/* =========================================
   1. GENERAL BASICS & VARIABLES
   ========================================= */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #64748b;
    --success: #10b981;
    --success-dark: #059669;
    --danger: #ef4444;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding-top: 56px; /* Header height + space */
    height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* --- CRITICAL: TEST MODE OVERRIDES --- */
/* Isolates Test Interface from the main site scrolling behavior */
body.test-mode {
    padding-top: 0 !important;
    overflow: hidden !important;
    background: #fff;
    position: fixed;
    width: 100%;
    height: 100dvh;
}

* { box-sizing: border-box; }
a { text-decoration: none; color: var(--primary); transition: 0.2s; }
a:hover { color: var(--primary-dark); }
ul { list-style: none; padding: 0; margin: 0; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-gray { color: var(--text-light); }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.w-100 { width: 100%; }
.d-block { display: block; }
.fade-in { animation: fadeIn 0.3s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   2. HEADER (Global Dashboard)
   ========================================= */
.main-header {
    height: 56px;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
}

.main-header .container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.logo {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
    letter-spacing: -0.5px;
}

.nav-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background-color: transparent;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background-color: #eef2ff;
    color: var(--primary);
    border-color: #c7d2fe;
}

/* =========================================
   3. BUTTONS & FORMS (Modernized)
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-lg { padding: 0.85rem 1.5rem; width: 100%; font-size: 1rem; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; width: auto; }
.btn-xs { padding: 0.25rem 0.6rem; font-size: 0.75rem; width: auto; }

.btn-primary { background-color: var(--primary); color: white; box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2); }
.btn-primary:hover:not(:disabled) { background-color: var(--primary-dark); transform: translateY(-1px); }

.btn-secondary { background-color: var(--border); color: var(--text-main); }
.btn-secondary:hover:not(:disabled) { background-color: #cbd5e1; }

.btn-success { background-color: var(--success); color: white; box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2); }
.btn-success:hover:not(:disabled) { background-color: var(--success-dark); transform: translateY(-1px); }

/* Modern Input Styles */
.modern-input, .modern-select, .form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    background: #f8fafc;
    transition: all 0.2s;
    color: var(--text-main);
}
.modern-input:focus, .modern-select:focus, .form-input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.icon-btn {
    background: none; border: none; cursor: pointer; 
    padding: 8px; color: var(--text-main); display: flex; 
    align-items: center; justify-content: center;
}
.icon-btn:hover { background-color: #f1f5f9; border-radius: 50%; }

/* =========================================
   4. NEW INDEX PAGE STYLES (Hero & Grid)
   ========================================= */

/* Hero Section (Rank Calculator) */
.rank-hero-section {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    padding: 4rem 1rem;
    color: white;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: #ffffff;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: #e0e7ff;
    margin-bottom: 2rem;
    max-width: 600px;
}

.rank-input-wrapper {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    .rank-input-wrapper { flex-direction: row; align-items: flex-end; }
    .hero-input-group { flex: 1; }
    .hero-select-group { flex: 0 0 180px; }
    .hero-btn-group { flex: 0 0 160px; }
}

.hero-label {
    display: block;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

/* Exam List Section */
.exam-section {
    padding: 3rem 0 5rem;
    background-color: var(--bg-body);
}

.section-heading {
    text-align: center;
    margin-bottom: 2.5rem;
}
.section-heading h2 { font-size: 2rem; font-weight: 800; color: var(--text-main); margin: 0; }
.section-heading p { color: var(--text-light); margin-top: 0.5rem; }

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.category-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: #cbd5e1;
}

.cat-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(to right, #fff, #f8fafc);
}

.cat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    flex-shrink: 0;
}

.cat-info h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
}

.cat-meta {
    padding: 0.75rem 1.25rem;
    background: #fff;
    color: var(--text-light);
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.test-count {
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 6px;
    color: var(--text-main);
}

/* Shift Dropdown Inside Card */
.shift-list-wrapper {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    background: #f8fafc;
}

.category-card.active .shift-list-wrapper {
    max-height: 250px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}

.shift-item {
    padding: 10px 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    background: #fff;
}
.shift-item:last-child { border-bottom: none; }
.shift-item:hover { background: #f1f5f9; }

.shift-date { font-weight: 600; color: var(--text-main); display: block; }
.shift-time { font-size: 0.75rem; color: var(--text-light); }

/* Auth Box */
.auth-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    margin: 0 auto;
    box-shadow: var(--shadow-md);
    text-align: center;
}

/* =========================================
   5. TEST INTERFACE LAYOUT (Desktop Default)
   ========================================= */

/* The Main Container for Test Page */
#test-page-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
}

/* Intro Cards (Centered) */
#personal-intro, #mock-intro, #results-section {
    background: #fff;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    max-width: 600px;
    margin: 4rem auto;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

/* Wrapper for the actual quiz interface */
#quiz-section {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.quiz-top-bar {
    height: 50px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    flex-shrink: 0;
}
.quiz-header-left, .quiz-header-right { display: flex; align-items: center; gap: 10px; }
.exam-title { font-weight: 700; color: var(--text-main); font-size: 1.1rem; }

/* Desktop: Side by Side Layout */
.quiz-wrapper {
    display: flex;
    flex-direction: row; 
    flex: 1; /* Take remaining height */
    overflow: hidden;
    position: relative;
    background: #fff;
}

/* LEFT: Question Area */
.quiz-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    overflow: hidden;
    min-width: 0;
}

/* Section Tabs */
.section-bar {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    overflow-x: auto;
    white-space: nowrap;
    flex-shrink: 0;
}
.section-tabs { display: flex; gap: 0.5rem; }
.section-tab {
    padding: 0.4rem 1rem; background: #fff; border: 1px solid var(--border);
    border-radius: 20px; font-size: 0.85rem; color: var(--text-light); cursor: pointer;
}
.section-tab:hover { border-color: var(--primary); color: var(--primary); }
.section-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Question Scroll Area */
.question-card {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}
.q-header {
    margin-bottom: 1.5rem; padding-bottom: 0.5rem; border-bottom: 1px solid #f1f5f9;
    display: flex; justify-content: space-between; align-items: center;
}
.q-body { font-size: 1.15rem; line-height: 1.6; color: var(--text-main); margin-bottom: 1.5rem; }
.q-body img { max-width: 100%; height: auto; }

.option-container label {
    display: flex; align-items: flex-start; padding: 1rem;
    border: 1px solid var(--border); border-radius: 8px; cursor: pointer; margin-top: 0.75rem;
    transition: background 0.2s;
}
.option-container label:hover { background: #f8fafc; }
.option-container input { margin-top: 4px; margin-right: 12px; }

/* --- HIDE STATUS ICONS (Tick/Cross) INSIDE OPTIONS --- */
.option-container label img[src*="tick"],
.option-container label img[src*="Tick"],
.option-container label img[src*="check"],
.option-container label img[src*="Check"],
.option-container label img[src*="correct"],
.option-container label img[src*="Correct"],
.option-container label img[src*="right"],
.option-container label img[src*="Right"],
.option-container label img[src*="cross"],
.option-container label img[src*="Cross"],
.option-container label img[src*="wrong"],
.option-container label img[src*="Wrong"],
.option-container label img[src*="cancel"],
.option-container label img[src*="Cancel"],
.option-container label img[src*="incorrect"],
.option-container label img[src*="false"],
.option-container label img[src*="error"] {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    position: absolute !important;
}

/* Navigation Buttons */
.navigation-buttons {
    padding: 1rem 2rem; border-top: 1px solid var(--border); background: #fff;
    display: flex; justify-content: space-between; flex-shrink: 0; gap: 1rem; z-index: 10;
}

/* RIGHT: Palette Sidebar */
.quiz-sidebar {
    width: 300px; background: #fff; display: flex; flex-direction: column;
    flex-shrink: 0; border-left: 1px solid var(--border);
}
.sidebar-header { padding: 1rem; border-bottom: 1px solid var(--border); }
.palette-legend { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--text-light); }
.palette-scroll-area { flex: 1; overflow-y: auto; padding: 1rem; }
.palette-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.palette-btn {
    padding: 8px 0; text-align: center; border: 1px solid var(--border);
    border-radius: 4px; background: #fff; cursor: pointer;
}
.palette-btn.active { border: 2px solid var(--primary); font-weight: 600; }
.palette-btn.answered { background: var(--success); color: #fff; border-color: var(--success); }

/* Utilities */
.mobile-only { display: none !important; }
.desktop-only { display: inline-block; }
.drawer-header { display: none; }
.mobile-backdrop { display: none; }

/* =========================================
   6. MOBILE RESPONSIVENESS (< 992px)
   ========================================= */
@media (max-width: 992px) {
    .mobile-only { display: inline-flex !important; }
    .desktop-only { display: none !important; }

    /* RESET LAYOUT FOR MOBILE APP FEEL */
    body.test-mode {
        height: 100dvh;
        width: 100%;
        position: fixed;
    }

    #test-page-container { height: 100%; }
    .quiz-top-bar { padding: 0 10px; }

    /* Stack Vertically */
    .quiz-wrapper { flex-direction: column; height: 100%; width: 100%; }

    /* Question Area */
    .quiz-main { width: 100%; height: 100%; border: none; }

    /* SCROLLABLE CARD FIX */
    .question-card {
        padding: 1rem;
        /* MASSIVE PADDING: Ensures last option clears the fixed buttons */
        padding-bottom: 250px !important; 
        -webkit-overflow-scrolling: touch;
    }

    /* FIXED BOTTOM NAVIGATION */
    .navigation-buttons {
        position: fixed; bottom: 0; left: 0; right: 0;
        padding: 12px 15px;
        /* iOS Safe Area */
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
        z-index: 100;
    }
    .navigation-buttons .btn { padding: 10px; font-size: 0.9rem; flex: 1; }

    /* SIDEBAR AS DRAWER (Right) */
    .quiz-sidebar {
        position: fixed; top: 50px; right: 0; bottom: 0;
        width: 85%; max-width: 300px; z-index: 2000;
        transform: translateX(100%); transition: transform 0.25s ease;
        box-shadow: -5px 0 25px rgba(0,0,0,0.15); border-left: 1px solid #eee;
    }
    .quiz-sidebar.open { transform: translateX(0); }

    /* SECTIONS AS DRAWER (Left) */
    .section-bar {
        position: fixed; top: 50px; left: 0; bottom: 0;
        width: 80%; max-width: 280px; z-index: 2000;
        transform: translateX(-100%); transition: transform 0.25s ease;
        box-shadow: 5px 0 25px rgba(0,0,0,0.15);
        display: flex !important; flex-direction: column; padding: 0;
        background: #fff;
    }
    .section-bar.open { transform: translateX(0); }
    
    .drawer-header {
        display: flex; justify-content: space-between; align-items: center;
        padding: 1rem; border-bottom: 1px solid #eee; background: #f8fafc;
    }
    .drawer-header h4 { margin: 0; font-size: 1rem; }

    .section-tabs { flex-direction: column; padding: 1rem; width: 100%; overflow-y: auto; padding-bottom: 50px; }
    .section-tab { text-align: left; padding: 0.8rem; margin-bottom: 0.5rem; }

    /* BACKDROP */
    .mobile-backdrop {
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.5); z-index: 1900;
    }
    .mobile-backdrop.show { display: block; }
    
    /* Intro Cards Mobile Sizing */
    #personal-intro, #mock-intro, #results-section {
        width: 95%; max-height: 80dvh; padding-bottom: 50px;
    }
}

/* =========================================
   7. LOADERS & MISC
   ========================================= */
#loader, .loader-sm {
    border: 4px solid #f3f3f3; border-top: 4px solid var(--primary);
    border-radius: 50%; width: 40px; height: 40px;
    animation: spin 1s linear infinite; margin: 0 auto;
}
.loader-sm { width: 24px; height: 24px; border-width: 3px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.error-text { color: var(--danger); font-size: 0.9rem; margin-top: 0.5rem; text-align: center; }


/* =========================================
   8. RESULT DASHBOARD STYLES
   ========================================= */
.result-container {
    max-width: 1000px;
    margin: 0 auto;
    padding-bottom: 50px;
}

.result-header-card {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 2rem;
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3);
}

.score-big { font-size: 3rem; font-weight: 800; line-height: 1; }
.score-label { opacity: 0.9; font-size: 0.9rem; letter-spacing: 0.5px; text-transform: uppercase; }

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-value { font-size: 1.5rem; font-weight: 700; color: #1e293b; }
.stat-title { font-size: 0.85rem; color: #64748b; margin-top: 5px; }

.section-table-wrapper {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    margin-bottom: 2rem;
}

.analysis-table {
    width: 100%;
    border-collapse: collapse;
}

.analysis-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    text-align: left;
    padding: 1rem;
    font-size: 0.85rem;
    border-bottom: 1px solid #e2e8f0;
}

.analysis-table td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-size: 0.9rem;
}

.analysis-table tr:last-child td { border-bottom: none; }

.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }

/* Rank Highlight */
.rank-box {
    background: rgba(255,255,255,0.1);
    padding: 10px;
    border-radius: 8px;
    margin-top: 15px;
    display: inline-block;
    min-width: 120px;
}

/* =========================================
   9. ADVERTISEMENT STYLES
   ========================================= */
.ad-container {
    display: block;
    text-align: center;
    margin: 20px auto;
    width: 100%;
    min-height: 90px; /* Prevents layout shift */
    overflow: hidden;
    max-width: 100%;
}

.ad-label {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    display: block;
}

/* Mobile specific spacing */
@media (max-width: 768px) {
    .ad-container { margin: 15px auto; }
}

/* --- SEO CONTENT (New) --- */
.seo-section {
    background: #fff; border-top: 1px solid #e2e8f0; padding: 4rem 1rem; margin-top: 4rem;
}
.seo-container { max-width: 1000px; margin: 0 auto; }
.seo-container h2 { color: #1e293b; margin-bottom: 1rem; font-size: 1.5rem; }
.seo-container h3 { color: #334155; margin-top: 1.5rem; margin-bottom: 0.5rem; font-size: 1.2rem; }
.seo-container p { color: #64748b; line-height: 1.7; margin-bottom: 1rem; }
.seo-container ul { list-style: disc; padding-left: 1.5rem; color: #64748b; margin-bottom: 1rem; }


/* --- SCROLL FIX FOR FIXED HEADER --- */
html {
    scroll-behavior: smooth;
}

#mock-test-section {
    scroll-margin-top: 80px; /* 50px Header + 30px Buffer */
}