@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --bg-dark: #090d16;
    --bg-card: #111827;
    --bg-card-hover: #1e293b;
    --bg-subtle: #172033;
    --border: #26334d;
    --border-highlight: #3b82f6;

    --primary: #10b981;
    --primary-hover: #059669;
    --primary-glow: rgba(16, 185, 129, 0.25);

    --gold: #f59e0b;
    --gold-glow: rgba(245, 158, 11, 0.2);

    --danger: #ef4444;
    --text-white: #f8fafc;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-white);
    font-family: 'Plus Jakarta Sans', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header */
header {
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: var(--text-white);
}

.brand-icon {
    font-size: 1.5rem;
    background: linear-gradient(135deg, #10b981, #059669);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #ffffff, #a7f3d0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

/* Earnings Pill */
.earnings-strip {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.2));
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 0.4rem 1.1rem;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 1.2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.earnings-metric {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.earnings-metric strong {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-white);
}

.earnings-metric.owed strong {
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold-glow);
}

/* Role Selector */
.role-pill {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.role-pill label {
    font-size: 0.75rem;
    color: var(--text-subtle);
    font-weight: 600;
    text-transform: uppercase;
}

.role-pill select {
    background: transparent;
    color: var(--text-white);
    border: none;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

/* Main Layout */
.app-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 1.75rem;
    padding: 1.75rem 2rem;
    flex: 1;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Sidebar & Episodes */
.sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    position: sticky;
    top: 95px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.sidebar-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.sidebar-title {
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.course-progress-card {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    margin-top: 0.75rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.progress-bar-bg {
    background: rgba(255, 255, 255, 0.08);
    height: 8px;
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    background: linear-gradient(90deg, #10b981, #34d399);
    height: 100%;
    width: 0%;
    transition: width 0.4s ease;
    border-radius: var(--radius-full);
}

.bonus-milestone {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--gold);
    font-weight: 700;
    margin-top: 0.5rem;
}

.episode-list {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding-right: 0.25rem;
}

.episode-list::-webkit-scrollbar {
    width: 5px;
}
.episode-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.episode-card {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.episode-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.episode-card.active {
    background: rgba(16, 185, 129, 0.12);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.ep-num-pill {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
}

.episode-card.active .ep-num-pill {
    background: var(--primary);
    color: #064e3b;
}

.ep-info {
    flex: 1;
    overflow: hidden;
}

.ep-title {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Cairo', sans-serif;
}

.ep-tag {
    font-size: 0.72rem;
    color: var(--text-subtle);
}

.ep-badge-passed {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.55rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(16, 185, 129, 0.4);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Content Area */
.content-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Mode Selection Card */
.mode-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.mode-info h2 {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
    font-family: 'Cairo', sans-serif;
}

.mode-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.mode-toggle-group {
    display: flex;
    gap: 0.85rem;
}

.mode-button {
    background: var(--bg-subtle);
    border: 2px solid var(--border);
    color: var(--text-white);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 170px;
    text-align: left;
}

.mode-button:hover {
    border-color: var(--text-muted);
}

.mode-button.active {
    background: rgba(16, 185, 129, 0.12);
    border-color: var(--primary);
    box-shadow: 0 0 16px var(--primary-glow);
}

.mode-button .mode-name {
    font-size: 0.85rem;
    font-weight: 700;
}

.mode-button .mode-reward {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--gold);
}

/* Player Frame */
.player-wrapper {
    background: #000;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    padding-bottom: 56.25%;
    height: 0;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

@supports (aspect-ratio: 16 / 9) {
    .player-wrapper {
        height: auto;
        padding-bottom: 0;
    }
}

.player-wrapper #yt-player,
.player-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: 0;
    display: block;
}

/* Playback Alert / Unlock Strip */
.player-status-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.pulse-dot {
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.btn-dev-skip {
    background: transparent;
    border: 1px dashed var(--text-subtle);
    color: var(--text-subtle);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-dev-skip:hover {
    color: var(--gold);
    border-color: var(--gold);
}

/* Quiz Section */
.quiz-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.3s ease;
}

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

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.quiz-header h3 {
    font-size: 1.15rem;
    font-weight: 800;
}

.quiz-pass-badge {
    background: rgba(245, 158, 11, 0.15);
    color: var(--gold);
    border: 1px solid rgba(245, 158, 11, 0.3);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
}

.question-block {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.question-heading {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    font-family: 'Cairo', sans-serif;
    line-height: 1.6;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
}

.option-pill {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.15rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-pill:hover {
    border-color: var(--primary);
    background: rgba(16, 185, 129, 0.05);
}

.option-pill input[type="radio"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.option-pill span {
    font-size: 0.92rem;
    font-weight: 500;
    font-family: 'Cairo', sans-serif;
}

.btn-primary {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    border: none;
    padding: 0.85rem 2rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 16px var(--primary-glow);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

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

.modal-dialog {
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    max-width: 480px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.modal-dialog.failed {
    border-color: var(--danger);
}

.modal-score-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-subtle);
    border: 4px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 800;
    margin: 1.25rem auto;
    color: var(--primary);
}

.modal-dialog.failed .modal-score-circle {
    border-color: var(--danger);
    color: var(--danger);
}

/* Admin Dashboard */
.admin-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 800;
    margin-top: 0.35rem;
}

.metric-value.green { color: var(--primary); }
.metric-value.gold { color: var(--gold); }

.admin-action-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.payout-presets {
    display: flex;
    gap: 0.5rem;
}

.preset-btn {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--text-white);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
}

.preset-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

/* Tables */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-table th {
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Responsive Design System */
@media (max-width: 1024px) {
    .app-layout {
        grid-template-columns: 1fr;
        padding: 1.25rem 1.5rem;
    }
    .sidebar {
        height: auto;
        position: static;
        order: 2;
    }
    .content-area {
        order: 1;
    }
}

@media (max-width: 768px) {
    header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .brand {
        justify-content: flex-start;
    }

    .header-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .earnings-strip {
        padding: 0.35rem 0.75rem;
        gap: 0.65rem;
        font-size: 0.75rem;
    }

    .earnings-metric {
        font-size: 0.75rem;
    }

    .earnings-metric strong {
        font-size: 0.85rem;
    }

    .app-layout {
        padding: 0.85rem 0.75rem;
        gap: 1rem;
        display: flex;
        flex-direction: column;
    }

    .content-area {
        order: 1;
        gap: 1rem;
    }

    .sidebar {
        order: 2;
        padding: 1rem;
    }

    .episode-list {
        max-height: 280px;
        overflow-y: auto;
    }

    .mode-card {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        gap: 0.85rem;
    }

    .mode-toggle-group {
        flex-direction: column;
        width: 100%;
        gap: 0.65rem;
    }

    .mode-button {
        width: 100%;
        min-width: 0;
        min-height: 48px;
        padding: 0.85rem 1rem;
    }

    .extension-support-banner {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 1rem;
    }

    .extension-support-banner > div:last-child {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .btn-yt-external, .btn-dev-skip {
        width: 100%;
        justify-content: center;
        text-align: center;
        min-height: 44px;
    }

    .vocab-drawer {
        padding: 1rem;
    }

    .vocab-grid {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }

    .quiz-box {
        padding: 1rem;
    }

    .question-block {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .option-pill {
        padding: 0.85rem 1rem;
        min-height: 48px;
    }

    .btn-primary {
        width: 100%;
        justify-content: center;
        padding: 0.85rem 1.25rem;
        min-height: 48px;
    }

    .modal-dialog {
        padding: 1.75rem 1.25rem;
        width: 92%;
    }

    /* Admin Mobile Responsiveness */
    .admin-metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .metric-card {
        padding: 1rem;
    }

    .metric-value {
        font-size: 1.4rem;
    }

    .admin-action-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        gap: 1rem;
    }

    .payout-presets {
        width: 100%;
        display: flex;
        gap: 0.35rem;
    }

    .preset-btn {
        flex: 1;
        padding: 0.5rem 0.25rem;
        text-align: center;
        font-size: 0.78rem;
    }

    #payout-amount {
        width: 100% !important;
        min-height: 44px;
        box-sizing: border-box;
    }

    .admin-action-bar button.btn-primary {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table th, .data-table td {
        padding: 0.65rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .admin-nav-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: space-between;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .brand-title {
        font-size: 1.1rem;
    }
    
    .brand-icon {
        width: 34px;
        height: 34px;
        font-size: 1.25rem;
    }

    .earnings-strip {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem 0.8rem;
    }

    .admin-metrics-grid {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 1.5rem 1.1rem !important;
    }

    .form-input, .text-input, .select-input {
        font-size: 16px !important; /* Prevents auto-zoom on iOS Safari */
    }
}
