/* ================= GLOBAL RESET ================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', 'Segoe UI', Arial, sans-serif;
}

html {
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
}

/* ================= DEFAULT BODY (Dashboard/Quiz/Result) ================= */

body {
    background: #f8fafc;
    color: #111827;
    min-height: 100vh;
    overflow-x: clip;
    max-width: 100%;
    background-image: 
        radial-gradient(circle at 0% 0%, rgba(255, 107, 0, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 100% 0%, rgba(255, 140, 26, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(255, 107, 0, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 0% 100%, rgba(255, 140, 26, 0.05) 0%, transparent 50%);
    background-attachment: fixed;
}

:root {
    --brand: #ff6b00;
    --accent: #ff8c1a;
    --bg: #f8fafc;
    --surface: #ffffff;
    --subtle: #fff7ed;
    --text: #111827;
    --muted: #64748b;
    --border: #e2e8f0;
}

/* ================= CONTAINER COMMON ================= */

.container {
    width: 90%;
    max-width: 1200px;
    margin: auto;
    padding: 20px;
}

/* ================= BUTTONS ================= */

button {
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    transition: 0.3s;
}

.primary-btn {
    background: #3b82f6;
    color: white;
}

.primary-btn:hover {
    background: #2563eb;
}

/* ================= CARD STYLE (Dashboard & Quiz Cards) ================= */

.card {
    background: #ffffff;
    color: #0f172a;
    padding: 30px;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(59, 130, 246, 0.15);
    border: 2px solid #e2e8f0;
    border-top: 6px solid #3b82f6;
}

/* ================= QUIZ OPTIONS ================= */

.options label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    padding: 15px 20px;
    margin: 12px 0;
    background: #f8fafc;
    border-radius: 16px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
    color: #334155;
    border: 2px solid #e2e8f0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

.options label:hover {
    background: #eff6ff;
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.1);
}

.options input[type="radio"]:checked+label {
    background-color: #3b82f6;
    color: #ffffff;
    border-color: #2563eb;
    font-weight: 600;
    box-shadow: 0 8px 15px rgba(59, 130, 246, 0.3);
}

/* ================= PROGRESS BAR ================= */

.progress-container {
    width: 100%;
    background: #e2e8f0;
    border-radius: 20px;
    height: 12px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 20px;
    transition: 0.3s;
}

/* ================= TIMER ================= */

.timer {
    font-weight: bold;
    font-size: 18px;
    color: #ef4444;
    background: #fee2e2;
    padding: 6px 14px;
    border-radius: 20px;
    display: inline-block;
}

/* ================= RESULT PAGE ================= */

.result-summary {
    background: #ffffff;
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    word-wrap: break-word;
    overflow-x: hidden;
    max-width: 100%;
}

.correct {
    color: #22c55e;
}

.wrong {
    color: #ef4444;
}

.options label.correct {
    background-color: #16a34a;
    border-color: #22c55e;
    color: white !important;
    font-weight: 600;
}

.options label.wrong {
    background-color: #dc2626;
    border-color: #ef4444;
    color: white !important;
    font-weight: 600;
}

/* Mobile Responsiveness for Result Page */
@media (max-width: 768px) {
    .result-summary {
        padding: 15px 20px;
        border-radius: 15px;
    }
    .options label {
        font-size: 15px;
        padding: 12px 15px;
    }
}

/* ===================================================== */
/* ================= AUTH PAGE ONLY ==================== */
/* ===================================================== */

body.auth-page {
    background: #f8fafc;
    background-image: 
        radial-gradient(circle at 0% 0%, rgba(255, 107, 0, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(255, 140, 26, 0.05) 0%, transparent 50%);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Signup/Login Container */

.auth-container, .signup-box {
    background: #ffffff;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
    color: #1e293b;
    border: 1px solid #e2e8f0;
}
.auth-container {
    width: 400px;
    border-radius: 24px;
    border-top: 4px solid #ff6b00;
}

/* Input Group */

.input-group {
    margin-bottom: 20px;
}

.auth-container input,
.auth-container select {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    font-size: 14px;
    outline: none;
    background: #f8fafc;
    color: #1e293b;
    transition: 0.2s;
}

.auth-container input:focus,
.auth-container select:focus {
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.1);
    border-color: #ff6b00;
    background: #ffffff;
}

.auth-link {
    text-align: center;
    margin-top: 20px;
}

.auth-link a {
    color: #ff6b00;
    text-decoration: none;
    font-weight: bold;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* ================= SIGNUP PAGE FIX ================= */

.signup-wrapper {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8fafc;
    background-image: 
        radial-gradient(circle at 0% 0%, rgba(255, 107, 0, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(255, 140, 26, 0.05) 0%, transparent 50%);
}
.signup-box {
    width: 100%;
    max-width: 440px;
    border-radius: 24px;
    border-top: 4px solid #ff6b00;
}

.auth-container h2, .signup-box h2 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 24px;
    color: #1e293b;
    font-weight: 800;
}

.signup-box .input-group {
    margin-bottom: 12px;
}

.signup-box input,
.signup-box select {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    outline: none;
    background: #f8fafc;
    color: #1e293b;
    font-size: 14px;
    transition: 0.2s;
}

.signup-box input:focus,
.signup-box select:focus {
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.1);
    border-color: #ff6b00;
    background: #ffffff;
}

.signup-btn {
    width: 100%;
    padding: 14px 16px;
    background: #ff6b00;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    color: white;
    transition: all 0.3s ease;
    margin-top: 5px;
    box-shadow: 0 4px 15px rgba(255, 107, 0, 0.3);
}

.signup-btn:hover {
    background: #ff8c1a;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 0, 0.4);
}

/* ================= SAFE DASHBOARD ENHANCEMENT ================= */

.dashboard-card h2 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 24px;
    color: #2563eb;
}

.olympiad-tagline {
    display: block;
    margin: 12px 0;
    font-weight: 800;
    color: #c2410c; /* High-contrast bold orange */
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    background: #fff7ed; /* Light orange tint background */
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #ffedd5;
}

/* Improve dropdown look */
.dashboard-card select {
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    font-size: 16px;
    margin-bottom: 15px;
    background: #f8fafc;
    color: #1e293b;
}

/* Improve Start button */
.dashboard-card button {
    background: #3b82f6;
    color: #ffffff;
    padding: 14px;
    border-radius: 10px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    transition: 0.3s;
}

.dashboard-card button:hover {
    background: #2563eb;
}

/* ================= PROFESSIONAL NAVBAR ================= */

nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 8px 5%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-wrap: wrap;
    gap: 10px;
}

.nav-important {
    display: flex;
    gap: 8px;
    align-items: center;
}

@media (min-width: 769px) {
    /* Hide the mobile navbar helper on desktop to remove redundant Home/Logout buttons */
    .nav-important {
        display: none !important;
    }

    /* Floating Timer for Desktop Layout */
    .desktop-timer {
        display: flex !important;
        font-size: 1.2rem;
        padding: 8px 16px;
        box-shadow: var(--shadow-sm);
        border: 1px solid rgba(239, 68, 68, 0.2);
        color: var(--danger);
        background-color: #fee2e2 !important;
        border-radius: 12px;
        font-weight: 700;
        align-items: center;
        gap: 10px;
    }

    /* Hide the mobile-specific timer on desktop */
    .mobile-timer {
        display: none !important;
    }
}

.nav-important a {
    text-decoration: none;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--brand);
    background: rgba(79, 70, 229, 0.08);
    padding: 4px 8px;
    border-radius: 8px;
    text-transform: uppercase;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    z-index: 1001;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--text);
    border-radius: 2px;
    transition: 0.3s;
}

.brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    transition: 0.3s;
}
.brand:hover {
    color: var(--brand);
}

.nav-links {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 800;
    text-transform: uppercase;
    transition: 0.3s;
    padding: 8px 12px;
    border-radius: 8px;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}

.nav-links a:hover {
    color: var(--brand);
    background: rgba(79, 70, 229, 0.05);
}

.nav-links a.active {
    color: var(--brand);
    background: rgba(79, 70, 229, 0.06);
    border-bottom-color: var(--brand);
}

/* ================= NAV ACTIONS (Login/Signup) ================= */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    border-left: 2px solid var(--border);
    padding-left: 15px;
    margin-left: 10px;
}

.login-link {
    font-weight: 700;
    color: white !important;
    text-decoration: none;
    font-size: 0.9rem;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    padding: 10px 25px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
    transition: 0.3s;
}
.login-link:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4); filter: brightness(1.1); }

/* Dropdown Menu Styles */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--surface);
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    border-radius: 12px;
    z-index: 1001;
    top: 100%;
    left: 0;
    border: 1px solid var(--border);
    padding: 8px 0;
}

.nav-dropdown-content a {
    color: var(--text) !important;
    padding: 12px 20px !important;
    text-decoration: none !important;
    display: block !important;
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    border-bottom: none !important;
    transition: background 0.2s !important;
    border-radius: 0 !important;
    text-align: left;
}

.close-menu {
    display: none;
}

.nav-dropdown-content a:hover {
    background-color: var(--subtle) !important;
    color: var(--brand) !important;
}

.nav-dropdown:hover .nav-dropdown-content {
    display: block;
}

.dropbtn::after {
    content: ' ▾';
    font-size: 0.8rem;
    opacity: 0.7;
}

@media (max-width: 768px) {
    .nav-dropdown { width: 100%; }
    .nav-dropdown-content {
        position: static;
        display: block;
        box-shadow: none;
        border: none;
        background: var(--subtle);
        padding-left: 20px;
        border-radius: 0;
        min-width: 100%;
    }
}

