/* ==============================================================================
   EXAM PORTAL - RESPONSIVE DESIGN SYSTEM (DESKTOP, TABLET & MOBILE)
   ============================================================================== */

:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --primary-gradient: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    --secondary: #0EA5E9;
    --success: #10B981;
    --success-light: #ECFDF5;
    --warning: #F59E0B;
    --danger: #EF4444;
    --dark: #0F172A;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --bg-page: #F8FAFC;
    --bg-surface: #FFFFFF;
    --border-color: #E2E8F0;
    --border-focus: #818CF8;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --sidebar-width: 260px;
    --rail-width: 80px;
    --bottom-nav-height: 64px;
    --top-header-height: 68px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-hover);
}

/* ==============================================================================
   LAYOUT SYSTEM: DESKTOP (Sidebar), TABLET (Rail), MOBILE (Bottom Nav)
   ============================================================================== */

/* Wrapper */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: var(--bg-page);
}

.content-body {
    padding: 24px;
    flex: 1;
}

/* 1. DESKTOP LAYOUT (>= 1024px) */
@media (min-width: 1024px) {
    .desktop-sidebar {
        width: var(--sidebar-width);
        background: #FFFFFF;
        border-right: 1px solid var(--border-color);
        display: flex;
        flex-direction: column;
        position: sticky;
        top: 0;
        height: 100vh;
        z-index: 100;
    }

    .tablet-rail {
        display: none !important;
    }

    .mobile-bottom-nav {
        display: none !important;
    }

    .mobile-header-bar {
        display: none !important;
    }

    .desktop-header-bar {
        display: flex !important;
    }
}

/* 2. TABLET LAYOUT (768px to 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .desktop-sidebar {
        display: none !important;
    }

    .tablet-rail {
        width: var(--rail-width);
        background: #FFFFFF;
        border-right: 1px solid var(--border-color);
        display: flex;
        flex-direction: column;
        align-items: center;
        position: sticky;
        top: 0;
        height: 100vh;
        z-index: 100;
        padding-top: 16px;
    }

    .mobile-bottom-nav {
        display: none !important;
    }

    .mobile-header-bar {
        display: none !important;
    }

    .desktop-header-bar {
        display: flex !important;
    }

    .content-body {
        padding: 20px;
    }
}

/* 3. MOBILE LAYOUT (< 768px) */
@media (max-width: 767px) {
    .desktop-sidebar {
        display: none !important;
    }

    .tablet-rail {
        display: none !important;
    }

    .desktop-header-bar {
        display: none !important;
    }

    .mobile-header-bar {
        display: flex !important;
        position: sticky;
        top: 0;
        background: #FFFFFF;
        border-bottom: 1px solid var(--border-color);
        padding: 12px 16px;
        z-index: 99;
        justify-content: space-between;
        align-items: center;
    }

    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: var(--bottom-nav-height);
        background: #FFFFFF;
        border-top: 1px solid var(--border-color);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
    }

    .content-body {
        padding: 16px;
        padding-bottom: calc(var(--bottom-nav-height) + 24px); /* Extra space for bottom bar */
    }
}

/* ==============================================================================
   SIDEBAR & NAVIGATION STYLES
   ============================================================================== */
.sidebar-brand {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 18px;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.brand-text h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
    line-height: 1.2;
}

.brand-text span {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 12px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
    transition: all 0.15s ease;
}

.nav-item:hover {
    color: var(--primary);
    background-color: var(--primary-light);
}

.nav-item.active {
    color: #FFFFFF;
    background: var(--primary-gradient);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.nav-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background-color: rgba(255, 255, 255, 0.25);
}

/* Tablet Rail Item */
.rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 6px;
    margin-bottom: 8px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    width: 64px;
}

.rail-item i {
    font-size: 18px;
    margin-bottom: 4px;
}

.rail-item.active {
    color: var(--primary);
    background-color: var(--primary-light);
}

/* Mobile Bottom Navigation Bar */
.bottom-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    flex: 1;
    height: 100%;
    position: relative;
}

.bottom-nav-link i {
    font-size: 20px;
    margin-bottom: 2px;
}

.bottom-nav-link.active {
    color: var(--primary);
    font-weight: 700;
}

.bottom-nav-link.active::after {
    content: '';
    position: absolute;
    top: 4px;
    width: 32px;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
}

/* ==============================================================================
   HEADER BARS
   ============================================================================== */
.desktop-header-bar {
    height: var(--top-header-height);
    background: #FFFFFF;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-search {
    display: flex;
    align-items: center;
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 8px 16px;
    width: 320px;
}

