/* --- AI Video Player Styles --- */
body.video-player-open {
    overflow: hidden;
}

#video-player-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: #0F0C29;
    background: linear-gradient(135deg, #0F0C29, #302B63, #24243E);
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s 0.4s;
    font-family: 'Inter', sans-serif;
    color: #f0f0f0;
}

#video-player-modal.open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease;
}

/* New wrapper to hold player and chapters side-by-side */
.video-player-container {
    display: flex;
    flex-direction: column; /* Changed to column to stack selection and player */
    gap: 16px;
    width: 95vw;
    max-width: 1200px;
    height: 90vh;
    max-height: 720px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: scale(0.95);
    position: relative; /* For absolute positioning inside */
}

#video-player-modal.open .video-player-container {
     transform: scale(1);
}

.video-player-main-area {
    display: flex;
    gap: 16px;
    flex-grow: 1;
    min-height: 0; /* Important for flex children */
}

.video-player-content {
    background: rgba(10, 9, 20, 0.6);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(124, 77, 255, 0.4);
    border-radius: 24px;
    flex: 3; /* Player takes more space */
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden; 
}

/* Script Selection Screen */
.video-script-selection-container {
    background: rgba(18, 15, 45, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(124, 77, 255, 0.3);
    border-radius: 20px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    height: 100%;
    box-shadow: 0 5px 25px rgba(0,0,0,0.3);
    position: relative;
}

.video-script-selection-container .close-selection-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: #e0e0e0;
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
}

.video-script-selection-container .close-selection-btn:hover {
    color: #c4b5fd;
    transform: scale(1.1) rotate(90deg);
}

.video-script-selection-container h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px rgba(124, 77, 255, 0.5);
}

.video-script-selection-container h2 .selection-word {
    color: #ffae68;
}

.video-script-selection-container p {
    font-size: 1.1rem;
    color: #d1c4e9;
    margin-bottom: 2.5rem;
    max-width: 600px;
}

.video-script-options {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.video-script-option-btn {
    background: rgba(10, 9, 20, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    width: 200px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.video-script-option-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
}

.video-script-option-btn .icon-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: #fff;
    transition: all 0.3s ease;
}

.video-script-option-btn:hover .icon-container {
    transform: scale(1.1);
}

.video-script-option-btn#explanation-btn .icon-container {
    background: linear-gradient(45deg, #fd6c3c, #ff9a44);
    box-shadow: 0 0 20px #fd6c3c;
}

.video-script-option-btn#comparison-btn .icon-container {
    background: linear-gradient(45deg, #ef4444, #ff6b6b);
    box-shadow: 0 0 20px #ef4444;
}

.video-script-option-btn#thematic-btn .icon-container {
    background: linear-gradient(45deg, #e75480, #ff8dac);
    box-shadow: 0 0 20px #e75480;
}

.video-script-option-btn h4 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
    color: #fff; /* Ensure text is white */
}

.video-script-option-btn p {
    font-size: 0.9rem;
    color: #c4b5fd;
    line-height: 1.4;
    margin: 0;
}

/* Comparison Sub-flow styling */
.video-comparison-subflow {
    padding: 2rem;
    text-align: center;
}

.video-comparison-subflow h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.video-comparison-subflow h3 .selection-word {
    color: #ffae68;
    font-style: italic;
}

