:root {
    --primary: #0056b3;
    /* BSNL Blue */
    --primary-hover: #004494;
    --accent: #007bff;
    --success: #198754;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

/* Print Protection */
@media print {
    body {
        display: none !important;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Navbar - Flat */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-main);
    transition: transform 0.3s ease;
}

.brand {
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Player View & Mobile Layout */
/* Player View & Mobile Layout - GLOBAL DRAWER MODE */
.player-layout {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: block;
}

/* Sidebar - Off-canvas Drawer */
.sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100%;
    background: var(--bg-card);
    z-index: 2200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    transform: translateX(0);
}

/* Backdrop for Sidebar */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.sidebar.open+.sidebar-overlay {
    /* Handled via JS typically, but kept for reference */
    opacity: 1;
    pointer-events: auto;
}

/* Content Area - Full Screen */
.content-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 80px 20px 20px 20px;
    /* Top padding for FAB space */
    overflow-y: auto;
    z-index: 1;
    background: var(--bg-main);
}

/* Mobile Nav (Hidden on Desktop) */
.mobile-nav {
    display: none;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 10px 15px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    margin-bottom: 10px;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 5px;
}

.mobile-title {
    font-weight: 600;
    font-size: 1rem;
    text-transform: uppercase;
}

/* Typography */
h1,
h2,
h3 {
    font-weight: 600;
    margin-top: 0;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* Cards - Flat */
.card,
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--primary);
}

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

/* Inputs & Buttons */
.input-field {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 12px;
    border-radius: 6px;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
}

.input-field:focus {
    border-color: var(--primary);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: 1px solid transparent;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

.btn-outline:hover {
    border-color: var(--text-muted);
}

/* Utilities */
.hidden {
    display: none !important;
}

.text-sm {
    font-size: 0.875rem;
}

.text-muted {
    color: var(--text-muted);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    position: relative;
}

/* Tree View & Mini Accordion */
.tree-header {
    font-weight: 600;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: var(--bg-card);
    transition: background 0.2s;
    margin-top: 10px;
    /* Spacing between groups */
    border-top: 1px solid var(--border);
    /* Visual separator */
}

/* First header shouldn't have margin/border if at very top, but padding handles it */
.tree-header:first-child {
    margin-top: 0;
    border-top: none;
}


.tree-header:hover {
    background: var(--bg-main);
}

.tree-header i {
    transition: transform 0.3s;
}

.tree-header.active i {
    transform: rotate(180deg);
    color: var(--primary);
}

.tree-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--bg-main);
}

.tree-header.active+.tree-content {
    max-height: 8000px;
}

.tree-item {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    white-space: normal;
    overflow-wrap: break-word;
}

.tree-item span {
    flex: 1;
    min-width: 0;
}

.tree-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.tree-item.active-file {
    background: #e0f2fe;
    color: #0369a1;
    border-left: 3px solid #0369a1;
}

.free-preview-tag {
    background: #f59e0b;
    color: white;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 1px 1.5px;
    border-radius: 3px;
    margin-left: auto;
    text-transform: uppercase;
    flex: none !important;
    width: fit-content !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* MCQ Styles */
.mode-card {
    padding: 30px;
    border: 2px solid var(--border);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    background: var(--bg-card);
    transition: all 0.2s;
}

.mode-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.mcq-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

.option-btn {
    text-align: left;
    background: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    margin-bottom: 8px;
    transition: background 0.2s, border-color 0.2s;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--primary);
}

.option-btn.correct {
    background: #d1fae5 !important;
    border-color: var(--success) !important;
    color: #065f46;
}

.option-btn.wrong {
    background: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #991b1b;
}

.explanation-box {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-main);
    border-left: 4px solid var(--accent);
}

/* Big Accordion (Courses) */
.accordion-container {
    max-width: 900px;
    margin: 30px auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.accordion-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.accordion-header {
    padding: 24px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accordion-title {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    gap: 10px;
    align-items: center;
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 0;
    background: var(--bg-main);
}

.accordion-item.active .accordion-content {
    max-height: 8000px;
    opacity: 1;
    padding: 24px;
    border-top: 1px solid var(--border);
}


/* --- MOBILE OPTIMIZATIONS --- */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    /* Hide Desktop Elements */
    .desktop-only {
        display: none !important;
    }

    .navbar {
        display: flex;
        /* Show on mobile homepage */
        padding: 10px 15px;
        /* Adjust padding for mobile */
    }

    /* Show navbar on homepage, hide when player is active */
    body.player-active .navbar {
        display: none !important;
    }

    /* Player View Container - Full Screen */
    #player-view {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: var(--bg-main);
        z-index: 100;
        padding: 0 !important;
        margin: 0;
    }



    /* Font Adjustments */
    .accordion-title {
        font-size: 1.2rem;
    }

    #display-price {
        font-size: 3rem;
    }

    .home-hamburger,
    .navbar {
        display: none !important;
    }
}

/* Home Drawer - Global Access via FAB */
.home-drawer {
    position: fixed;
    width: 280px;
    height: 100%;
    top: 0;
    left: 0;
    background: var(--bg-card);
    z-index: 2200;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.home-drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-main);
}

.drawer-item {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
    color: var(--text-main);
    cursor: pointer;
}

.drawer-item:active {
    background: var(--bg-main);
}

/* Global FAB Styles (Visible on Mobile & Desktop per user request, but usually Mobile) */
.floating-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    z-index: 3000;
    /* Highest */
    cursor: grab;
    touch-action: none;
    /* Prevent scroll while dragging */
    transition: transform 0.1s, box-shadow 0.2s;
}

/* Responsive Modal Grid */
.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.date-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

@media (max-width: 480px) {
    .modal-content {
        width: 95% !important;
        margin: 10px auto;
    }

    .input-grid {
        grid-template-columns: 1fr;
    }

    .date-row {
        flex-direction: column;
        align-items: stretch;
    }

    .date-row span {
        text-align: center;
        padding: 5px 0;
    }
}


/* Close Button (Floating Top Right in Player) */
.floating-close-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-main);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    z-index: 2300;
    /* Above drawer */
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.floating-close-btn:hover {
    background: rgba(0, 0, 0, 0.2);
}

.floating-close-btn:active {
    transform: scale(0.95);
}

/* Font Size Control Display */
#font-size-display {
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 25px;
    text-align: center;
    color: var(--text-main);
}



.floating-fab:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.floating-fab.dragging {
    opacity: 0.9;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    transition: none;
}

/* Hide Old Floating Buttons in Player since we use Global FAB now */
.floating-menu-btn {
    display: none !important;
}

/* Hide Navbar Globally */
.navbar {
    display: none !important;
}

/* Desktop: Hide Home Hamburger (Legacy button, not FAB) */
@media (min-width: 769px) {
    .home-hamburger {
        display: none !important;
    }
}

/* Chapter Navigation Buttons */
.nav-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    gap: 15px;
}

.nav-btn {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 50px;
    /* Pillow shape like FAB/Close */
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    max-width: 48%;
    /* Prevent overlapping on small screens */
}

.nav-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--text-muted);
}

.nav-btn.prev {
    margin-right: auto;
}

.nav-btn.next {
    margin-left: auto;
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.nav-btn.next:hover {
    background: var(--primary-hover);
}