.header-search input {
    border: none;
    background: transparent;
    outline: none;
    margin-left: 8px;
    font-size: 13.5px;
    width: 100%;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.coin-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #FEF3C7;
    border: 1px solid #FCD34D;
    color: #92400E;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 13px;
}

/* ==============================================================================
   COMPONENTS: CARDS, BUTTONS, BADGES, HERO
   ============================================================================== */

/* Hero Banner */
.hero-card {
    background: var(--primary-gradient);
    border-radius: var(--radius-lg);
    padding: 32px;
    color: #FFFFFF;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.hero-card::after {
    content: '';
    position: absolute;
    right: -20px;
    bottom: -20px;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.hero-card h1 {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 8px;
}

.hero-card p {
    font-size: 14.5px;
    opacity: 0.9;
    max-width: 600px;
    margin-bottom: 20px;
}

/* Card Grids */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

@media (min-width: 1200px) {
    .grid-cards-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Modern Card */
.card-item {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
}

.card-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-focus);
}

.card-thumb {
    width: 100%;
    height: 160px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    margin-bottom: 14px;
    background-color: #E2E8F0;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
    line-height: 1.3;
}

.card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    flex: 1;
}

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 12.5px;
    color: var(--text-muted);
}

.card-price {
    font-size: 17px;
    font-weight: 800;
    color: var(--primary);
}

/* Badges */
.badge-free {
    background-color: var(--success-light);
    color: var(--success);
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
}

.badge-live {
    background-color: #FEE2E2;
    color: #DC2626;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-live::before {
    content: '';
    width: 6px;
    height: 6px;
    background-color: #DC2626;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

/* Buttons */
.btn-primary {
    background: var(--primary-gradient);
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.15s ease;
}

.btn-primary:hover {
    opacity: 0.95;
    color: #FFFFFF;
}

.btn-secondary {
    background: #FFFFFF;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 18px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background-color: var(--bg-page);
    border-color: var(--text-muted);
}

.btn-block {
    width: 100%;
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: #FFFFFF;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ==============================================================================
   INTERACTIVE EXAM ENVIRONMENT (DESKTOP & MOBILE ADAPTIVE)
   ============================================================================== */
.exam-header {
    background: #FFFFFF;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.exam-timer {
    background: #FEF2F2;
    border: 1px solid #FCA5A5;
    color: #DC2626;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.exam-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    padding: 20px;
}

@media (max-width: 900px) {
    .exam-layout {
        grid-template-columns: 1fr;
    }
}

.question-box {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
}

.question-palette {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 14px;
}

.palette-btn {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-page);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.palette-btn.current {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

.palette-btn.answered {
    background-color: #10B981;
    color: #FFFFFF;
    border-color: #10B981;
}

.palette-btn.marked {
    background-color: #7C3AED;
    color: #FFFFFF;
    border-color: #7C3AED;
}

.palette-btn.unanswered {
    background-color: #EF4444;
    color: #FFFFFF;
    border-color: #EF4444;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.option-item:hover {
    background-color: var(--primary-light);
    border-color: var(--primary);
}

.option-item.selected {
    background-color: var(--primary-light);
    border-color: var(--primary);
    font-weight: 600;
    color: var(--primary);
}

.option-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #E2E8F0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

.option-item.selected .option-badge {
    background: var(--primary);
    color: #FFFFFF;
}

/* Offline Banner */
.sync-pill {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: #DCFCE7;
    color: #166534;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.hover-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hover-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md) !important;
}

.shadow-xs {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.cursor-pointer {
    cursor: pointer;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* CBT Modern Exam & Quiz Layout */
.timer-badge {
    background: #fef2f2;
    border: 2px solid #f87171;
    color: #b91c1c;
    padding: 6px 16px;
    border-radius: 99px;
    font-weight: 800;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.15);
}

.timer-badge.warning-pulse {
    animation: pulseTimer 1s infinite alternate;
    background: #dc2626 !important;
    color: #ffffff !important;
    border-color: #991b1b !important;
}

@keyframes pulseTimer {
    from { transform: scale(1); opacity: 1; }
    to { transform: scale(1.05); opacity: 0.85; }
}

.exam-progress {
    height: 5px;
    background: #e2e8f0;
}

.exam-progress-bar {
    background: linear-gradient(90deg, #4338ca, #06b6d4);
    height: 100%;
    transition: width 0.3s ease;
}

/* Print Styles for Scorecards & Certificates */
@media print {
    .desktop-sidebar, .mobile-bottom-nav, .mobile-top-bar, .btn, header, footer {
        display: none !important;
    }
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    .card-item {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}