.video-comparison-subflow p {
    font-size: 1.1rem;
    color: #d1c4e9;
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.video-comparison-subflow .controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.video-comparison-subflow .controls button {
    background: transparent;
    border: 2px solid;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.video-comparison-subflow .controls button:hover {
    transform: scale(1.1);
}

.video-comparison-subflow .yes-btn {
    color: #4ade80;
    border-color: #4ade80;
}
.video-comparison-subflow .yes-btn:hover {
    background: #4ade80;
    color: #110f1c;
}

.video-comparison-subflow .no-btn {
    color: #f87171;
    border-color: #f87171;
}
.video-comparison-subflow .no-btn:hover {
    background: #f87171;
    color: #110f1c;
}

.video-comparison-input-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.video-comparison-input-area .input-group {
    display: flex;
    gap: 1rem;
    width: 100%;
    max-width: 500px;
}

.video-comparison-input-area input {
    flex-grow: 1;
    padding: 0.8rem 1rem;
    font-size: 1.1rem;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
    transition: border-color 0.2s;
}
.video-comparison-input-area input:focus {
    outline: none;
    border-color: #ef4444;
}

.video-comparison-input-area .submit-comparison-btn {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 0 1.5rem;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s;
}

.video-comparison-input-area .submit-comparison-btn:hover {
    background: #c13131;
}

.video-comparison-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    max-width: 600px;
}

.video-comparison-suggestions .suggestion-chip {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f0f0f0;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.video-comparison-suggestions .suggestion-chip:hover {
    background: #ef4444;
    border-color: #ef4444;
}

/* Chapters panel is now part of the main layout */
.video-chapters-panel-container {
    background: rgba(18, 15, 45, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(124, 77, 255, 0.3);
    border-radius: 20px;
    flex: 1; /* Chapters take less space */
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 25px rgba(0,0,0,0.3);
}

.video-player-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(124, 77, 255, 0.2);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.video-title {
    font-size: 1.5rem;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(124, 77, 255, 0.5);
}

.video-player-top-controls button {
    background: transparent;
    border: none;
    color: #e0e0e0;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    margin-left: 1rem;
}

.video-player-top-controls .video-chapters-toggle-btn {
    display: none; /* Button to toggle chapters is no longer needed */
}

.video-player-top-controls button:hover {
    color: #7c4dff;
    transform: scale(1.1);
}

.teleprompter-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.teleprompter-live-indicator {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 12px;
    height: 12px;
    background: #ff4d4d;
    border-radius: 50%;
    box-shadow: 0 0 10px #ff4d4d;
    animation: pulse 2s infinite;
}

.teleprompter-text {
    font-size: 2.5rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.teleprompter-text em {
    font-style: italic;
    color: #d1c4e9; 
}

.teleprompter-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.video-player-bottom-bar {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(124, 77, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.video-controls button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.video-controls button:hover {
    background: #7c4dff;
    transform: translateY(-2px);
}

.video-progress-container {
    flex-grow: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.video-progress-container:hover {
    transform: scaleY(1.5);
}

.video-progress-bar {
    width: 0%;
    height: 100%;
    background: #7c4dff;
    border-radius: 4px;
    transition: width 0.5s linear;
    box-shadow: 0 0 10px #7c4dff;
}

.video-player-loader,
.video-player-error, 
.video-player-end-screen {
    position: absolute;
    inset: 0;
    background: rgba(15, 12, 41, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 2rem;
    text-align: center;
}

.video-player-error {
    gap: 1.5rem;
}

.video-player-error-message {
    font-size: 1.5rem;
    margin: 0;
}

.video-player-error .video-error-exit-btn {
     background: rgba(255, 255, 255, 0.1);
     border: 1px solid rgba(255, 255, 255, 0.3);
     color: white;
     padding: 0.8rem 1.5rem;
     font-size: 1.2rem;
     border-radius: 8px;
     cursor: pointer;
     transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
     display: flex;
     align-items: center;
     gap: 0.5em;
}

.video-player-error .video-error-exit-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: none;
    transform: scale(1.05) translateY(-2px);
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #7c4dff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-text {
    margin-top: 1.5rem;
    font-size: 1.2rem;
    animation: text-pulse 2s infinite;
}

.video-player-end-screen {
    gap: 1.5rem;
}

.end-screen-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
    margin-top: 1.5rem;
}

.video-player-end-screen button {
     background: #7c4dff;
     border: none;
     color: white;
     padding: 0.8rem 1.5rem;
     font-size: 1.2rem;
     border-radius: 8px;
     cursor: pointer;
     transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
     display: flex;
     align-items: center;
     gap: 0.5em;
}

.video-player-end-screen button:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 0 15px #7c4dff;
}

.video-player-end-screen .video-elaborate-btn {
    background: #ff5277;
}

.video-player-end-screen .video-elaborate-btn:hover {
    box-shadow: 0 0 15px #ff5277;
}

.video-player-end-screen .video-exit-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.video-player-end-screen .video-exit-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: none;
}

.video-explore-next-container {
    margin-top: 2rem;
    width: 100%;
    max-width: 600px;
}

.video-explore-next-container h4 {
    font-size: 1.1rem;
    color: #d1c4e9;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    text-align: center;
}

.video-explore-next-words {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.explore-next-word {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f0f0f0;
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.explore-next-word:hover {
    background: #7c4dff;
    border-color: #7c4dff;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(124, 77, 255, 0.4);
}

/* Script Panel is still a slide-out */
#video-script-panel {
    position: fixed;
    top: 0;
    right: -450px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: rgba(30, 27, 60, 0.9);
    backdrop-filter: blur(15px);
    z-index: 2001;
    display: none;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
    transition: right 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

#video-script-panel.open {
    right: 0;
}

.video-script-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(124, 77, 255, 0.2);
}

.video-script-header .header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Chapters panel is no longer a slide-out */
.video-chapters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(124, 77, 255, 0.2);
}

.video-script-header h3, .video-chapters-header h3 {
    font-size: 1.2rem;
    margin: 0;
}

.video-chapters-header .video-chapters-close-btn {
    display: none; /* No close button needed for static panel */
}

.video-script-header button {
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s, background-color 0.2s;
    padding: 0.25rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-script-header button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #7c4dff;
    transform: scale(1.1);
}

.video-script-content, .video-chapters-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

.video-script-list, .video-chapters-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.video-chapters-list {
    list-style-type: decimal;
    padding-left: 1.5rem;
}

.video-chapters-list li {
    padding-left: 0.5rem;
}

.video-script-list li, .video-chapters-list li {
    padding: 0.8rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    transition: background 0.3s, color 0.3s, box-shadow 0.3s;
    line-height: 1.5;
    cursor: pointer;
}

.video-script-list li:hover, .video-chapters-list li:hover {
    background: rgba(124, 77, 255, 0.1);
}

.video-script-list li.active, .video-chapters-list li.active {
    background: rgba(124, 77, 255, 0.3);
    color: #fff;
    box-shadow: inset 3px 0 0 #ab87ff;
}

.video-script-list li.active:hover, .video-chapters-list li.active:hover {
    background: rgba(124, 77, 255, 0.35);
}

.video-script-list li em {
    font-style: italic;
    color: #e0cffc;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes text-pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* --- New Button Style --- */
.video-btn {
  background: linear-gradient(45deg, #00dbde, #fc00ff);
  color: #fff;
  border: none;
  border-radius: 8px;
  min-width: 48px;
  padding: 0.5rem 1rem;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.6em;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(252, 0, 255, 0.3);
}

.video-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 219, 222, 0.4);
}