/* ===== CSS Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2236;
    --bg-card: #1e293b;
    --bg-hover: #243047;
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --accent-dark: #d97706;
    --accent-glow: rgba(245, 158, 11, 0.15);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #2d3a4f;
    --success: #22c55e;
    --error: #ef4444;
    --info: #3b82f6;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 4px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --transition: 0.2s ease;
    --sidebar-width: 320px;
    --controls-height: 80px;
}

html { font-size: 16px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ===== Layout ===== */
.webinar-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition), width var(--transition);
    z-index: 20;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-header h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.sidebar-header p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.section-group { margin-bottom: 4px; }

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    cursor: pointer;
    transition: background var(--transition);
    user-select: none;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.section-header:hover { background: var(--bg-hover); }

.section-header.active {
    color: var(--accent);
    background: var(--accent-glow);
}

.section-header .section-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.section-header.active .section-icon { opacity: 1; }

.section-header .chevron {
    margin-left: auto;
    width: 14px;
    height: 14px;
    transition: transform var(--transition);
    opacity: 0.5;
}

.section-header.expanded .chevron { transform: rotate(90deg); }

.section-slides {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.section-slides.expanded { max-height: 500px; }

.slide-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px 8px 48px;
    cursor: pointer;
    transition: background var(--transition);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.slide-item:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.slide-item.active {
    color: var(--accent);
    background: var(--accent-glow);
}

.slide-item.completed { color: var(--success); }

.slide-item .slide-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.slide-item.active .slide-num {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.slide-item.completed .slide-num {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.slide-item .slide-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar progress */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.progress-bar-bg {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-dark), var(--accent-light));
    border-radius: 2px;
    transition: width 0.4s ease;
    width: 0%;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* Top bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 16px;
    min-height: 50px;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.btn-toggle-sidebar {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-toggle-sidebar:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.current-slide-info {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.current-slide-info span {
    color: var(--accent);
    margin-right: 8px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-size: 0.75rem;
    gap: 4px;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-icon.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent);
}

/* ===== Slide Viewer ===== */
.slide-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
}

.slide-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide-image {
    max-width: 100%;
    max-height: calc(100vh - 260px);
    width: auto;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.slide-image.loading { opacity: 0.3; }

/* Slide navigation arrows */
.slide-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(17, 24, 39, 0.8);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    z-index: 5;
    backdrop-filter: blur(8px);
}

.slide-nav-arrow:hover {
    background: rgba(17, 24, 39, 0.95);
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-50%) scale(1.05);
}

.slide-nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.slide-nav-arrow.prev { left: 16px; }
.slide-nav-arrow.next { right: 16px; }

/* ===== Transcript Panel ===== */
.transcript-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(10, 14, 26, 0.95) 30%);
    padding: 40px 60px 16px;
    pointer-events: none;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.transcript-panel.visible { transform: translateY(0); }

.transcript-text {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-primary);
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
    pointer-events: auto;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

/* ===== Controls Bar ===== */
.controls-bar {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 0 20px;
    flex-shrink: 0;
}

.timeline-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0 4px;
}

.timeline-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    cursor: pointer;
    outline: none;
    position: relative;
}

.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
    transition: transform var(--transition);
}

.timeline-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }

.timeline-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

.time-display {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 90px;
    text-align: center;
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0 10px;
}

.controls-left,
.controls-center,
.controls-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.controls-left { flex: 1; justify-content: flex-start; }
.controls-center { flex: 0; }
.controls-right { flex: 1; justify-content: flex-end; }

.ctrl-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.ctrl-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.ctrl-btn.active { color: var(--accent); }
.ctrl-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.ctrl-btn.play-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--bg-primary);
    margin: 0 8px;
}

.ctrl-btn.play-btn:hover {
    background: var(--accent-light);
    transform: scale(1.05);
}

.speed-btn {
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 42px;
    text-align: center;
    padding: 6px 8px;
}

.volume-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.volume-slider {
    width: 80px;
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    cursor: pointer;
    outline: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-secondary);
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-secondary);
    border: none;
}

/* ===== Quiz Modal ===== */
.quiz-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 26, 0.92);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

