/* ==========================================================================
   THEME VARIABLES & BASE STYLES
   ========================================================================== */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-blue: #38bdf8;
    --accent-purple: #a855f7;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-orange: #f97316;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.8);
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --accent-blue: #0284c7;
    --accent-purple: #7e22ce;
    --accent-green: #16a34a;
    --accent-red: #dc2626;
    --accent-orange: #ea580c;
    --border-color: rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.05);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    transition: background-color 0.3s, color 0.3s;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 95;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: fixed;
    height: 100vh;
    top: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
    justify-content: space-between;
}

.brand-icon {
    font-size: 1.8rem;
    color: var(--accent-blue);
}

.brand-text h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.brand-text h2 span {
    color: var(--accent-blue);
}

.brand-text p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.sidebar-close-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-blue);
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-theme {
    width: 100%;
    padding: 0.6rem;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: calc(100% - 260px);
}

.top-header {
    min-height: 70px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    max-width: 500px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
    padding: 0.4rem;
}

.search-box {
    position: relative;
    width: 300px;
    max-width: 100%;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-box input {
    width: 100%;
    padding: 0.5rem 0.5rem 0.5rem 2.2rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    outline: none;
    font-size: 0.9rem;
}

.search-dropdown {
    position: absolute;
    top: 110%;
    left: 0;
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    z-index: 200;
    box-shadow: var(--shadow);
}

.search-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.search-item:hover {
    background: rgba(56, 189, 248, 0.1);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
}

.xp-badge { background: rgba(168, 85, 247, 0.15); color: var(--accent-purple); }
.streak-badge { background: rgba(249, 115, 22, 0.15); color: var(--accent-orange); }

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.avatar { font-size: 1.5rem; color: var(--accent-blue); }

/* Dynamic Content Views */
.view-container {
    padding: 2rem;
    flex: 1;
    width: 100%;
}

.content-view {
    display: none;
}

.content-view.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Dashboard Elements */
.welcome-banner {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(168, 85, 247, 0.2));
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.welcome-banner h1 { font-size: 1.8rem; margin-bottom: 0.5rem; word-break: break-word; }
.welcome-banner p { color: var(--text-secondary); margin-bottom: 1rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    backdrop-filter: blur(8px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    flex-shrink: 0;
}

.bg-blue { background: var(--accent-blue); }
.bg-green { background: var(--accent-green); }
.bg-purple { background: var(--accent-purple); }
.bg-orange { background: var(--accent-orange); }

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin: 0.4rem 0;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-blue);
    width: 0%;
    transition: width 0.4s ease;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.revision-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    word-break: break-word;
}

.card-header h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Alert Boxes */
.alert-box {
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    gap: 0.8rem;
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.alert-danger { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--accent-red); color: #fca5a5; }
.alert-info { background: rgba(56, 189, 248, 0.15); border: 1px solid var(--accent-blue); color: #93c5fd; }
.alert-warning { background: rgba(249, 115, 22, 0.15); border: 1px solid var(--accent-orange); color: #fdba74; }

/* Modules Grid */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s;
}

.module-card:hover { transform: translateY(-4px); }

.module-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.module-card p { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 1rem; }

/* Lesson content tables */
.lesson-body-text table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    margin-top: 1rem;
}

/* Practice & Tabs */
.tab-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    white-space: nowrap;
}

.tab-btn {
    padding: 0.6rem 1.2rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.fill-practice-form p {
    font-size: 1.05rem;
    line-height: 2.2;
}

.fill-practice-form input, .fill-practice-form select {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    max-width: 100%;
}

.form-control {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    outline: none;
    font-family: inherit;
}

/* Flashcards */
.flashcard-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    width: 100%;
}

.flashcard {
    width: 100%;
    max-width: 500px;
    min-height: 280px;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 280px;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    box-sizing: border-box;
}

.flashcard-back {
    transform: rotateY(180deg);
}

.flashcard-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hindi-box {
    background: rgba(168, 85, 247, 0.1);
    border-left: 3px solid var(--accent-purple);
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-top: 0.5rem;
    word-break: break-word;
}

/* Buttons */
.btn-primary {
    background: var(--accent-blue);
    color: #fff;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

/* Acronym & Revision */
.acronym-box {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.acronym-box .letter {
    color: var(--accent-blue);
    font-size: 1.4rem;
}

.plan-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.plan-list li {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Certificate Styles */
.certificate-container {
    padding: 2rem;
    background: #fff;
    color: #000;
    border-radius: 12px;
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.certificate-border {
    border: 8px double #1e293b;
    padding: 2rem;
}

.cert-badge { font-size: 3rem; color: #d97706; margin-bottom: 1rem; }
.certificate-container h1 { font-size: 2.2rem; margin-bottom: 0.5rem; }
.cert-subtitle { font-style: italic; color: #475569; }
.certificate-container h2 { font-size: 1.8rem; color: #0284c7; margin: 1rem 0; }
.cert-body { line-height: 1.6; margin-bottom: 2rem; font-size: 0.95rem; }
.cert-footer { display: flex; justify-content: space-between; font-weight: 600; font-size: 0.85rem; }

/* Utilities */
.hidden { display: none !important; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mb-3 { margin-bottom: 1rem; }
.p-3 { padding: 1rem; }
.text-green { color: var(--accent-green); }
.text-muted { color: var(--text-secondary); }

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES (DESKTOP, TABLET, MOBILE)
   ========================================================================== */

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: var(--shadow);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close-btn {
        display: block;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .icon-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .dashboard-grid, .revision-grid {
        grid-template-columns: 1fr;
    }

    .search-box {
        width: 220px;
    }
}

@media (max-width: 768px) {
    .top-header {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .header-left {
        width: 100%;
        max-width: 100%;
        justify-content: space-between;
    }

    .search-box {
        width: 100%;
        flex: 1;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .stat-badge {
        padding: 0.35rem 0.6rem;
        font-size: 0.78rem;
    }

    .user-profile {
        font-size: 0.85rem;
    }

    .view-container {
        padding: 1rem;
    }

    .welcome-banner {
        padding: 1.25rem;
    }

    .welcome-banner h1 {
        font-size: 1.4rem;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 1rem;
    }

    .modules-grid {
        grid-template-columns: 1fr;
    }

    .tab-container {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1 1 auto;
        text-align: center;
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }

    .fill-practice-form input[type="text"],
    .fill-practice-form select {
        width: 100%;
        margin: 0.3rem 0;
    }

    .certificate-container {
        padding: 1rem;
    }

    .certificate-border {
        padding: 1rem;
    }

    .certificate-container h1 {
        font-size: 1.5rem;
    }

    .certificate-container h2 {
        font-size: 1.3rem;
    }

    .cert-footer {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header-right {
        flex-wrap: wrap;
    }

    .user-profile {
        margin-left: auto;
    }

    .flashcard {
        min-height: 320px;
    }

    .acronym-box {
        font-size: 1rem;
    }

    .acronym-box .letter {
        font-size: 1.2rem;
    }
}