.signup-btn-nav {
    background: linear-gradient(135deg, #38bdf8, #2563eb);
    color: white !important;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
    text-decoration: none;
    font-size: 0.9rem;
}

/* ================= TABS NAVIGATION (For Chapterwise/Leaderboard) ================= */
.tabs-nav {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0 40px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
    flex-wrap: wrap;
}

.tab-item {
    padding: 12px 24px;
    font-weight: 700;
    text-decoration: none;
    color: var(--muted);
    transition: all 0.3s ease;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.tab-item:hover {
    color: var(--brand);
}

.tab-item.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    background: rgba(79, 70, 229, 0.05);
}

@media (max-width: 768px) {
    nav {
        padding: 0 12px !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        position: sticky;
        top: 0;
        z-index: 1000;
        min-height: 60px !important; /* Increased from 50px to better contain navigation items */
    }
    .brand {
        font-size: 0.9rem !important;
        margin-left: 0 !important; /* Removed to give more horizontal space to the brand */
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis; /* Prevents pushing buttons off-screen */
    }
    .nav-important a {
        background: var(--brand) !important;
        color: white !important;
        display: inline-block;
    }
    .menu-toggle {
        display: flex;
        padding: 10px 4px;
        margin-right: 0;
        order: -1; /* Ensures it stays on the far left */
        flex-shrink: 0;
    }
    .nav-links {
        display: flex;
        position: fixed;
        top: 0;
        right: 0;
        transform: translateX(100%);
        height: 100vh;
        width: 280px;
        background: var(--surface);
        flex-direction: column;
        padding: 80px 25px 30px;
        box-shadow: -10px 0 30px rgba(0,0,0,0.15);
        z-index: 1000;
        align-items: flex-start;
        justify-content: flex-start;
        margin: 0;
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s, visibility 0.4s;
    }
    .nav-links.active {
        transform: translateX(0);
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
    }
    .close-menu {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 20px;
        right: 20px;
        background: rgba(0,0,0,0.05);
        border: none;
        font-size: 28px;
        color: var(--text);
        cursor: pointer;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        transition: 0.3s;
        padding: 0;
    }
    .close-menu:hover {
        background: rgba(239, 68, 68, 0.1);
        color: var(--danger);
    }
    /* Hide links that are already visible on the main screen */
    .nav-links a[href="about.html"], 
    .nav-links .login-link,
    .nav-links a[href="index.html"] { /* Hide Home if it's in nav-important */
        display: none !important;
    }
    .nav-links a {
        width: 100%;
        padding: 15px 0;
        border-bottom: 1px solid var(--border);
        font-size: 0.9rem;
        text-align: left;
    }
    .nav-actions {
        border: none;
        padding: 0;
        margin: 20px 0 0 0;
        gap: 15px;
        flex-direction: column;
        align-items: flex-start;
    }
    .tabs-nav {
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding: 0 15px;
        scrollbar-width: none;
        margin: 15px 0 25px;
    }
    .tab-item {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    /* Hide the floating desktop timer on mobile devices */
    .desktop-timer {
        display: none !important;
    }
    .tabs-nav::-webkit-scrollbar { display: none; }
}

/* Content is visible by default for immediate loading */
#main-app-container {
    display: block !important;
}


/* ================= DASHBOARD ENHANCEMENT ================= */

select {
    padding: 12px 15px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    font-weight: 500;
    color: #1e293b;
}

/* ===== FIXED DASHBOARD LAYOUT ===== */

.dashboard-wrapper {
    max-width: 1100px;
    margin: 100px auto 50px auto;
    text-align: center;
}

.dashboard-wrapper h1 {
    font-size: 32px;
    margin-bottom: 10px;
    color: #1e293b;
}

.dashboard-wrapper p {
    color: #64748b;
    margin-bottom: 20px;
}

.dashboard-wrapper select {
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 40px;
}

/* Horizontal Card Layout */
.card-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    margin-bottom: 40px;
}

.dashboard-card {
    width: 280px;
    padding: 30px;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 15px 40px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: 0.3s ease;
    color: #1e293b;
    border: 1px solid rgba(0,0,0,0.07);
}

.dashboard-card:hover {
    transform: translateY(-8px);
    border-color: #3b82f6;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
}

.dashboard-card h3 {
    margin-bottom: 10px;
    color: #1e293b;
}

.leaderboard-btn {
    background: #3b82f6;
    color: #ffffff;
    padding: 12px 25px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}

.leaderboard-btn:hover {
    background: #2563eb;
}

/* Visibility helpers for different designs */
@media (min-width: 769px) {
    .mobile-only { display: none !important; }
}
@media (max-width: 768px) {
    .desktop-only { display: none !important; }
}

/* ================= MODAL / POPUP STYLES ================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: var(--surface);
    width: 100%;
    max-width: 500px;
    border-radius: 24px;
    padding: 35px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    position: relative;
    animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    margin-bottom: 20px;
    text-align: center;
}

.modal-header h2 {
    color: var(--brand);
    font-size: 1.5rem;
    font-weight: 800;
}

.quiz-details {
    background: var(--subtle);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.quiz-rules {
    margin-bottom: 25px;
}

.quiz-rules ul {
    list-style: none;
    padding-left: 0;
}

.quiz-rules li {
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--muted);
}