.quiz-overlay.active { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.quiz-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    max-width: 640px;
    width: min(100%, 640px);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.quiz-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-glow);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 16px;
}

.quiz-modal h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.quiz-modal .quiz-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 24px;
}

.quiz-question {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.5;
}

.quiz-question-counter {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }

.quiz-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
}

.quiz-option:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.quiz-option.selected {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.quiz-option.correct {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.quiz-option.incorrect {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.quiz-option .option-letter {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.quiz-option.selected .option-letter {
    background: var(--accent);
    color: var(--bg-primary);
}

.quiz-option.correct .option-letter {
    background: var(--success);
    color: white;
}

.quiz-option.incorrect .option-letter {
    background: var(--error);
    color: white;
}

.quiz-explanation {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: none;
}

.quiz-explanation.visible { display: block; }

.quiz-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    position: sticky;
    bottom: -1px;
    z-index: 1;
    padding-top: 12px;
    background: var(--bg-card);
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary:hover { background: var(--accent-light); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ===== Completion Screen ===== */
.completion-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 26, 0.95);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
}

.completion-overlay.active { display: flex; }

.completion-card {
    text-align: center;
    padding: 48px;
    max-width: 520px;
    width: 90%;
    animation: slideUp 0.5s ease;
}

.completion-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: var(--accent-glow);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.completion-card h2 {
    font-size: 1.75rem;
    margin-bottom: 12px;
}

.completion-card p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.completion-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 28px 0;
    padding: 20px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.completion-stat { text-align: center; }
.completion-stat .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.completion-stat .stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.completion-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

/* ===== Welcome Screen ===== */
.welcome-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

.welcome-overlay.hiding {
    opacity: 0;
    pointer-events: none;
}

.welcome-card {
    text-align: center;
    max-width: 600px;
    width: 90%;
    padding: 48px;
}

.welcome-card .logo-mark {
    width: 64px;
    height: 64px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, var(--accent-dark), var(--accent-light));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-card h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    line-height: 1.3;
}

.welcome-card .welcome-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 32px;
}

.welcome-details {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 36px;
}

.welcome-detail {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.welcome-detail svg { color: var(--accent); }

.btn-start {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    color: var(--bg-primary);
    border: none;
    padding: 14px 48px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(245, 158, 11, 0.45);
}

.welcome-resume {
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.welcome-resume a {
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
}

.welcome-resume a:hover { text-decoration: underline; }

/* ===== Keyboard Shortcuts Tooltip ===== */
.shortcuts-tooltip {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    z-index: 50;
    box-shadow: var(--shadow-lg);
    display: none;
    min-width: 260px;
}

.shortcuts-tooltip.visible { display: block; }

.shortcuts-tooltip h3 {
    font-size: 0.85rem;
    margin-bottom: 12px;
    color: var(--accent);
}

.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.75rem;
}

.shortcut-row .key {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    font-family: monospace;
    font-size: 0.7rem;
}

/* ===== Notification Toast ===== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    z-index: 300;
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    transform: translateX(120%);
    transition: transform 0.3s ease;
}

.toast.visible { transform: translateX(0); }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 30;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.collapsed { transform: translateX(-100%); }

    .slide-image { max-height: calc(100vh - 220px); }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 280px; }

    .top-bar { padding: 8px 12px; }
    .slide-area { padding: 8px; }
    .controls-bar { padding: 0 12px; }

    .transcript-panel { padding: 30px 20px 12px; }
    .transcript-text { font-size: 0.8rem; }

    .volume-slider { display: none; }

    .slide-nav-arrow { width: 36px; height: 36px; }
    .slide-nav-arrow.prev { left: 8px; }
    .slide-nav-arrow.next { right: 8px; }

    .quiz-modal { padding: 24px; }
}

/* ===== Fullscreen ===== */
.webinar-container:fullscreen .sidebar { display: none; }
.webinar-container:-webkit-full-screen .sidebar { display: none; }

/* ===== Loading states ===== */
@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.loading-pulse { animation: pulse 1.5s infinite; }

/* ===== SVG icon sizing ===== */
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }
