/* =====================================================
   PM-SUCCESS EXAM PLATFORM - Modern Light Design
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;1,14..32,400&family=Cairo:wght@300;400;500;600;700;800&display=swap');

/* ---- Design Tokens ---- */
:root {
  /* Brand Colors */
  --primary:       #4f6ef7;
  --primary-dark:  #3b57e8;
  --primary-light: #7b92fa;
  --primary-bg:    #eef1fe;
  --primary-hover: #f0f3ff;

  --secondary:     #0ea5e9;
  --success:       #10b981;
  --success-bg:    #ecfdf5;
  --danger:        #ef4444;
  --danger-bg:     #fef2f2;
  --warning:       #f59e0b;
  --warning-bg:    #fffbeb;
  --purple:        #8b5cf6;
  --purple-bg:     #f5f3ff;

  /* Neutrals */
  --bg:            #f8f9fc;
  --surface:       #ffffff;
  --surface-2:     #f1f4f9;
  --border:        #e2e8f0;
  --border-dark:   #cbd5e1;

  /* Text */
  --text-primary:  #0f172a;
  --text-secondary:#475569;
  --text-muted:    #94a3b8;
  --text-inverse:  #ffffff;

  /* Layout */
  --sidebar-w:           270px;
  --sidebar-w-collapsed: 78px;
  --topbar-h:            68px;
  --radius-xs:     6px;
  --radius-sm:     10px;
  --radius-md:     14px;
  --radius-lg:     20px;
  --radius-xl:     28px;
  --radius-full:   9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15,23,42,0.06);
  --shadow-sm: 0 1px 4px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.08), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg: 0 8px 24px rgba(15,23,42,0.10), 0 3px 6px rgba(15,23,42,0.05);
  --shadow-xl: 0 20px 48px rgba(15,23,42,0.12), 0 8px 16px rgba(15,23,42,0.06);
  --shadow-primary: 0 4px 16px rgba(79,110,247,0.30);

  /* Transitions */
  --transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  --transition-fast: all 0.12s cubic-bezier(0.4,0,0.2,1);
  --transition-slow: all 0.35s cubic-bezier(0.4,0,0.2,1);

  /* Typography */
  --font: 'Inter', sans-serif;
  --font-ar: 'Cairo', sans-serif;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
[lang="ar"], [dir="rtl"] { font-family: var(--font-ar); }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; }
input, select, textarea { font-family: inherit; }

/* =====================================================
   LAYOUT — Sidebar + Content
   ===================================================== */
.admin-wrapper, .student-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- Unified Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

[dir="rtl"] .sidebar { left: auto; right: 0; border-right: none; border-left: 1px solid var(--border); }

.sidebar-logo {
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 68px;
}

.sidebar-logo .logo-full {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.sidebar-logo .logo-compact {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: var(--shadow-primary);
  text-decoration: none;
  margin: 0 auto;
}

.sidebar-collapse-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 0.82rem;
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary-light);
}

.sidebar-user-box {
  margin: 12px 12px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: var(--transition-fast);
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 16px 6px;
  transition: opacity 0.2s;
}

.sidebar-nav { padding: 6px 10px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 3px;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
}
.nav-item:hover {
  background: var(--primary-hover);
  color: var(--primary);
  text-decoration: none;
}
.nav-item.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}
.nav-item .nav-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: var(--transition-fast);
}
.nav-item.active .nav-icon { background: var(--primary); color: #fff; }
.nav-item:not(.active) .nav-icon { background: var(--surface-2); color: var(--text-secondary); }
.nav-item:hover:not(.active) .nav-icon { background: var(--primary-bg); color: var(--primary); }

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ---- Collapsed Sidebar Rules (Desktop) ---- */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-w-collapsed) !important;
  overflow: visible !important;
}
body.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-w-collapsed);
}
[dir="rtl"] body.sidebar-collapsed .main-content {
  margin-left: 0;
  margin-right: var(--sidebar-w-collapsed);
}

body.sidebar-collapsed .sidebar-logo {
  justify-content: center;
  padding: 14px 6px;
}
body.sidebar-collapsed .sidebar-logo .logo-full {
  display: none !important;
}
body.sidebar-collapsed .sidebar-logo .logo-compact {
  display: flex !important;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
}
body.sidebar-collapsed .sidebar-logo .logo-compact:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}
body.sidebar-collapsed .sidebar-collapse-btn {
  display: none !important;
}

body.sidebar-collapsed .sidebar-user-box {
  padding: 8px 4px !important;
  margin: 8px auto !important;
  justify-content: center !important;
  background: transparent !important;
  border-color: transparent !important;
  width: 48px !important;
}
body.sidebar-collapsed .sidebar-user-details,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .nav-item .nav-label,
body.sidebar-collapsed .nav-item .badge,
body.sidebar-collapsed .sidebar-group-info,
body.sidebar-collapsed .sidebar-footer-collapse-hide {
  display: none !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  overflow: hidden !important;
}

body.sidebar-collapsed .sidebar-nav {
  padding: 8px 6px !important;
  overflow: visible !important;
}

body.sidebar-collapsed .nav-item {
  justify-content: center !important;
  padding: 0 !important;
  width: 48px !important;
  height: 44px !important;
  margin: 4px auto !important;
  border-radius: var(--radius-sm) !important;
  font-size: 0 !important; /* Completely hides any raw/orphan text nodes */
  color: transparent !important;
  white-space: nowrap !important;
  position: relative !important;
  overflow: visible !important;
}

body.sidebar-collapsed .nav-item .nav-icon {
  margin: 0 !important;
  width: 38px !important;
  height: 38px !important;
  font-size: 1rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
}

body.sidebar-collapsed .nav-item > *:not(.nav-icon) {
  display: none !important;
}

/* Floating Tooltip in Collapsed Mode */
body.sidebar-collapsed .nav-item[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #f8fafc;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35), 0 8px 10px -6px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  letter-spacing: normal;
  line-height: 1.4;
  animation: tooltipFadeIn 0.15s ease-out;
}

body.sidebar-collapsed .nav-item[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  border-width: 5px 6px 5px 0;
  border-style: solid;
  border-color: transparent #0f172a transparent transparent;
  z-index: 9999;
  pointer-events: none;
  animation: tooltipFadeIn 0.15s ease-out;
}

[dir="rtl"] body.sidebar-collapsed .nav-item[data-tooltip]:hover::after {
  left: auto;
  right: calc(100% + 14px);
}
[dir="rtl"] body.sidebar-collapsed .nav-item[data-tooltip]:hover::before {
  left: auto;
  right: calc(100% + 8px);
  border-width: 5px 0 5px 6px;
  border-color: transparent transparent transparent #0f172a;
}

body.sidebar-collapsed .nav-item:not([data-tooltip]):hover::after,
body.sidebar-collapsed .nav-item[data-tooltip=""]:hover::after,
body.sidebar-collapsed .nav-item:not([data-tooltip]):hover::before,
body.sidebar-collapsed .nav-item[data-tooltip=""]:hover::before {
  display: none !important;
}

@keyframes tooltipFadeIn {
  from { opacity: 0; transform: translateY(-50%) scale(0.92); }
  to { opacity: 1; transform: translateY(-50%) scale(1); }
}

body.sidebar-collapsed .sidebar-footer {
  padding: 10px 4px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Mobile backdrop */
.sidebar-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 95;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1), margin-right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
[dir="rtl"] .main-content { margin-left: 0; margin-right: var(--sidebar-w); }

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-xs);
}
  position: sticky; top: 0; z-index: 50;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.topbar-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.lang-switcher {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-full);
  padding: 4px;
}
.lang-switcher a {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}
.lang-switcher a.active, .lang-switcher a:hover {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* ---- Page Content ---- */
.page-content {
  padding: 28px;
  flex: 1;
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* =====================================================
   STAT CARDS (Dashboard)
   ===================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-icon.blue  { background: #eff6ff; color: #3b82f6; }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.purple{ background: var(--purple-bg); color: var(--purple); }
.stat-icon.orange{ background: var(--warning-bg); color: var(--warning); }
.stat-icon.red   { background: var(--danger-bg); color: var(--danger); }
.stat-icon.cyan  { background: #ecfeff; color: var(--secondary); }

.stat-info .stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}
.stat-info .stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
}
.stat-trend {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 4px;
}
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* =====================================================
   GRID LAYOUTS
   ===================================================== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 900px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  border: 1.5px solid transparent;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 20px rgba(79,110,247,0.40);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}
.btn-secondary:hover { background: #0284c7; transform: translateY(-1px); }

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

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

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-dark);
}
.btn-outline:hover {
  background: var(--surface-2);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }
.btn-icon.btn-sm { padding: 6px; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* =====================================================
   FORMS
   ===================================================== */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.form-label span.required { color: var(--danger); margin-left: 3px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,110,247,0.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:hover:not(:focus) { border-color: var(--border-dark); }

select.form-control { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 5px;
}
.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Input Group */
.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* =====================================================
   TABLES
   ===================================================== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--surface-2);
}
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
[dir="rtl"] thead th { text-align: right; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--transition-fast);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--primary-hover); }

