/* ========================================================
   Exam Management System - Core Design System & Styles
   ======================================================== */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-dark: #1e40af;
    
    --secondary: #64748b;
    --secondary-light: #f8fafc;
    
    --success: #10b981;
    --success-light: #ecfdf5;
    
    --danger: #ef4444;
    --danger-light: #fef2f2;
    
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    
    --info: #06b6d4;
    --info-light: #ecfeff;
    
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-light: #f8fafc;
    
    --border: #e2e8f0;
    --border-focus: #3b82f6;
    
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
    
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-hindi: 'Noto Sans Devanagari', 'Inter', sans-serif;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14.5px;
    -webkit-font-smoothing: antialiased;
}

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

/* Layout Hierarchy */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    transition: transform 0.25s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
}
.brand-logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,0.4);
}
.brand-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    display: block;
    line-height: 1.2;
}
.brand-subtitle {
    font-size: 0.72rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.25rem;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-header {
    font-size: 0.7rem;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.08em;
    padding: 0.75rem 0.75rem 0.25rem;
}

.nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 0.85rem;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.15s ease;
}

.nav-item .nav-link i {
    font-size: 1.15rem;
}

.nav-item:hover .nav-link {
    background-color: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-item.active .nav-link {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.institute-card {
    background: rgba(255,255,255,0.05);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
}
.inst-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #f1f5f9;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.inst-phone {
    font-size: 0.75rem;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.15s;
}
.btn-logout:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

/* App Main Container */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin 0.25s ease;
}

/* Header */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}
.sidebar-toggle:hover {
    background-color: var(--bg-main);
}

.header-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}
.header-breadcrumb .separator {
    color: var(--text-muted);
}
.header-breadcrumb .active-page {
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--success-light);
    color: #065f46;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid #a7f3d0;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* User Dropdown */
.user-dropdown {
    position: relative;
}

.user-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    transition: background 0.15s;
}
.user-dropdown-btn:hover {
    background: var(--bg-main);
}

.avatar-circle {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid #bfdbfe;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.user-info-text {
    text-align: left;
    line-height: 1.2;
}
.user-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}
.user-role {
    font-size: 0.74rem;
    color: var(--text-muted);
}

.user-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    width: 220px;
    padding: 0.5rem 0;
    display: none;
    z-index: 1000;
}
.user-dropdown-menu.show {
    display: block;
}
.dropdown-header {
    padding: 0.5rem 1rem;
}
.dropdown-header small {
    display: block;
    color: var(--text-muted);
}
.dropdown-divider {
    height: 1px;
    background-color: var(--border);
    margin: 0.4rem 0;
}
.dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.55rem 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}
.dropdown-item:hover {
    background-color: var(--bg-main);
    color: var(--primary);
}

/* App Content */
.app-content {
    flex: 1;
    padding: 1.75rem;
}

/* Footer */
.app-footer {
    background-color: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 1rem 1.75rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Alerts */
.alert {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #ecfeff; border-color: #a5f3fc; color: #155e75; }
.btn-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.6;
}
.btn-close:hover { opacity: 1; }

/* Grid System & Cards */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.page-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
}
.page-subtitle {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-info .stat-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.stat-info .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 0.25rem;
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}
.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger { background: var(--danger-light); color: var(--danger); }
.stat-icon.info { background: var(--info-light); color: var(--info); }

/* Main Card Component */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.75rem;
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fafbfd;
}
.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}
.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background-color: #fafbfd;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

.table th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.85rem 1.2rem;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 0.95rem 1.2rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1;
}
.badge-live { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-scheduled { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.badge-completed { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.badge-draft { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-archived { background: #f3f4f6; color: #6b7280; }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-secondary { background: #f1f5f9; color: #64748b; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    text-align: center;
}
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 1.5rem; font-size: 1rem; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }

.btn-secondary { background: #f1f5f9; color: var(--text-secondary); border-color: var(--border); }
.btn-secondary:hover { background: #e2e8f0; color: var(--text-primary); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }

.btn-outline-primary { border-color: var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

.btn-outline-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}
.form-label .required {
    color: var(--danger);
}
.form-control, .form-select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: #fff;
    color: var(--text-primary);
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
textarea.form-control {
    min-height: 90px;
    resize: vertical;
}
.form-hint {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.form-col {
    flex: 1;
    min-width: 220px;
}

/* Filter Toolbar */
.toolbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}
.search-box {
    position: relative;
    max-width: 320px;
    width: 100%;
}
.search-box i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.search-box input {
    padding-left: 2.3rem;
}

/* Modal Window */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 1rem;
}
.modal-overlay.show {
    display: flex;
}
.modal-dialog {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 550px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalSlide 0.2s ease-out;
}
@keyframes modalSlide {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-header {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-body {
    padding: 1.5rem;
}
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background-color: #fafbfd;
}

/* Scorecard & Result Styling */
.scorecard-banner {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}
.scorecard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1.5rem;
}
.score-stat-circle {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: 3px solid rgba(255,255,255,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.score-stat-circle .val {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1;
}
.score-stat-circle .sub {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.85;
}

.performance-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.perf-metric-card {
    background: rgba(255,255,255,0.1);
    padding: 0.85rem;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid rgba(255,255,255,0.15);
}
.perf-metric-card .num {
    font-size: 1.35rem;
    font-weight: 700;
}
.perf-metric-card .lbl {
    font-size: 0.72rem;
    opacity: 0.85;
    text-transform: uppercase;
}

/* Question Response Review Sheet */
.question-review-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    background: #fff;
    overflow: hidden;
}
.question-review-header {
    padding: 0.75rem 1.25rem;
    background-color: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.question-review-body {
    padding: 1.25rem;
}
.question-text-box {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}
.question-hindi {
    font-family: var(--font-hindi);
    color: #334155;
    font-weight: 500;
    margin-top: 0.35rem;
}
.options-review-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.option-review-item {
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.92rem;
}
.option-review-item.correct {
    background-color: #ecfdf5;
    border-color: #10b981;
    color: #065f46;
    font-weight: 600;
}
.option-review-item.user-wrong {
    background-color: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
    font-weight: 600;
}
.explanation-box {
    background-color: #f8fafc;
    border-left: 4px solid var(--primary);
    padding: 0.85rem 1rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.88rem;
}

/* Responsive Media Queries */
@media (max-width: 992px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0;
    }
}
@media (max-width: 640px) {
    .app-content {
        padding: 1rem;
    }
    .app-header {
        padding: 0 1rem;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