tbody td {
  padding: 13px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* =====================================================
   BADGES
   ===================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-muted   { background: var(--surface-2);  color: var(--text-muted); }
.badge-purple  { background: var(--purple-bg);  color: var(--purple); }
.badge-cyan    { background: #ecfeff;            color: var(--secondary); }

/* =====================================================
   ALERTS / NOTICES
   ===================================================== */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}
.alert-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: var(--primary-bg); color: #1e40af; border: 1px solid #bfdbfe; }

/* =====================================================
   MODALS
   ===================================================== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.50);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-lg { max-width: 720px; }

@keyframes modalIn {
  from { opacity:0; transform: scale(0.95) translateY(8px); }
  to   { opacity:1; transform: scale(1)    translateY(0);   }
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: none;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 0.9rem;
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-2);
}

/* =====================================================
   LOGIN PAGE
   ===================================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.login-left {
  flex: 0 0 42%;
  background: linear-gradient(145deg, #4f6ef7 0%, #7b92fa 50%, #38bdf8 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.06'%3E%3Ccircle cx='30' cy='30' r='4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-left::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
  bottom: -100px; right: -80px;
}

.login-brand {
  position: relative; z-index: 1;
  text-align: center;
  color: #fff;
}
.login-brand .brand-icon {
  width: 72px; height: 72px;
  background: rgba(255,255,255,0.2);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin: 0 auto 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.3);
}
.login-brand h1 { font-size: 1.75rem; font-weight: 800; margin-bottom: 10px; }
.login-brand p  { font-size: 0.95rem; opacity: 0.85; line-height: 1.6; }

.login-features {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative; z-index: 1;
  width: 100%;
  max-width: 300px;
}
.login-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: #fff;
  font-size: 0.84rem;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.18);
}
.login-feature i { font-size: 1rem; opacity: 0.9; }

.login-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-form-box {
  width: 100%;
  max-width: 420px;
}

.login-form-box .login-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.login-form-box .login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.login-lang-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 28px;
}

.login-error {
  padding: 12px 16px;
  background: var(--danger-bg);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  color: #991b1b;
  font-size: 0.84rem;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.password-toggle {
  position: relative;
}
.password-toggle .form-control { padding-right: 44px; }
.password-toggle .toggle-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 0.9rem; padding: 2px;
}

.login-submit {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.login-footer {
  margin-top: 32px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .login-left { display: none; }
  .login-right { padding: 24px; }
}

/* =====================================================
   EXAM ENGINE
   ===================================================== */
.exam-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.exam-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-xs);
}

.exam-title-bar {
  display: flex;
  align-items: center;
  gap: 14px;
}
.exam-title-bar h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.exam-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: var(--radius-full);
  padding: 7px 16px;
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}
.exam-timer.warning { background: var(--warning-bg); color: var(--warning); border-color: #fcd34d; }
.exam-timer.danger  { background: var(--danger-bg);  color: var(--danger);  border-color: #fca5a5; animation: pulse 1s infinite; }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.65; }
}

/* Progress Bar */
.exam-progress-bar {
  height: 3px;
  background: var(--border);
}
.exam-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.4s ease;
}

/* Exam Layout */
.exam-body {
  flex: 1;
  display: flex;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 28px 24px;
}

/* Question Navigator */
.question-navigator {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 92px;
  align-self: flex-start;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 16px;
  margin-right: 20px;
}
[dir="rtl"] .question-navigator { margin-right: 0; margin-left: 20px; }

.navigator-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

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

.nav-q {
  aspect-ratio: 1;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex; align-items: center; justify-content: center;
}
.nav-q:hover { border-color: var(--primary); color: var(--primary); }
.nav-q.answered { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.nav-q.current  { background: var(--primary); border-color: var(--primary); color: #fff; }

.navigator-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Question Area */
.question-area { flex: 1; }

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.question-number {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.question-number .q-num {
  background: var(--primary);
  color: #fff;
  width: 26px; height: 26px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
}

.question-points {
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.question-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.65;
  margin-bottom: 22px;
}

/* Answer Options */
.options-list { display: flex; flex-direction: column; gap: 10px; }

.option-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: var(--transition-fast);
  background: var(--surface);
}
.option-item:hover {
  border-color: var(--primary);
  background: var(--primary-hover);
}
.option-item.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.option-item.correct {
  border-color: var(--success);
  background: var(--success-bg);
}
.option-item.incorrect {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.option-letter {
  width: 30px; height: 30px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: var(--transition-fast);
}
.option-item.selected .option-letter {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.option-item.correct .option-letter {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.option-item.incorrect .option-letter {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.option-text { font-size: 0.9rem; color: var(--text-primary); flex: 1; }

/* Question Navigation */
.question-nav-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

/* Fill Blank */
.fill-blank-text {
  font-size: 0.95rem;
  line-height: 2.2;
  color: var(--text-primary);
}
.fill-blank-input {
  display: inline-block;
  min-width: 120px;
  border: none;
  border-bottom: 2px solid var(--primary);
  background: var(--primary-bg);
  padding: 2px 10px;
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: 600;
  border-radius: 4px 4px 0 0;
  outline: none;
}

/* True/False */
.tf-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.tf-btn {
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: var(--transition-fast);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.tf-btn:hover { border-color: var(--primary); background: var(--primary-hover); color: var(--primary); }
.tf-btn.selected-true { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.tf-btn.selected-false { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }

/* Anti-cheat overlay */
.anticheat-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.97);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  padding: 40px;
  backdrop-filter: blur(8px);
}
.anticheat-icon {
  width: 80px; height: 80px;
  background: rgba(239,68,68,0.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 20px;
  border: 2px solid rgba(239,68,68,0.4);
  animation: shake 0.5s ease;
}
@keyframes shake {
  0%,100%{transform:translateX(0)}
  25%{transform:translateX(-8px)}
  75%{transform:translateX(8px)}
}
.anticheat-overlay h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 8px; }
.anticheat-overlay p  { font-size: 0.9rem; opacity: 0.75; margin-bottom: 24px; }

/* =====================================================
   RESULTS PAGE
   ===================================================== */
.result-page {
  min-height: 100vh;
  background: var(--bg);
}

.result-hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 40px 24px;
  text-align: center;
}

.result-score-circle {
  width: 130px; height: 130px;
  border-radius: 50%;
  margin: 0 auto 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  position: relative;
  border: 6px solid var(--border);
  background: var(--surface);
}
.result-score-circle.passed { border-color: var(--success); }
.result-score-circle.failed { border-color: var(--danger); }

.result-score-circle .score-pct {
  font-size: 1.9rem;
  line-height: 1;
}
.result-score-circle.passed .score-pct { color: var(--success); }
.result-score-circle.failed .score-pct { color: var(--danger); }

.result-score-circle .score-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-top: 4px;
}

.result-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.result-exam-name {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.result-stats {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-2);
}
.result-stat {
  padding: 12px 24px;
  text-align: center;
  border-right: 1px solid var(--border);
}
.result-stat:last-child { border-right: none; }
.result-stat .r-val {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
}
.result-stat .r-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 2px;
}

.result-body {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 24px;
}

/* Review Cards */
.review-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.review-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
}
.review-card-header:hover { background: var(--surface-2); }

.review-status-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.review-status-icon.correct  { background: var(--success-bg); color: var(--success); }
.review-status-icon.incorrect{ background: var(--danger-bg);  color: var(--danger);  }

.review-q-text {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}
.review-points-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.review-card-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--border);
}

.explanation-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fffbeb;
  border-left: 3px solid var(--warning);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  font-size: 0.84rem;
  color: #78350f;
}
[dir="rtl"] .explanation-box {
  border-left: none;
  border-right: 3px solid var(--warning);
  border-radius: var(--radius-xs) 0 0 var(--radius-xs);
}

/* =====================================================
   UPLOAD / DRAG DROP
   ===================================================== */
.upload-zone {
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius-md);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--surface);
}
.upload-zone:hover, .upload-zone.dragging {
  border-color: var(--primary);
  background: var(--primary-hover);
}
.upload-zone .upload-icon { font-size: 2.5rem; color: var(--text-muted); margin-bottom: 12px; }
.upload-zone p { font-size: 0.875rem; color: var(--text-muted); }
.upload-zone strong { color: var(--primary); }

/* =====================================================
   EMPTY STATES
   ===================================================== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}
.empty-state h3 { font-size: 1rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p  { font-size: 0.875rem; margin-bottom: 20px; }

/* =====================================================
   TOAST NOTIFICATIONS
   ===================================================== */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
[dir="rtl"] #toast-container { right: auto; left: 24px; }

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  animation: toastIn 0.3s ease;
  font-size: 0.875rem;
}
@keyframes toastIn {
  from { opacity:0; transform: translateX(20px); }
  to   { opacity:1; transform: translateX(0); }
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--primary); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info    .toast-icon { color: var(--primary); }

.toast-msg { color: var(--text-primary); font-weight: 500; flex: 1; }

/* =====================================================
   UTILITIES
   ===================================================== */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.flex-gap-2  { gap: 8px; }
.flex-gap-3  { gap: 12px; }

.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

.text-muted   { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-center  { text-align: center; }
.text-sm      { font-size: 0.84rem; }
.text-xs      { font-size: 0.75rem; }
.font-bold    { font-weight: 700; }
.font-semibold{ font-weight: 600; }

.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-none { display: none; }

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* Section header */
.section-header {
  margin-bottom: 20px;
}
.section-header h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
}
.section-header p {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header h1, .page-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
}
.page-header p {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Exam warning bar */
.cheat-warning-bar {
  background: var(--warning-bg);
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.84rem;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

/* Student Dashboard exam card */
.exam-list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}
.exam-list-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
}
.exam-list-card .exam-card-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius-sm);
  background: var(--primary-bg);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.exam-list-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.exam-list-card .exam-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.exam-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Color swatch picker */
.color-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 28px; height: 28px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition-fast);
}
.color-swatch.selected, .color-swatch:hover {
  border-color: var(--text-primary);
  transform: scale(1.15);
}

/* Dropdown menu */
.dropdown { position: relative; display: inline-flex; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
  animation: dropIn 0.15s ease;
}
@keyframes dropIn {
  from { opacity:0; transform:translateY(-6px); }
  to   { opacity:1; transform:translateY(0); }
}
[dir="rtl"] .dropdown-menu { right: auto; left: 0; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 0.84rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition-fast);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  font-family: inherit;
}
.dropdown-item:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 2px;
}
.tab-item {
  padding: 8px 16px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab-item:hover { color: var(--primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Checkbox / Radio custom */
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Code block */
pre, code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.84rem;
}
pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
}

/* =====================================================
   STUDENT DASHBOARD & MODERN COMPONENTS
   ===================================================== */

/* ---- Resume Exam Hero ---- */
.resume-exam-hero {
  background: linear-gradient(135deg, #ffffff 0%, #fffbf0 60%, #fff7ed 100%);
  border: 1.5px solid #fde68a;
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 26px;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.08);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.resume-exam-hero:hover {
  box-shadow: 0 8px 30px rgba(245, 158, 11, 0.14);
  border-color: #f59e0b;
}
.resume-exam-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, #f59e0b, #ef4444);
}
[dir="rtl"] .resume-exam-hero::before {
  left: auto; right: 0;
}

/* Pulsing Badge */
.pulse-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 700;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  animation: pulseDot 1.8s infinite;
}
@keyframes pulseDot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* ---- Calendar Widget ---- */
.calendar-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.calendar-widget:hover {
  box-shadow: var(--shadow-md);
}
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.calendar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.calendar-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 0.8rem;
}
.calendar-nav-btn:hover {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary-light);
}
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 8px;
  text-align: center;
}
.calendar-weekday {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 0;
}
.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar-day {
  aspect-ratio: 1;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
  background: transparent;
  border: 1px solid transparent;
}
.calendar-day:hover:not(.empty) {
  background: var(--surface-2);
  border-color: var(--border);
}
.calendar-day.empty {
  cursor: default;
  opacity: 0.25;
}
.calendar-day.today {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 800;
  background: var(--primary-bg);
}
.calendar-day.has-activity {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}
.calendar-day.has-activity:hover {
  background: #d1fae5;
  border-color: #34d399;
}
.calendar-day-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-top: 2px;
  background: var(--primary);
}
.calendar-day-dot.passed { background: #10b981; }
.calendar-day-dot.attempted { background: #f59e0b; }

/* ---- Countdown Target Date Box ---- */
.countdown-box {
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}
.countdown-digits {
  font-size: 1.5rem;
  font-weight: 800;
  color: #4f46e5;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* ---- Readiness Gauge & Motivation Hub ---- */
.readiness-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
}
.readiness-card:hover {
  box-shadow: var(--shadow-md);
}

.weekly-challenge-box {
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 14px;
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar { 
    transform: translateX(-100%); 
    width: var(--sidebar-w) !important;
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1); 
  }
  .sidebar.open { transform: translateX(0); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  [dir="rtl"] .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; margin-right: 0 !important; }
}

@media (max-width: 640px) {
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .result-stats { flex-direction: column; }
  .question-navigator { display: none; }
  .exam-body { padding: 16px; }
}

