/* ============================================================
   Beshoy LMS — Admin Panel CSS
   Vanilla CSS with CSS Variables for maximum performance
   RTL-first, Dark mode default
   ============================================================ */

:root {
  --bg: #0a0e1a;
  --bg-surface: #111827;
  --bg-card: #1a2235;
  --bg-hover: #1e293b;
  --bg-page: #F8F9FA;
  --border: #1e293b;
  --border-light: rgba(255,255,255,0.06);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-heading: #f1f5f9;
  --primary: #7A5299;
  --primary-hover: #8F63AD;
  --primary-dark: #2C3049;
  --secondary: #6B9AC4;
  --secondary-hover: #5a89b3;
  --primary-bg: rgba(122,82,153,0.12);
  --accent-cta: #E29535;
  --accent-cta-hover: #C97F28;
  --accent-calm: #6B9AC4;
  --success: #22c55e;
  --success-bg: rgba(34,197,94,0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.4);
  --sidebar-width: 260px;
  --header-height: 64px;
  --transition: 200ms ease;
  --font-heading: 'Almarai', 'Cairo', sans-serif;
  --font-body: 'Tajawal', 'Cairo', 'IBM Plex Sans Arabic', sans-serif;
}

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

html {
  background-color: var(--bg);
  color-scheme: dark;
}
html.light-mode {
  color-scheme: light;
}
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden; /* Prevent horizontal scrolling on mobile */
  -webkit-font-smoothing: antialiased;
  background: radial-gradient(circle at 15% 50%, rgba(122,82,153,0.10), transparent 25%),
              radial-gradient(circle at 85% 30%, rgba(226,149,53,0.08), transparent 25%),
              var(--bg);
  background-attachment: fixed;
}
body::before {
  content: ''; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(circle, rgba(122, 82, 153, 0.02) 10%, transparent 20%);
  background-size: 60px 60px; pointer-events: none; z-index: 0;
}

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

/* ==================== LAYOUT ==================== */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: var(--sidebar-width);
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255,255,255,0.05);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-brand {
  padding: 24px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-brand .brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-heading);
}

.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.sidebar-nav { padding: 24px 16px; flex: 1; }

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  margin-bottom: 4px;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-link.active {
  background: var(--primary-bg);
  color: var(--primary);
}

.nav-link .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 24px 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
}

.sidebar-user .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 13px; font-weight: 700; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 11px; color: var(--text-muted); font-weight: 600; }

/* ==================== MAIN CONTENT ==================== */
.admin-main {
  margin-right: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0; /* Prevent flex children from overflowing the page */
}

.admin-header {
  height: calc(var(--header-height) + 16px);
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.admin-header h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-heading);
}

.admin-content {
  flex: 1;
  padding: 40px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  min-width: 0; /* Prevent overflow inside content area */
}

/* Global width rule for standard cards inside admin content */
.admin-content > .card {
  max-width: 1450px !important;
  margin: 0 auto !important;
  width: 100% !important;
}

/* ==================== CARDS ==================== */
.card {
  background: rgba(26, 34, 53, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  position: relative;
  z-index: 1;
  min-width: 0; /* Keep card contained in parent viewport */
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 16px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.stat-card {
  background: rgba(26, 34, 53, 0.5);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 24px 32px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.primary { background: var(--primary-bg); color: var(--primary); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-bg);  color: var(--danger); }

.stat-value { font-size: 28px; font-weight: 800; color: var(--text-heading); }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }

/* ==================== TABLE ==================== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.04);
  width: 100%;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  background: rgba(17, 24, 39, 0.7);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  padding: 16px 20px;
  text-align: right;
  border-bottom: 2px solid rgba(255,255,255,0.06);
  white-space: nowrap;
}

td {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text);
  vertical-align: middle;
  transition: all var(--transition);
  white-space: nowrap;
}

/* Allow title column to wrap cleanly but with a minimum width to prevent squishing */
td.title-col,
td[style*="font-weight:700"] {
  white-space: normal;
  min-width: 180px;
}

tr { transition: background-color 0.2s ease; }
tr:nth-child(even) td { background: rgba(255, 255, 255, 0.01); }
tr:hover td {
  background: rgba(99, 102, 241, 0.06);
  color: var(--text-heading);
}

/* Table Partitioning Tabs Styles */
.table-tabs-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 24px;
  padding-bottom: 2px;
  flex-wrap: wrap;
  gap: 16px;
}

.table-tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  color: var(--text-heading);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  transition: all var(--transition);
  border-radius: 2px;
}

.tab-btn.active {
  color: var(--primary-hover);
  background: rgba(99, 102, 241, 0.05);
}

.tab-btn.active::after {
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
}

.tab-btn .badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-right: 4px;
}

.partition-empty-state {
  display: none;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  margin-top: 16px;
}

.partition-empty-state .empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.7;
}

.partition-empty-state h4 {
  color: var(--text-heading);
  font-size: 15px;
  margin-bottom: 4px;
}

/* ==================== FORMS ==================== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 8px;
}

.form-label i[data-lucide],
.form-label svg {
  width: 15px;
  height: 15px;
  color: var(--primary);
  display: inline-block;
  vertical-align: middle;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition);
  direction: rtl;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

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

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary { background: var(--accent-cta); color: #fff !important; }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active { background: var(--accent-cta-hover); color: #fff !important; transform: translateY(-1px); }
.btn-success { background: var(--success); color: #fff !important; }
.btn-success:hover, .btn-success:focus, .btn-success:active { filter: brightness(1.05); color: #fff !important; }
.btn-danger  { background: var(--danger);  color: #fff !important; }
.btn-danger:hover, .btn-danger:focus, .btn-danger:active { filter: brightness(1.1); color: #fff !important; }
.btn-ghost { background: transparent; color: var(--text-muted) !important; border: 1px solid var(--border); }
.btn-ghost:hover, .btn-ghost:focus, .btn-ghost:active { background: var(--bg-hover); color: var(--text) !important; }
.btn-outline {
  background: var(--bg-card);
  color: var(--text-heading) !important;
  border: 1px solid var(--border);
}
.btn-outline:hover, .btn-outline:focus, .btn-outline:active {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--text-heading) !important;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Global busy / double-click guard */
.sf-btn-busy {
  position: relative !important;
  cursor: wait !important;
  filter: saturate(0.85);
}
.sf-btn-busy-spinner {
  position: absolute;
  inset-inline-end: 10px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: sf-btn-spin 0.7s linear infinite;
  pointer-events: none;
  opacity: 0.95;
  flex-shrink: 0;
}
@keyframes sf-btn-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .sf-btn-busy-spinner { animation-duration: 1.4s; }
}

/* ==================== BADGES ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.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-primary { background: var(--primary-bg); color: var(--primary); }

/* ==================== PAGINATION ==================== */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
  max-width: 100%;
  min-width: 0;
}

.pagination a, .pagination span, .pagination button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all var(--transition);
  background: var(--bg-card);
  cursor: pointer;
  font-family: inherit;
}

.pagination-form {
  display: inline-flex;
  margin: 0;
  padding: 0;
}

.pagination a:hover, .pagination button:hover { background: var(--bg-hover); color: var(--text); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .pager-disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}
.qbank-pager,
.admin-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  max-width: 100%;
  min-width: 0;
}
.admin-pager .pagination {
  margin-top: 0;
  justify-content: flex-start;
}
.admin-pager-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}
.admin-pager-jump {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.admin-pager-jump-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}
.admin-pager-jump-input {
  width: 4.5rem;
  height: 36px;
  text-align: center;
}
.pagination .pager-ellipsis {
  min-width: 28px;
  border: none;
  background: transparent;
  cursor: default;
  pointer-events: none;
  color: var(--text-muted);
}
.qbank-pager-meta,
.admin-pager-meta {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-heading);
}
.qbank-status-tabs {
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  padding-bottom: 4px;
}
.qbank-status-tabs .table-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  overflow: visible;
  white-space: normal;
}
.qbank-status-tabs .tab-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-heading);
}
.light-mode .qbank-status-tabs .tab-btn {
  color: var(--primary-dark) !important;
  background: #fff !important;
  border-color: rgba(44, 48, 73, 0.16);
}
.light-mode .qbank-status-tabs .tab-btn.active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary);
}
.light-mode .pagination a,
.light-mode .pagination span,
.light-mode .pagination button {
  background: #fff;
  color: var(--primary-dark);
  border: 1px solid rgba(44, 48, 73, 0.18);
}
.light-mode .pagination .active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ==================== VECTOR ICONS (LUCIDE) ==================== */
.lucide,
i[data-lucide] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  width: 18px;
  height: 18px;
  stroke-width: 2px;
  margin-left: 8px; /* RTL spacing */
  flex-shrink: 0;
}

/* Icons inside buttons */
.btn i[data-lucide] {
  width: 16px;
  height: 16px;
  margin-left: 6px;
}

/* Icons inside sidebar */
.nav-link i[data-lucide] {
  width: 20px;
  height: 20px;
  margin-left: 12px;
  color: var(--text-muted);
  transition: color var(--transition);
}
.nav-link.active i[data-lucide] {
  color: var(--primary);
}

/* Icons inside alerts */
.alert i[data-lucide] {
  width: 20px;
  height: 20px;
  margin-left: 8px;
}

/* ==================== ALERTS ==================== */
.alert {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(34,197,94,0.2); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.2); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }

/* ==================== LOGIN PAGE ==================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 15% 50%, rgba(99,102,241,0.15), transparent 25%),
              radial-gradient(circle at 85% 30%, rgba(139,92,246,0.15), transparent 25%),
              var(--bg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.03) 10%, transparent 20%),
              radial-gradient(circle, rgba(139, 92, 246, 0.03) 10%, transparent 20%);
  background-size: 60px 60px;
  background-position: 0 0, 30px 30px;
  animation: moveBg 30s linear infinite;
  z-index: 0;
}

@keyframes moveBg {
  0% { transform: translate(0, 0); }
  100% { transform: translate(60px, 60px); }
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(26, 34, 53, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 48px 40px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
  position: relative;
  z-index: 1;
  animation: cardEntrance 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes cardEntrance {
  from { opacity: 0; transform: translateY(30px) scale(0.95); filter: blur(10px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.login-card h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-heading);
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 36px;
}

.login-card .form-group {
  position: relative;
}

.login-card .form-input { 
  height: 52px;
  background: rgba(17, 24, 39, 0.5);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0 16px;
}

.login-card .form-input:focus {
  background: rgba(17, 24, 39, 0.8);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), 0 8px 16px rgba(0,0,0,0.2);
  transform: translateY(-2px);
}

.login-card .btn { 
  width: 100%; 
  height: 52px; 
  justify-content: center; 
  font-size: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.25);
  position: relative;
  overflow: hidden;
  border: none;
  margin-top: 12px;
}

.login-card .btn::after {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: skewX(-20deg);
  transition: all 0.6s ease;
}

.login-card .btn:hover::after {
  left: 150%;
}

.login-card .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(99, 102, 241, 0.4);
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }

/* ===== Student login devices ===== */
.device-limit-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  margin-bottom: 14px;
  background: var(--primary-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.student-password-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}
.student-password-box h4 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}
.student-password-box h4 i { width: 16px; height: 16px; color: var(--primary); }
.student-password-box .hint {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.student-password-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.student-password-grid label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.student-password-grid .form-input { height: 38px; width: 100%; }
.sf-password-field {
  position: relative;
}
.sf-password-field .form-input {
  padding-inline-end: 42px;
}
.sf-password-toggle {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sf-password-toggle:hover {
  color: var(--text-main);
  background: var(--primary-bg);
}
.sf-password-toggle i {
  width: 16px;
  height: 16px;
}
@media (max-width: 992px) {
  .student-password-grid { grid-template-columns: 1fr; }
}

.device-limit-form label { font-size: 13px; font-weight: 700; color: var(--text-main); }
.device-limit-form .form-input { width: 90px; height: 38px; text-align: center; }
.device-limit-hint { font-size: 12px; color: var(--text-muted); }

.device-list { display: flex; flex-direction: column; gap: 10px; }

.device-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.device-item:hover { border-color: var(--accent-calm); }

.device-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--primary-bg);
  color: var(--primary);
}

.device-item-icon i { width: 20px; height: 20px; }
.device-item-body { flex: 1; min-width: 0; }
.device-item-title { font-size: 14px; font-weight: 700; color: var(--text-main); margin-bottom: 4px; word-break: break-word; }

.device-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.device-item-meta span { display: inline-flex; align-items: center; gap: 4px; }
.device-item-meta i { width: 13px; height: 13px; }
.device-item-id { font-family: monospace; }

@media (max-width: 768px) {
  .device-item { flex-wrap: wrap; }
}

/* ==================== TOOLBAR ==================== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  height: 40px;
  min-width: 280px;
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  direction: rtl;
}

/* ==================== RESPONSIVE ==================== */
.sidebar-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  color: var(--text-heading);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-hover);
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.2);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Add shimmer and glass effects globally for modern feel */
.btn-primary {
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(226, 149, 53, 0.35);
}

.btn-primary::after {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  transform: skewX(-25deg);
  transition: none;
}

.btn-primary:hover::after {
  animation: shine 0.75s ease-in-out;
}

@keyframes shine {
  100% { left: 150%; }
}

.form-input, .form-select, .form-textarea {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.15), 0 0 0 3px var(--primary-bg);
}

/* Improve Table Responsiveness & Scroll Indicator */
.table-wrapper {
  position: relative;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) rgba(255,255,255,0.02);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
  width: 100%;
  max-width: 100%;
}

.table-wrapper::-webkit-scrollbar {
  height: 6px;
}
.table-wrapper::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}
.table-wrapper::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}@media (max-width: 1024px) {
  .sidebar-toggle { display: flex; }
  
  /* Cosmic Glassmorphism tablet/mobile drawer sidebar */
  .admin-sidebar {
    transform: translateX(100%);
    transition: transform 350ms cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(10, 14, 26, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  
  .admin-main { margin-right: 0; }
  .admin-content { padding: 24px; }
  .card { padding: 24px; }

  /* Cosmic mobile/tablet sticky header with responsive height */
  .admin-header {
    padding: 12px 24px;
    height: auto;
    min-height: var(--header-height);
    flex-wrap: wrap;
    gap: 12px;
    background: rgba(10, 14, 26, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  }
  .admin-header h1 {
    font-size: 18px;
    font-weight: 800;
  }

  /* Adapting the stats grid for tablets using auto-fit */
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
  }

  /* Stack layout grids with unequal/wide ratios (e.g. 2fr 1fr) on tablets */
  div[style*="grid-template-columns:2fr 1fr"],
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns:2fr  1fr"],
  .chapter-form-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  /* Make 3-column and 5-column grids adapt beautifully with auto-fit on tablets */
  div[style*="grid-template-columns:1fr 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr 1fr;"],
  div[style*="grid-template-columns:1fr  1fr  1fr"] {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
    gap: 16px !important;
  }

  div[style*="grid-template-columns:1fr 1fr 1fr 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr 1fr 1fr 1fr"] {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
    gap: 16px !important;
  }

  /* Responsive Stack for Form & Action flex containers on mobile & tablets —
     scoped to known action rows only (never force-column every inline flex). */
  .form-actions,
  .actions-bar,
  .toolbar,
  .sf-hero-actions,
  .chapter-form-actions,
  .settings-floating-save {
    flex-wrap: wrap;
    gap: 12px;
  }

  .form-actions .btn,
  .actions-bar .btn,
  .toolbar .btn,
  .sf-hero-actions .btn,
  .form-group > .btn {
    min-height: 44px;
  }

  .table-tabs-container { gap: 10px; }
  .table-tabs {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .table-tabs::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 768px) {
  .admin-content { padding: 16px; }
  .admin-header { padding: 0 16px; }
  .admin-header h1 { font-size: 16px; }
  
  /* On mobile viewports, stack multi-column layouts — but keep auto-fill / auto-fit responsive grids */
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns:2fr 1fr"],
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns:1fr 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr 1fr"],
  .chapter-form-grid,
  .bilingual-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 24px;
  }
  .stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    transition: transform 200ms ease;
  }
  .stat-card:active {
    transform: scale(0.98);
  }
  .stat-value {
    font-size: 24px;
    color: var(--text-heading);
    font-weight: 800;
  }
  
  /* Beautiful glass cards on mobile — theme tokens (works in light + dark) */
  .card {
    padding: 20px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius-sm);
  }

  /* Luxurious sidebar link active states */
  .nav-link {
    padding: 14px 20px;
    font-size: 14px;
  }
  .nav-link.active {
    background: linear-gradient(135deg, rgba(122, 82, 153, 0.15), rgba(139, 92, 246, 0.08));
    border-right: 4px solid var(--primary); /* RTL glow border on the right */
    color: var(--text-heading);
    box-shadow: 0 0 15px rgba(122, 82, 153, 0.12);
  }

  /* Universal Responsive Block Tables (Card Layout) */
  .table-wrapper {
    border: none !important;
    overflow-x: visible !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  .table-wrapper table,
  .table-wrapper thead,
  .table-wrapper tbody,
  .table-wrapper th,
  .table-wrapper td,
  .table-wrapper tr {
    display: block !important;
  }
  .table-wrapper thead tr {
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
  }
  .table-wrapper tr {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    padding: 16px !important;
    margin-bottom: 16px !important;
    box-shadow: var(--shadow) !important;
    transition: transform 0.2s ease !important;
    color: var(--text) !important;
  }
  .table-wrapper tr:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 24px rgba(122, 82, 153, 0.12) !important;
  }
  .table-wrapper tr:nth-child(even) td {
    background: transparent !important;
  }
  .table-wrapper td {
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
    position: relative !important;
    padding: 12px 0 !important;
    padding-right: 40% !important;
    white-space: normal !important;
    min-width: 0 !important;
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    text-align: left !important;
    color: var(--text) !important;
    background: transparent !important;
  }
  .table-wrapper td::before {
    content: attr(data-label);
    position: absolute !important;
    top: 50% !important;
    right: 12px !important;
    transform: translateY(-50%) !important;
    width: 35% !important;
    white-space: nowrap !important;
    text-align: right !important;
    font-weight: 700 !important;
    color: var(--text-muted) !important;
    font-size: 13px !important;
  }
  .table-wrapper td:last-child {
    border-bottom: none !important;
    padding-top: 16px !important;
    padding-bottom: 0 !important;
    padding-right: 0 !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: center !important;
    width: 100% !important;
    display: flex !important;
  }
  .table-wrapper td:last-child::before {
    display: none !important;
  }
  .table-wrapper td:last-child a,
  .table-wrapper td:last-child button,
  .table-wrapper td:last-child form {
    flex: 1 1 calc(50% - 8px) !important;
    min-width: 110px !important;
    margin: 0 !important;
  }
  .table-wrapper td:last-child form button {
    width: 100% !important;
    justify-content: center !important;
  }
  .table-wrapper td:last-child .btn {
    justify-content: center !important;
    width: 100% !important;
    padding: 8px 12px !important;
  }
}


@media (max-width: 576px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .search-box {
    min-width: 0;
    width: 100%;
    background: var(--bg-card);
  }
  .toolbar .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .login-card {
    padding: 40px 24px;
    border-radius: 20px;
    background: rgba(26, 34, 53, 0.8);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  }
  
  .admin-header h1 { font-size: 14px; }

  /* Prevent auto-zoom on iOS by setting input font size to 16px */
  .form-input, .form-select, .form-textarea {
    font-size: 16px;
    padding: 12px 16px;
    background: var(--bg-card);
  }
  .form-input:focus, .form-select:focus, .form-textarea:focus {
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px var(--primary-bg);
  }

  /* Flex container stacking has been unified to max-width: 768px */
}

@media (max-width: 400px) {
  .admin-content { padding: 10px 8px !important; }
  .card { padding: 16px 12px !important; }
  .stat-card {
    padding: 16px !important;
    gap: 8px !important;
    flex-direction: column !important;
    text-align: center !important;
  }
  .stat-icon { margin: 0 auto !important; }
  .stat-value { font-size: 20px !important; }
  .brand-text { font-size: 13px !important; }
  .sidebar-brand { padding: 16px !important; gap: 10px !important; }

  /* Login card optimizations for extremely narrow screens */
  .login-card {
    padding: 32px 16px !important;
    border-radius: 16px !important;
  }
  .login-card h1 {
    font-size: 22px !important;
  }

  /* Table cards stacking vertical layout for perfect layout on tiny viewports */
  .table-wrapper td {
    flex-direction: column !important;
    align-items: flex-start !important;
    padding-right: 0 !important;
    padding-top: 30px !important; /* Space for absolute header */
    justify-content: flex-start !important;
    text-align: right !important;
  }
  .table-wrapper td::before {
    top: 6px !important;
    right: 0 !important;
    transform: none !important;
    width: 100% !important;
    text-align: right !important;
    font-size: 12px !important;
  }

  /* Full-width block action buttons on small mobile screen */
  .table-wrapper td:last-child {
    padding-top: 16px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .table-wrapper td:last-child a,
  .table-wrapper td:last-child button,
  .table-wrapper td:last-child form {
    flex: 1 1 100% !important;
    width: 100% !important;
    margin: 0 !important;
  }

  /* Sticky and flex container stacking adjustments for < 400px screens */
  .toolbar {
    gap: 8px !important;
  }
  .table-tabs-container {
    margin-bottom: 16px !important;
  }
  .tab-btn {
    padding: 8px 12px !important;
    font-size: 13px !important;
  }

  /* Fluid wrapping and compact sizing for pagination buttons to prevent horizontal break */
  .pagination {
    flex-wrap: wrap !important;
    gap: 4px !important;
  }
  .pagination a, .pagination span, .pagination button {
    min-width: 30px !important;
    height: 30px !important;
    font-size: 11px !important;
    padding: 0 6px !important;
  }

  /* Compact upload dropzones for better spacing */
  .upload-dropzone {
    padding: 16px 12px !important;
    border-width: 1.5px !important;
    border-radius: var(--radius-sm) !important;
  }
  .dropzone-icon {
    font-size: 24px !important;
    margin-bottom: 8px !important;
  }
  .dropzone-icon i[data-lucide],
  .dropzone-icon svg {
    width: 28px !important;
    height: 28px !important;
  }
  .dropzone-text {
    font-size: 12px !important;
    margin-bottom: 2px !important;
  }
  .dropzone-hint {
    font-size: 10px !important;
  }

  /* Prevent horizontal overflow on non-grid details tables (e.g. user profile details) */
  .card table:not(.table-wrapper table) td {
    white-space: normal !important;
    word-break: break-word !important;
    padding: 8px 6px !important;
    font-size: 13px !important;
  }
  .card table:not(.table-wrapper table) td[style*="width:120px"],
  .card table:not(.table-wrapper table) td[style*="width: 120px"] {
    width: 90px !important;
  }

  /* Compact Quill rich text editors on small viewports */
  .ql-toolbar.ql-snow {
    padding: 4px 6px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 2px !important;
  }
  .ql-toolbar.ql-snow button,
  .ql-toolbar.ql-snow .ql-picker {
    margin: 1px !important;
    padding: 2px !important;
  }
  .ql-snow .ql-picker-label {
    padding-left: 2px !important;
    padding-right: 8px !important;
  }
  .rich-editor-quill-container {
    height: 180px !important; /* More compact height on extremely narrow viewports */
  }

  /* Compact alert messages and padding */
  .alert {
    padding: 10px 14px !important;
    font-size: 13px !important;
    gap: 8px !important;
    margin-bottom: 16px !important;
  }
  .alert i[data-lucide],
  .alert svg {
    width: 16px !important;
    height: 16px !important;
  }
}


/* ==================== LOADING / DISABLED ==================== */
.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary:active { transform: scale(0.97); }

/* ==================== TOAST ANIMATION ==================== */
.alert {
  animation: slideIn 300ms ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== FORM SELECT ==================== */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 32px;
}

/* ==================== STICKY FORM CARD ==================== */
@media (min-width: 769px) {
  .card[style*="sticky"] { max-height: calc(100vh - 120px); overflow-y: auto; }
}

/* ==================== QUESTION CARDS ==================== */
.card + .card { margin-top: 0; }

/* ============================================================
   STUDENT PROFILE PAGE
   ============================================================ */

/* ==================== STAT CARDS GRID ==================== */
.student-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.student-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  backdrop-filter: blur(12px);
  transition: transform 200ms ease, box-shadow 200ms ease;
}
.student-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon-courses { background: rgba(99,102,241,0.15); color: var(--primary); }
.stat-icon-certs { background: rgba(234,179,8,0.15); color: #eab308; }
.stat-icon-exams { background: rgba(34,197,94,0.15); color: var(--success); }
.stat-icon-avg { background: rgba(168,85,247,0.15); color: #a855f7; }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--text-heading); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ==================== TABS NAVIGATION ==================== */
.student-tabs-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 24px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.student-tab-btn {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 200ms ease;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
  font-family: inherit;
}
.student-tab-btn svg { width: 16px; height: 16px; }
.student-tab-btn:hover { color: var(--text); background: var(--bg-hover); }
.student-tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(122, 82, 153, 0.28);
}

/* ==================== TAB CONTENT ==================== */
.student-tab-content {
  display: none;
  animation: tabFadeIn 300ms ease forwards;
}
.student-tab-content.active { display: block; }
@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==================== PROGRESS BAR ==================== */
.progress-bar-wrapper {
  position: relative;
  background: rgba(255,255,255,0.06);
  border-radius: 20px;
  height: 24px;
  min-width: 120px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-hover) 100%);
  transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0;
}
.progress-bar-fill.progress-excellent { background: linear-gradient(90deg, #22c55e, #4ade80); }
.progress-bar-fill.progress-good { background: linear-gradient(90deg, #eab308, #facc15); }
.progress-bar-fill.progress-weak { background: linear-gradient(90deg, #ef4444, #f87171); }
.progress-bar-text {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* ==================== REPORT STATS GRID ==================== */
.report-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.report-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  backdrop-filter: blur(12px);
}
.report-stat-value {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-heading);
  line-height: 1.2;
}
.report-stat-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.report-stat-pass { border-color: rgba(34,197,94,0.3); }
.report-stat-pass .report-stat-value { color: var(--success); }
.report-stat-fail { border-color: rgba(239,68,68,0.3); }
.report-stat-fail .report-stat-value { color: var(--danger); }
.report-stat-avg { border-color: rgba(122, 82, 153, 0.3); }
.report-stat-avg .report-stat-value { color: var(--primary); }
.report-stat-best { border-color: rgba(34,197,94,0.3); background: rgba(34,197,94,0.05); }
.report-stat-worst { border-color: rgba(234,179,8,0.3); background: rgba(234,179,8,0.05); }

/* ==================== PERFORMANCE CHART (CSS) ==================== */
.perf-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 220px;
  padding: 16px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.perf-chart-col {
  flex: 1;
  min-width: 50px;
  max-width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.perf-chart-bar {
  width: 100%;
  border-radius: 8px 8px 0 0;
  min-height: 8px;
  transition: height 600ms cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6px;
  position: relative;
}
.perf-chart-val {
  font-size: 10px;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.bar-excellent { background: linear-gradient(180deg, #22c55e, #16a34a); }
.bar-good { background: linear-gradient(180deg, #3b82f6, #2563eb); }
.bar-average { background: linear-gradient(180deg, #eab308, #ca8a04); }
.bar-weak { background: linear-gradient(180deg, #ef4444, #dc2626); }
.perf-chart-label {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   ATTEMPT DETAILS PAGE
   ============================================================ */

/* ==================== ATTEMPT HEADER ==================== */
.attempt-header-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.attempt-header-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  backdrop-filter: blur(12px);
}
.attempt-meta-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}
.attempt-meta-row span { display: flex; align-items: center; gap: 4px; }
.attempt-score-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.attempt-score-label { font-size: 12px; color: var(--text-muted); }
.attempt-score-value { font-size: 36px; font-weight: 800; color: var(--text-heading); line-height: 1.2; }
.attempt-score-status { margin-top: 6px; }
.score-pass { border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.05); }
.score-pass .attempt-score-value { color: var(--success); }
.score-fail { border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.05); }
.score-fail .attempt-score-value { color: var(--danger); }
.attempt-summary-card { display: flex; align-items: center; justify-content: center; }
.attempt-summary-row { display: flex; gap: 24px; }
.attempt-summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.attempt-summary-item svg { width: 20px; height: 20px; }
.attempt-summary-item span { font-size: 22px; font-weight: 800; line-height: 1; }
.attempt-summary-item small { font-size: 11px; color: var(--text-muted); }
.summary-correct svg, .summary-correct span { color: var(--success); }
.summary-wrong svg, .summary-wrong span { color: var(--danger); }
.summary-total svg, .summary-total span { color: var(--primary); }

/* ==================== QUESTION CARDS ==================== */
.questions-list { display: flex; flex-direction: column; gap: 16px; }
.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 200ms ease;
}
.question-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 4px; height: 100%;
  border-radius: 0 16px 16px 0;
}
.q-correct::before { background: var(--success); }
.q-wrong::before { background: var(--danger); }
.q-pending::before { background: var(--text-muted); }
.question-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.question-number {
  font-weight: 800;
  font-size: 14px;
  color: var(--primary);
  background: var(--primary-bg);
  padding: 4px 12px;
  border-radius: 8px;
}
.question-type-badge {
  font-size: 11px;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 6px;
}
.question-points {
  font-size: 13px;
  color: var(--text-muted);
  margin-right: auto;
}
.q-result-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
}
.q-result-badge svg { width: 14px; height: 14px; }
.q-result-correct { background: rgba(34,197,94,0.15); color: var(--success); }
.q-result-wrong { background: rgba(239,68,68,0.15); color: var(--danger); }
.q-result-pending { background: rgba(148,163,184,0.15); color: var(--text-muted); }
.question-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 16px;
}

/* ==================== OPTIONS ==================== */
.question-options { display: flex; flex-direction: column; gap: 8px; }
.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: all 200ms ease;
}
.option-indicator { flex-shrink: 0; display: flex; align-items: center; }
.option-indicator svg { width: 18px; height: 18px; }
.option-text { font-size: 14px; color: var(--text); }
.option-correct {
  border-color: rgba(34,197,94,0.4);
  background: rgba(34,197,94,0.06);
}
.option-selected:not(.option-correct) {
  border-color: rgba(239,68,68,0.4);
  background: rgba(239,68,68,0.06);
}

/* ==================== TEXT ANSWER & GRADER NOTES ==================== */
.text-answer-box, .grader-notes-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.7;
}
.text-answer-box strong, .grader-notes-box strong {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.grader-notes-box {
  border-color: rgba(234,179,8,0.3);
  background: rgba(234,179,8,0.05);
}

/* ==================== RESPONSIVE: STUDENT PROFILE ==================== */
@media (max-width: 1024px) {
  .student-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .attempt-header-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .student-stats-grid { grid-template-columns: 1fr 1fr; }
  .student-tab-btn { padding: 8px 14px; font-size: 13px; }
  .student-tab-btn svg { display: none; }
  #tab-info > div { grid-template-columns: 1fr !important; }
}
@media (max-width: 480px) {
  .student-stats-grid { grid-template-columns: 1fr; }
  .student-tabs-nav { gap: 2px; padding: 3px; }
  .student-tab-btn { padding: 7px 10px; font-size: 12px; }
  .attempt-summary-row { gap: 14px; }
  .attempt-summary-item span { font-size: 18px; }
  .attempt-score-value { font-size: 28px; }
  .question-header { gap: 6px; }
  .question-number { font-size: 12px; padding: 3px 8px; }
  .report-stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ==================== PREMIUM GLASSMORPHIC QUILL OVERRIDES ==================== */
/* Overall Editor Wrapper Styling */
.rich-editor-quill-container,
#editor-container {
  background: var(--bg-surface) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 1px solid var(--border) !important;
  border-bottom-left-radius: var(--radius) !important;
  border-bottom-right-radius: var(--radius) !important;
  color: var(--text) !important;
  font-family: var(--font-body, 'Tajawal', 'Cairo', sans-serif) !important;
  font-size: 14.5px !important;
  transition: border-color var(--transition), box-shadow var(--transition) !important;
  overflow: hidden;
  box-shadow: none !important;
}

/* Focused editor */
.rich-editor-quill-container.ql-container.ql-snow:focus-within,
#editor-container.ql-container.ql-snow:focus-within {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--primary-bg) !important;
}

/* Toolbar Styling */
.ql-toolbar.ql-snow {
  background: var(--bg-hover) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 1px solid var(--border) !important;
  border-bottom: 1px solid var(--border) !important;
  border-top-left-radius: var(--radius) !important;
  border-top-right-radius: var(--radius) !important;
  padding: 8px 10px !important;
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 4px !important;
  position: relative !important;
  z-index: 2 !important;
}

/* Keep Quill's native selects hidden — Select2 must never restyle them */
.ql-toolbar.ql-snow select,
.ql-snow .ql-toolbar select {
  display: none !important;
}
.ql-toolbar .select2-container,
.ql-snow .select2-container {
  display: none !important;
}

/* Editor content container */
.ql-container.ql-snow {
  border: 1px solid var(--border) !important;
  border-top: none !important;
  background: var(--bg-surface) !important;
}

/* The actual text writing area */
.ql-editor {
  direction: rtl !important;
  text-align: right !important;
  color: var(--text-heading) !important;
  background: var(--bg-surface) !important;
  line-height: 1.8 !important;
  padding: 18px 24px !important;
  caret-color: var(--primary) !important;
  min-height: 160px;
}

/* Custom Scrollbar for editor writing area */
.ql-editor::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.ql-editor::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}
.ql-editor::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.ql-editor::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Text placeholder styling */
.ql-editor.ql-blank::before {
  color: var(--text-muted) !important;
  font-style: normal !important;
  left: auto !important;
  right: 24px !important;
  opacity: 0.6 !important;
  font-size: 14px !important;
}

/* Toolbar button styling */
.ql-snow.ql-toolbar button {
  border-radius: var(--radius-sm) !important;
  width: 30px !important;
  height: 30px !important;
  padding: 5px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
  background: transparent !important;
}

/* Button strokes and fills */
.ql-snow.ql-toolbar button .ql-stroke {
  stroke: var(--text-muted) !important;
  transition: stroke 0.2s ease !important;
}
.ql-snow.ql-toolbar button .ql-fill {
  fill: var(--text-muted) !important;
  transition: fill 0.2s ease !important;
}

/* Hover / Active button styling */
.ql-snow.ql-toolbar button:hover,
.ql-snow.ql-toolbar button.ql-active {
  background: var(--primary-bg) !important;
}
.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke {
  stroke: var(--primary) !important;
  filter: none !important;
}
.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill {
  fill: var(--primary) !important;
  filter: none !important;
}

/* Dropdown styling (e.g. Header and Color Pickers) */
.ql-snow .ql-picker {
  color: var(--text) !important;
  font-family: var(--font-body, 'Tajawal', 'Cairo', sans-serif) !important;
  font-size: 13px !important;
  border-radius: var(--radius-sm) !important;
  transition: all 0.2s ease !important;
  height: 30px !important;
  display: inline-flex !important;
  align-items: center !important;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
  padding: 0 8px !important;
  margin: 0 !important;
  float: none !important;
}

.ql-snow .ql-picker-label {
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  color: var(--text) !important;
  border: none !important;
}
.ql-snow .ql-picker-label svg {
  right: auto !important;
  left: 0 !important;
  margin-top: 0 !important;
  position: relative !important;
  top: 0 !important;
  stroke: var(--text-muted) !important;
}

.ql-snow .ql-picker:hover {
  border-color: var(--primary) !important;
  background: var(--primary-bg) !important;
}
.ql-snow .ql-picker:hover .ql-picker-label svg {
  stroke: var(--primary) !important;
}

/* Floating Picker Options Menu */
.ql-snow .ql-picker-options {
  background: var(--bg-card) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 6px !important;
  min-width: 120px !important;
  top: 32px !important;
  z-index: 1000 !important;
}

/* Dropdown list item styling */
.ql-snow .ql-picker.ql-header .ql-picker-item {
  color: var(--text) !important;
  font-family: 'Cairo', sans-serif !important;
  font-size: 13px !important;
  padding: 6px 12px !important;
  border-radius: 4px !important;
  transition: all 0.15s ease !important;
  text-align: right !important;
}
.ql-snow .ql-picker.ql-header .ql-picker-item:hover,
.ql-snow .ql-picker.ql-header .ql-picker-item.ql-selected {
  background: var(--primary-bg) !important;
  color: var(--primary-hover) !important;
}

/* Table actions popup modal or input elements */
.ql-snow .ql-tooltip {
  background: var(--bg-card) !important;
  backdrop-filter: none !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--text) !important;
  padding: 10px 14px !important;
  z-index: 1000 !important;
}
.ql-snow .ql-tooltip input[type=text] {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  color: var(--text-heading) !important;
  padding: 4px 8px !important;
  font-size: 12px !important;
  margin-left: 8px !important;
  font-family: inherit !important;
}
.ql-snow .ql-tooltip a {
  color: var(--primary-hover) !important;
  font-size: 12px !important;
  transition: all 0.2s ease !important;
}
.ql-snow .ql-tooltip a:hover {
  text-decoration: underline !important;
}

/* Styling native Quill tables inside the editor */
.ql-editor table {
  border-collapse: collapse !important;
  margin: 15px 0 !important;
  width: 100% !important;
}
.ql-editor td, .ql-editor th {
  border: 1px solid var(--border) !important;
  padding: 8px 12px !important;
  background: var(--bg-surface) !important;
  color: var(--text) !important;
}
.ql-editor th {
  background: var(--bg-hover) !important;
  font-weight: 700 !important;
}

/* Beautiful color picker grids in dark mode */
.ql-snow .ql-color-picker .ql-picker-item {
  border-radius: 4px !important;
  border: 1px solid rgba(0,0,0,0.5) !important;
  margin: 2px !important;
  width: 16px !important;
  height: 16px !important;
  transition: transform 0.15s ease !important;
}

/* Lesson status icons (Free / Paid) in table view */
.lesson-status-icon {
  width: 28px;
  height: 28px;
  vertical-align: middle;
  object-fit: contain;
  transition: transform var(--transition), filter var(--transition);
  cursor: pointer;
}
.lesson-status-icon:hover {
  transform: scale(1.2) rotate(6deg);
  filter: drop-shadow(0 0 6px var(--primary-bg));
}

/* ==================== PRINT STYLES ==================== */
@media print {
  .admin-sidebar, .admin-header, .sidebar-toggle, .sidebar-overlay,
  .student-tabs-nav, .no-print, .btn { display: none !important; }
  .admin-layout { grid-template-columns: 1fr !important; }
  .admin-content { padding: 0 !important; }
  .print-only-header { display: block !important; text-align: center; margin-bottom: 20px; border-bottom: 2px solid #333; padding-bottom: 12px; }
  .student-tab-content { display: block !important; }
  body, .admin-content, .card, .question-card, .attempt-header-card,
  .report-stat-card, .student-stat-card { background: white !important; color: #111 !important; border-color: #ddd !important; }
  .stat-value, .report-stat-value, .attempt-score-value, .question-number { color: #111 !important; }
  .stat-label, .report-stat-label, .attempt-score-label, .question-type-badge,
  .option-text, .question-text, .perf-chart-label { color: #333 !important; }
  .progress-bar-fill { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .q-correct::before { background: #22c55e !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .q-wrong::before { background: #ef4444 !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .option-correct { background: #dcfce7 !important; border-color: #22c55e !important; }
  .option-selected:not(.option-correct) { background: #fee2e2 !important; border-color: #ef4444 !important; }
  .perf-chart-bar { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .badge { border: 1px solid #999 !important; background: #f3f3f3 !important; color: #333 !important; }
  table, th, td { border: 1px solid #ddd !important; }
}

/* ==================== PREMIUM NUMERIC STEPPER COMPONENT ==================== */
/* Hide native spin buttons */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

.numeric-stepper {
  display: inline-flex;
  width: 100%;
  align-items: center;
  background: rgba(17, 24, 39, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  direction: ltr; /* Force LTR layout for intuitive numeric adjustments */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 48px;
  box-sizing: border-box;
}

.numeric-stepper:focus-within {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.15), 0 0 0 3px var(--primary-bg);
}

.stepper-input {
  flex: 1;
  width: 100%;
  border: none !important;
  background: transparent !important;
  color: var(--text-heading) !important;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  padding: 4px 8px;
  box-shadow: none !important;
  outline: none !important;
}

.stepper-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.stepper-btn:hover {
  background: var(--primary);
  color: #fff !important;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.stepper-btn:active {
  transform: scale(0.95);
}

.stepper-btn i[data-lucide] {
  width: 16px;
  height: 16px;
  margin: 0 !important; /* Reset layout margin for inside button */
}

/* Disabled and readonly state styling */
.numeric-stepper.disabled,
.numeric-stepper:has(.stepper-input:disabled),
.numeric-stepper:has(.stepper-input[readonly]) {
  opacity: 0.6;
  pointer-events: none;
  background: rgba(17, 24, 39, 0.2);
}

/* Premium Datetime Picker UI styling */
.datetime-picker-wrapper {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
  background: rgba(17, 24, 39, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 48px;
  box-sizing: border-box;
}

.datetime-picker-wrapper:focus-within {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.15), 0 0 0 3px var(--primary-bg);
}

.datetime-picker-input {
  flex: 1;
  width: 100%;
  border: none !important;
  background: transparent !important;
  color: var(--text-heading) !important;
  font-size: 15px;
  font-weight: 500;
  padding: 12px 16px 12px 48px; /* LTR layout: space for left calendar icon */
  outline: none !important;
  box-shadow: none !important;
  cursor: pointer;
  box-sizing: border-box;
  color-scheme: dark; /* Force Chrome/Safari native calendar picker to dark */
  direction: ltr; /* Dates look cleaner in LTR */
  text-align: right;
}

.datetime-picker-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.datetime-picker-wrapper:focus-within .datetime-picker-icon {
  color: var(--primary);
}

/* Enable clicking anywhere on the input block to trigger the calendar picker */
.datetime-picker-input::-webkit-calendar-picker-indicator {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  color: transparent;
  cursor: pointer;
  opacity: 0; /* Cover the entire field transparently to intercept click events */
  z-index: 3;
}/* Disabled state styling for datetime */
.datetime-picker-wrapper.disabled,
.datetime-picker-wrapper:has(.datetime-picker-input:disabled),
.datetime-picker-wrapper:has(.datetime-picker-input[readonly]) {
  opacity: 0.6;
  pointer-events: none;
  background: rgba(17, 24, 39, 0.2);
}

/* Responsive Form Grid Utilities */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

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

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

/* Premium PWA Offline Ribbon Styles */
.pwa-offline-ribbon {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: rgba(220, 38, 38, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  z-index: 10000;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateY(-100%);
  opacity: 0;
  direction: rtl;
  pointer-events: none;
}
.pwa-offline-ribbon.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.pwa-offline-pulse {
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
  animation: pwa-pulse 1.5s infinite;
}
@keyframes pwa-pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

/* ==================== NAVIGATION DROPDOWN MENU ==================== */
.nav-dropdown-wrapper {
  margin-bottom: 4px;
}
.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.nav-dropdown-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-dropdown-toggle.active {
  color: var(--primary);
  background: var(--primary-bg);
  border-inline-start: 3px solid var(--primary);
  font-weight: 800;
}
.nav-dropdown-toggle .toggle-content {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-dropdown-toggle .toggle-content i[data-lucide] {
  width: 20px;
  height: 20px;
  margin-left: 12px;
  color: var(--text-muted);
  transition: color var(--transition);
}
.nav-dropdown-toggle.active .toggle-content i[data-lucide] {
  color: var(--primary);
}
.nav-dropdown-toggle .chevron-icon {
  width: 16px;
  height: 16px;
  margin-left: 0;
  margin-right: auto;
  transition: transform var(--transition);
}
.nav-dropdown-wrapper.open .chevron-icon {
  transform: rotate(180deg);
}
.nav-dropdown-menu {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition: max-height 300ms cubic-bezier(0.4, 0, 0.2, 1), opacity 300ms ease, margin 300ms ease;
  border-right: 1.5px solid rgba(255, 255, 255, 0.08);
  margin-right: 24px;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-dropdown-wrapper.open .nav-dropdown-menu {
  max-height: 400px;
  opacity: 1;
  pointer-events: auto;
  margin-top: 4px;
  margin-bottom: 8px;
}
.nav-dropdown-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.nav-dropdown-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-dropdown-link.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(122, 82, 153, 0.12);
}
.nav-dropdown-link .sub-nav-icon {
  width: 16px;
  height: 16px;
  margin-left: 8px;
  color: inherit;
}

/* LTR directional support override */
[dir="ltr"] .nav-dropdown-toggle .chevron-icon {
  margin-right: 0;
  margin-left: auto;
}
[dir="ltr"] .nav-dropdown-toggle .toggle-content i[data-lucide] {
  margin-left: 0;
  margin-right: 12px;
}
[dir="ltr"] .nav-dropdown-menu {
  border-right: none;
  border-left: 1.5px solid rgba(255, 255, 255, 0.08);
  margin-right: 0;
  margin-left: 24px;
  padding-right: 0;
  padding-left: 8px;
}
[dir="ltr"] .nav-dropdown-link .sub-nav-icon {
  margin-left: 0;
  margin-right: 8px;
}

/* ==================== QUILL IMAGE OVERLAY TOOLBAR & RESIZING ==================== */
.quill-image-overlay {
  position: absolute;
  background: rgba(15, 23, 42, 0.95) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 8px !important;
  padding: 6px 10px !important;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.5) !important;
  z-index: 1000;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: auto;
  direction: ltr !important;
  user-select: none;
  font-family: 'Cairo', system-ui, -apple-system, sans-serif !important;
  transition: opacity 0.2s ease;
}

.quill-image-overlay span {
  color: rgba(255, 255, 255, 0.7) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase;
}

.quill-image-overlay button {
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: #fff !important;
  border-radius: 6px !important;
  padding: 3px 8px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: all 0.15s ease;
  height: 24px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.quill-image-overlay button:hover {
  background: rgba(255, 255, 255, 0.25) !important;
  border-color: rgba(255, 255, 255, 0.4) !important;
}

.quill-image-overlay button.active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 8px var(--primary) !important;
}

.quill-image-overlay input {
  width: 55px !important;
  height: 24px !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 6px !important;
  color: #fff !important;
  font-size: 11px !important;
  text-align: center !important;
  outline: none !important;
  font-weight: 600 !important;
}

.quill-image-overlay input:focus {
  border-color: var(--primary) !important;
}

/* Image Selection Outline in Quill */
.ql-editor img {
  cursor: pointer;
  transition: outline 0.15s ease, box-shadow 0.15s ease;
  max-width: 100%;
}

.ql-editor img.ql-selected {
  outline: 3px solid rgba(99, 102, 241, 0.9) !important;
  outline-offset: 2px;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

/* ============================================================
   LIGHT MODE STYLING OVERRIDES
   ============================================================ */
.light-mode {
  --bg: #F8F9FA;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-page: #F8F9FA;
  --border: #e2e8f0;
  --border-light: rgba(0, 0, 0, 0.04);
  --text: #334155;
  --text-muted: #64748b;
  --text-heading: #2C3049;
  --primary: #7A5299;
  --primary-hover: #8F63AD;
  --primary-dark: #2C3049;
  --secondary: #6B9AC4;
  --secondary-hover: #5a89b3;
  --primary-bg: rgba(122, 82, 153, 0.10);
  --accent-cta: #E29535;
  --accent-cta-hover: #C97F28;
  --accent-calm: #6B9AC4;
  --success: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.08);
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --warning: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

body.light-mode {
  background: radial-gradient(circle at 15% 50%, rgba(122, 82, 153, 0.05), transparent 25%),
              radial-gradient(circle at 85% 30%, rgba(226, 149, 53, 0.04), transparent 25%),
              #F8F9FA;
  background-attachment: fixed;
}
body.light-mode::before {
  background: radial-gradient(circle, rgba(122, 82, 153, 0.015) 10%, transparent 20%);
  background-size: 60px 60px;
}

.light-mode .admin-sidebar {
  background: rgba(255, 255, 255, 0.85);
  border-left: 1px solid rgba(0, 0, 0, 0.06);
}
.light-mode .sidebar-brand {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.light-mode .sidebar-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.light-mode .sidebar-user {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.04);
}
.light-mode .admin-header {
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 4px 20px rgba(0,0,0,0.03);
}
.light-mode th {
  background: rgba(241, 245, 249, 0.9);
  border-bottom: 2px solid rgba(0, 0, 0, 0.06);
}
.light-mode tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.01);
}
.light-mode tr:hover td {
  background: rgba(79, 70, 229, 0.04);
}
.light-mode .table-tabs-container {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.light-mode .tab-btn:hover {
  background: rgba(0, 0, 0, 0.02);
}
.light-mode .tab-btn.active {
  background: rgba(79, 70, 229, 0.05);
}
.light-mode .partition-empty-state {
  border: 1px dashed rgba(0, 0, 0, 0.1);
}
.light-mode .card,
.light-mode .premium-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 8px 32px rgba(0,0,0,0.02);
}
.light-mode .stat-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 8px 24px rgba(0,0,0,0.02);
}
.light-mode .stat-card:hover {
  box-shadow: 0 16px 40px rgba(0,0,0,0.05), inset 0 1px 0 rgba(255,255,255,0.6);
}
.light-mode .login-card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 24px 48px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.8);
}
.light-mode .login-card .form-input {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.light-mode .login-card .form-input:focus {
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15), 0 8px 16px rgba(0,0,0,0.03);
}

/* Intercepting hardcoded inline styles for dark mode compatibility */
.light-mode td[style*="color:#fff"]:not(.btn *):not(.badge *),
.light-mode td[style*="color: #fff"]:not(.btn *):not(.badge *),
.light-mode strong[style*="color:#fff"]:not(.btn *):not(.badge *),
.light-mode strong[style*="color: #fff"]:not(.btn *):not(.badge *),
.light-mode span[style*="color:#fff"]:not(.btn *):not(.badge *),
.light-mode span[style*="color: #fff"]:not(.btn *):not(.badge *) {
  color: var(--text-heading) !important;
}

/* Quill Editor tweaks in Light Mode */
.light-mode .rich-editor-quill-container,
.light-mode #editor-container,
.light-mode .ql-toolbar.ql-snow,
.light-mode .ql-container.ql-snow,
.light-mode .ql-editor {
  background: #ffffff !important;
  color: var(--text-heading) !important;
  border-color: var(--border) !important;
  box-shadow: none !important;
}
.light-mode .ql-toolbar.ql-snow {
  background: #f8fafc !important;
}
.light-mode .ql-snow .ql-picker {
  background: #ffffff !important;
  border-color: var(--border) !important;
  color: var(--text-heading) !important;
}
.light-mode .ql-snow .ql-picker-options,
.light-mode .ql-snow .ql-tooltip {
  background: #ffffff !important;
  border-color: var(--border) !important;
  color: var(--text-heading) !important;
}
.light-mode .ql-stroke {
  stroke: var(--text-muted) !important;
}
.light-mode .ql-fill {
  fill: var(--text-muted) !important;
}
.light-mode .ql-picker {
  color: var(--text-heading) !important;
}

/* Dashboard Light Mode Overrides */
.light-mode .glass-glow-card {
  background: rgba(255, 255, 255, 0.8) !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.01), inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
}
.light-mode .glass-glow-card:hover {
  border-color: rgba(79, 70, 229, 0.2) !important;
  box-shadow: 0 15px 45px rgba(79, 70, 229, 0.04), 0 10px 30px rgba(0, 0, 0, 0.02) !important;
}
.light-mode .badge-normal {
  background: rgba(0, 0, 0, 0.03) !important;
  color: var(--text-muted) !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
}
.light-mode .badge-primary {
  background: rgba(79, 70, 229, 0.08) !important;
  color: #4f46e5 !important;
  border: 1px solid rgba(79, 70, 229, 0.2) !important;
}

/* Light mode overrides for high-contrast action buttons in tables */
.light-mode a[style*="color:#a78bfa"],
.light-mode a[style*="color: #a78bfa"],
.light-mode button[style*="color:#a78bfa"],
.light-mode button[style*="color: #a78bfa"] {
  color: #6d28d9 !important;
  background: rgba(109, 40, 217, 0.08) !important;
  border-color: rgba(109, 40, 217, 0.18) !important;
}

.light-mode a[style*="color:#fbbf24"],
.light-mode a[style*="color: #fbbf24"],
.light-mode button[style*="color:#fbbf24"],
.light-mode button[style*="color: #fbbf24"] {
  color: #b45309 !important;
  background: rgba(180, 83, 9, 0.08) !important;
  border-color: rgba(180, 83, 9, 0.18) !important;
}

.light-mode a[style*="color:#34d399"],
.light-mode a[style*="color: #34d399"],
.light-mode button[style*="color:#34d399"],
.light-mode button[style*="color: #34d399"],
.light-mode a[style*="color:#34D399"],
.light-mode a[style*="color: #34D399"] {
  color: #047857 !important;
  background: rgba(4, 120, 87, 0.08) !important;
  border-color: rgba(4, 120, 87, 0.18) !important;
}

.light-mode a[style*="color:#f87171"],
.light-mode a[style*="color: #f87171"],
.light-mode button[style*="color:#f87171"],
.light-mode button[style*="color: #f87171"] {
  color: #b91c1c !important;
  background: rgba(185, 28, 28, 0.08) !important;
  border-color: rgba(185, 28, 28, 0.18) !important;
}

/* Light mode overrides for high-contrast badge inline styles in tables */
.light-mode span[style*="color:#a5b4fc"],
.light-mode span[style*="color: #a5b4fc"] {
  color: #4f46e5 !important;
  background: rgba(79, 70, 229, 0.08) !important;
  border-color: rgba(79, 70, 229, 0.18) !important;
}

.light-mode span[style*="color:#93c5fd"],
.light-mode span[style*="color: #93c5fd"] {
  color: #1d4ed8 !important;
  background: rgba(29, 78, 216, 0.08) !important;
  border-color: rgba(29, 78, 216, 0.18) !important;
}

.light-mode span[style*="color:#34d399"],
.light-mode span[style*="color: #34d399"] {
  color: #047857 !important;
  background: rgba(4, 120, 87, 0.08) !important;
  border-color: rgba(4, 120, 87, 0.18) !important;
}

.light-mode span[style*="color:#f87171"],
.light-mode span[style*="color: #f87171"] {
  color: #b91c1c !important;
  background: rgba(185, 28, 28, 0.08) !important;
  border-color: rgba(185, 28, 28, 0.18) !important;
}

.light-mode span[style*="color:#fbbf24"],
.light-mode span[style*="color: #fbbf24"] {
  color: #b45309 !important;
  background: rgba(180, 83, 9, 0.08) !important;
  border-color: rgba(180, 83, 9, 0.18) !important;
}

/* General Light Mode Container Interceptors */
.light-mode [style*="background: rgba(26, 34, 53"],
.light-mode [style*="background:rgba(26, 34, 53"],
.light-mode [style*="background: rgba(26,34,53"],
.light-mode [style*="background:rgba(26,34,53"] {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow) !important;
}

/* Intercept card hover enhancements */
.light-mode [style*="background: rgba(26, 34, 53"]:hover,
.light-mode [style*="background:rgba(26, 34, 53"]:hover {
  border-color: rgba(79, 70, 229, 0.2) !important;
  box-shadow: var(--shadow-lg) !important;
}

/* Intercept dark search boxes, tab bars, and tag-like backgrounds */
.light-mode [style*="background: rgba(15, 23, 42"],
.light-mode [style*="background:rgba(15,23,42"],
.light-mode [style*="background: rgba(30, 41, 59"],
.light-mode [style*="background:rgba(30, 41, 59"],
.light-mode [style*="background: rgba(15,23,42"] {
  background: var(--bg-hover) !important;
  border-color: var(--border) !important;
}

/* Intercept inner code fields and mono blocks */
.light-mode code[style*="background: rgba(15, 23, 42"],
.light-mode code[style*="background:rgba(15,23,42"],
.light-mode code[style*="background:rgba(15, 23, 42"] {
  background: rgba(0, 0, 0, 0.03) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

/* Intercept filter tab active styles */
.light-mode .filter-tab {
  color: var(--text-muted) !important;
}
.light-mode .filter-tab.active,
.light-mode .filter-tab[style*="background: var(--primary)"],
.light-mode .filter-tab[style*="background:var(--primary)"] {
  background: var(--primary) !important;
  color: #ffffff !important;
}

/* Intercept template gallery cards inside templates.html */
.light-mode .template-card {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow) !important;
}
.light-mode .template-card:hover {
  border-color: rgba(79, 70, 229, 0.2) !important;
  box-shadow: var(--shadow-lg) !important;
}
.light-mode .template-card.is-default {
  border-color: var(--primary) !important;
  background: rgba(79, 70, 229, 0.04) !important;
}
.light-mode .template-card.is-default:hover {
  border-color: var(--primary-hover) !important;
}
.light-mode .template-card div[style*="background:rgba(255,255,255,0.03)"],
.light-mode .template-card div[style*="background: rgba(255, 255, 255, 0.03)"] {
  background: rgba(0, 0, 0, 0.03) !important;
  border-color: var(--border) !important;
}
.light-mode .template-thumbnail-container {
  background: #f1f5f9 !important;
  border-color: var(--border) !important;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.04) !important;
}

/* Light Mode Input, Textarea, Select Overrides */
.light-mode input[type="text"],
.light-mode input[type="number"],
.light-mode input[type="email"],
.light-mode input[type="password"],
.light-mode input[type="datetime-local"],
.light-mode select,
.light-mode textarea,
.light-mode .form-input,
.light-mode .form-select,
.light-mode .form-control {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}

.light-mode input::placeholder,
.light-mode textarea::placeholder {
  color: var(--text-muted) !important;
  opacity: 0.7;
}

.light-mode input[type="text"]:focus,
.light-mode input[type="number"]:focus,
.light-mode input[type="email"]:focus,
.light-mode input[type="password"]:focus,
.light-mode input[type="datetime-local"]:focus,
.light-mode select:focus,
.light-mode textarea:focus,
.light-mode .form-input:focus,
.light-mode .form-select:focus,
.light-mode .form-control:focus {
  background: #ffffff !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1) !important;
}

/* ==========================================
   GLOBAL LIGHT MODE OVERRIDES FOR LOCAL PAGE TEMPLATE STYLES
   ========================================== */

/* 1. Reset Local Glassmorphic variables to Light versions */
.light-mode,
.light-mode :root,
.light-mode * {
  --glass-bg: rgba(255, 255, 255, 0.85) !important;
  --glass-border: rgba(0, 0, 0, 0.08) !important;
  --glass-hover-border: rgba(99, 102, 241, 0.25) !important;
  --card-bg-glass: rgba(255, 255, 255, 0.85) !important;
  --card-border-glass: rgba(0, 0, 0, 0.08) !important;
  --card-hover-border: rgba(99, 102, 241, 0.25) !important;
  --aurora-gradient: linear-gradient(135deg, rgba(99, 102, 241, 0.04) 0%, rgba(139, 92, 246, 0.02) 50%, rgba(16, 185, 129, 0.02) 100%) !important;
}

/* 2. Text contrast fixes inside card blocks (hiding white texts on light backgrounds) */
.light-mode .rubric-card-item h3,
.light-mode .difficulty-title,
.light-mode .status-title,
.light-mode .panel-title,
.light-mode .metric-info .metric-value,
.light-mode .metric-info h4,
.light-mode .form-group-premium label,
.light-mode .filter-form-group label,
.light-mode #import-panel h3,
.light-mode #import-panel h4,
.light-mode #ai-config-modal h3,
.light-mode #ai-config-modal h4,
.light-mode #ai-modal h3,
.light-mode #ai-modal h4,
.light-mode .ai-modal-container h3,
.light-mode .ai-modal-container h4,
.light-mode .ai-modal-container p,
.light-mode .empty-drop-zone,
.light-mode .q-text-premium,
.light-mode .empty-state p {
  color: var(--text-heading) !important;
}

/* 3. Panel and Modal Container Light Mode Styling */
.light-mode .aurora-bg-container {
  background: var(--aurora-gradient) !important;
  border-color: var(--border) !important;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.02) !important;
}

.light-mode .premium-card,
.light-mode .stat-card-premium,
.light-mode .rubric-card-item,
.light-mode .metric-card {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow) !important;
}

.light-mode .premium-card:hover,
.light-mode .stat-card-premium:hover,
.light-mode .rubric-card-item:hover,
.light-mode .metric-card:hover {
  border-color: var(--primary) !important;
  background: var(--bg-surface) !important;
}

.light-mode #import-panel,
.light-mode #ai-config-modal .ai-modal-container,
.light-mode #ai-modal .ai-modal-container {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow-lg) !important;
}

.light-mode #import-panel *,
.light-mode #ai-config-modal *,
.light-mode #ai-modal * {
  border-color: var(--border) !important;
}

.light-mode #import-panel form {
  background: rgba(0, 0, 0, 0.01) !important;
  border-color: var(--border) !important;
}

/* 4. Choice Selection Cards (Difficulty, Status, etc.) */
.light-mode .difficulty-card,
.light-mode .status-card {
  background: rgba(0, 0, 0, 0.02) !important;
  border-color: rgba(0, 0, 0, 0.06) !important;
}

.light-mode .difficulty-card:hover,
.light-mode .status-card:hover {
  background: rgba(99, 102, 241, 0.04) !important;
  border-color: rgba(99, 102, 241, 0.2) !important;
}

.light-mode .difficulty-card.active,
.light-mode .status-card.active {
  background: rgba(99, 102, 241, 0.08) !important;
  border-color: var(--primary) !important;
}

/* 5. Drag & Drop list system */
.light-mode .questions-list {
  background: rgba(0, 0, 0, 0.02) !important;
  border-color: var(--border) !important;
}

.light-mode .q-card-premium,
.light-mode .filters-card-premium {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
}

.light-mode .q-card-premium:hover {
  border-color: var(--primary) !important;
  background: var(--bg-hover) !important;
}

.light-mode .empty-drop-zone {
  background: rgba(0, 0, 0, 0.01) !important;
  border-color: var(--border) !important;
}

/* 6. Custom Select Dropdowns */
.light-mode .search-select-trigger {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}

.light-mode .search-select-dropdown {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08) !important;
}

.light-mode .search-select-input {
  background: rgba(0, 0, 0, 0.02) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}

.light-mode .search-select-option {
  color: var(--text) !important;
}

.light-mode .search-select-option:hover {
  background: rgba(99, 102, 241, 0.05) !important;
  color: var(--primary) !important;
}

.light-mode .search-select-option.selected {
  background: rgba(99, 102, 241, 0.1) !important;
  color: var(--primary) !important;
}

/* 7. Action Circle Buttons in Tables */
.light-mode .action-btn-circle {
  background: rgba(0, 0, 0, 0.02) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}

.light-mode .action-btn-circle:hover {
  background: var(--bg-hover) !important;
  color: var(--text-heading) !important;
}

/* 8. Tab group & Filter buttons overrides */
.light-mode .filter-btn-group {
  background: rgba(0, 0, 0, 0.03) !important;
  border-color: var(--border) !important;
}

.light-mode .filter-btn-premium {
  color: var(--text-muted) !important;
}

.light-mode .filter-btn-premium.active {
  background: rgba(99, 102, 241, 0.1) !important;
  color: var(--primary) !important;
  border: 1px solid rgba(99, 102, 241, 0.2) !important;
}

.light-mode .tab-nav-btn {
  background: rgba(0, 0, 0, 0.02) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}

.light-mode .tab-nav-btn:hover {
  background: rgba(0, 0, 0, 0.04) !important;
  color: var(--text-heading) !important;
}

.light-mode .tab-nav-btn.active {
  background: rgba(99, 102, 241, 0.08) !important;
  color: var(--primary) !important;
  border-color: rgba(99, 102, 241, 0.2) !important;
}

.light-mode .wizard-btn-prev {
  background: rgba(0, 0, 0, 0.03) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

.light-mode .wizard-btn-prev:hover {
  background: rgba(0, 0, 0, 0.06) !important;
  border-color: rgba(0, 0, 0, 0.15) !important;
  color: var(--text-heading) !important;
}

/* 9. AI modal overlay & elements */
.light-mode .ai-modal-overlay {
  background: rgba(255, 255, 255, 0.85) !important;
}

.light-mode .ai-modal-container {
  background: #ffffff !important;
  border-color: var(--border) !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.08) !important;
}

.light-mode .ai-modal-header,
.light-mode .ai-modal-footer {
  background: rgba(0, 0, 0, 0.02) !important;
  border-color: var(--border) !important;
}

.light-mode .ai-modal-body select.form-select,
.light-mode .ai-modal-body input.form-input,
.light-mode .ai-modal-body textarea.form-input {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}

.light-mode .ai-modal-body select.form-select:focus,
.light-mode .ai-mode-body input.form-input:focus,
.light-mode .ai-modal-body textarea.form-input:focus {
  background: #ffffff !important;
  border-color: var(--primary) !important;
}

.light-mode #ai-drag-drop-zone {
  border-color: rgba(99, 102, 241, 0.25) !important;
  background: rgba(99, 102, 241, 0.02) !important;
}

.light-mode #ai-drag-drop-zone:hover {
  border-color: var(--primary) !important;
  background: rgba(99, 102, 241, 0.05) !important;
}

.light-mode #drag-drop-idle p,
.light-mode #drag-drop-loading p {
  color: var(--text) !important;
}

/* 10. Visual Template Editor Page Overrides */
.light-mode .toggle-btn-group {
  background: rgba(0, 0, 0, 0.03) !important;
  border-color: var(--border) !important;
}

.light-mode .toggle-btn {
  color: var(--text-muted) !important;
}

.light-mode .toggle-btn:hover {
  color: var(--text-heading) !important;
  background: rgba(0, 0, 0, 0.03) !important;
}

.light-mode .toggle-btn.active {
  background: var(--primary) !important;
  color: #111827 !important;
  box-shadow: 0 4px 12px rgba(197, 160, 89, 0.25) !important;
}

.light-mode .device-mock-frame {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.04) !important;
}

.light-mode .device-mock-header {
  background: rgba(0, 0, 0, 0.02) !important;
  border-color: var(--border) !important;
}

.light-mode .mock-address-bar {
  background: rgba(0, 0, 0, 0.04) !important;
  color: var(--text-muted) !important;
}

.light-mode .mock-viewport-content {
  background: #f1f5f9 !important;
}

.light-mode .preset-item-card {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
}

.light-mode .preset-item-card:hover {
  border-color: var(--primary) !important;
}

.light-mode .preset-item-card.active {
  background: rgba(197, 160, 89, 0.04) !important;
  border-color: var(--primary) !important;
}

.light-mode .custom-form-field label {
  color: var(--text) !important;
}

.light-mode .custom-form-field input,
.light-mode .custom-form-field select {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

.light-mode .custom-form-field input:focus,
.light-mode .custom-form-field select:focus {
  background: #ffffff !important;
  border-color: var(--primary) !important;
}

.light-mode .var-pill-key {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

.light-mode .var-pill-key:hover {
  background: var(--bg-hover) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

.light-mode .media-upload-area {
  border-color: var(--border) !important;
  background: rgba(0, 0, 0, 0.01) !important;
}

.light-mode .media-upload-area:hover {
  border-color: var(--primary) !important;
  background: rgba(197, 160, 89, 0.02) !important;
}

/* ════════════════════════════════════════════════════════════ */
/* 11. Rubrics Form Overrides (Light Mode)                      */
/* ════════════════════════════════════════════════════════════ */
.light-mode .criterion-card {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow) !important;
}

.light-mode .criterion-card:hover {
  border-color: var(--primary) !important;
}

.light-mode .level-row {
  background: rgba(0, 0, 0, 0.015) !important;
  border: 1px solid var(--border) !important;
}

.light-mode .level-row:hover {
  background: rgba(0, 0, 0, 0.03) !important;
}

.light-mode .c-num-badge {
  background: rgba(99, 102, 241, 0.08) !important;
  border-color: rgba(99, 102, 241, 0.2) !important;
  color: var(--primary) !important;
}

.light-mode #criteria-empty {
  background: rgba(0, 0, 0, 0.01) !important;
  border-color: var(--border) !important;
}

/* ════════════════════════════════════════════════════════════ */
/* 12. Question Bank Form Overrides (Light Mode)                */
/* ════════════════════════════════════════════════════════════ */
.light-mode .workspace-card {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow) !important;
}

.light-mode .workspace-header {
  border-bottom-color: var(--border) !important;
}

.light-mode .workspace-title {
  color: var(--text-heading) !important;
}

.light-mode .mcq-option-card {
  background: rgba(0, 0, 0, 0.01) !important;
  border-color: var(--border) !important;
}

.light-mode .mcq-option-card:hover {
  background: rgba(0, 0, 0, 0.02) !important;
  border-color: var(--primary) !important;
}

.light-mode .equation-editor-group {
  background: rgba(0, 0, 0, 0.015) !important;
  border-color: var(--border) !important;
}

.light-mode .math-toolbar {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
}

.light-mode math-field {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

.light-mode .tool-btn {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

.light-mode .tool-btn:hover {
  background: rgba(99, 102, 241, 0.08) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

.light-mode .tab-btn {
  color: var(--text-muted) !important;
}

.light-mode .tab-btn:hover {
  color: var(--text-heading) !important;
  background: rgba(0, 0, 0, 0.03) !important;
}

.light-mode .tab-btn.active {
  background: var(--primary) !important;
  color: #ffffff !important;
}

.light-mode .switch-btn {
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}

.light-mode .switch-btn:hover {
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

.light-mode .tf-card {
  background: rgba(0, 0, 0, 0.01) !important;
  border-color: var(--border) !important;
}

.light-mode .tf-card:hover {
  border-color: var(--primary) !important;
}

.light-mode .tf-card-title {
  color: var(--text-heading) !important;
}

.light-mode .upload-dropzone {
  background: rgba(0, 0, 0, 0.01) !important;
  border-color: var(--border) !important;
}

.light-mode .upload-dropzone:hover {
  background: rgba(99, 102, 241, 0.02) !important;
  border-color: var(--primary) !important;
}

.light-mode .dropzone-text {
  color: var(--text-heading) !important;
}

/* ════════════════════════════════════════════════════════════ */
/* 13. Exam Form & Spinner Overrides (Light Mode)              */
/* ════════════════════════════════════════════════════════════ */
.light-mode .numeric-stepper {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
}

.light-mode .numeric-stepper:focus-within {
  box-shadow: 0 4px 20px rgba(79, 70, 229, 0.15), 0 0 0 3px var(--primary-bg) !important;
}

.light-mode .stepper-input {
  color: var(--text-heading) !important;
  -webkit-text-fill-color: var(--text-heading) !important;
  background: transparent !important;
  caret-color: var(--text-heading) !important;
}

.light-mode .stepper-btn {
  background: rgba(0, 0, 0, 0.03) !important;
  color: var(--text) !important;
}

.light-mode .stepper-btn:hover {
  background: var(--primary) !important;
  color: #ffffff !important;
}

.light-mode .numeric-stepper.disabled,
.light-mode .numeric-stepper:has(.stepper-input:disabled),
.light-mode .numeric-stepper:has(.stepper-input[readonly]) {
  background: rgba(0, 0, 0, 0.05) !important;
}

.light-mode .difficulty-card,
.light-mode .status-card {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
}

.light-mode .difficulty-card:hover,
.light-mode .status-card:hover {
  background: var(--bg-hover) !important;
  border-color: var(--primary) !important;
}

.light-mode .difficulty-title,
.light-mode .status-title {
  color: var(--text-heading) !important;
}

.light-mode .difficulty-card.active[data-value=""] { border-color: #9ca3af !important; background: rgba(156, 163, 175, 0.08) !important; }
.light-mode .difficulty-card.active[data-value="easy"] { border-color: #10b981 !important; background: rgba(16, 185, 129, 0.08) !important; }
.light-mode .difficulty-card.active[data-value="medium"] { border-color: #4f46e5 !important; background: rgba(79, 70, 229, 0.08) !important; }
.light-mode .difficulty-card.active[data-value="hard"] { border-color: #f43f5e !important; background: rgba(244, 63, 94, 0.08) !important; }

.light-mode .status-card.active[data-value="1"] { border-color: #10b981 !important; background: rgba(16, 185, 129, 0.08) !important; }
.light-mode .status-card.active[data-value="0"] { border-color: #ef4444 !important; background: rgba(239, 68, 68, 0.08) !important; }

.light-mode .search-select-trigger {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

.light-mode .search-select-trigger:hover {
  border-color: var(--primary) !important;
}

.light-mode .search-select-dropdown {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow-lg) !important;
}

.light-mode .search-select-search-wrapper {
  border-bottom-color: var(--border) !important;
}

.light-mode .search-select-input {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

.light-mode .search-select-option {
  color: var(--text) !important;
}

.light-mode .search-select-option:hover {
  background: var(--bg-hover) !important;
  color: var(--text-heading) !important;
}

.light-mode .search-select-option.selected {
  background: rgba(79, 70, 229, 0.08) !important;
  color: var(--primary) !important;
}

.light-mode .tab-nav-btn {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}

.light-mode .tab-nav-btn:hover {
  background: var(--bg-hover) !important;
  color: var(--text-heading) !important;
  border-color: var(--border) !important;
}

.light-mode .tab-nav-btn.active {
  background: rgba(79, 70, 229, 0.08) !important;
  color: var(--primary) !important;
  border-color: rgba(79, 70, 229, 0.3) !important;
}

.light-mode .questions-list {
  background: rgba(0, 0, 0, 0.01) !important;
  border-color: var(--border) !important;
}

.light-mode .questions-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08) !important;
}

.light-mode .questions-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.15) !important;
}

.light-mode .q-card-premium {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow) !important;
}

.light-mode .q-card-premium:hover {
  border-color: var(--primary) !important;
  background: var(--bg-hover) !important;
}

.light-mode .filters-card-premium {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
}

.light-mode .empty-drop-zone {
  border-color: var(--border) !important;
  background: rgba(0, 0, 0, 0.01) !important;
}

.light-mode .form-section-title {
  border-bottom-color: var(--border) !important;
}

/* ════════════════════════════════════════════════════════════ */
/* 14. Global Inline Style Override Engine (Light Mode)         */
/* ════════════════════════════════════════════════════════════ */
.light-mode [style*="background: rgba(26, 34, 53"],
.light-mode [style*="background:rgba(26, 34, 53"],
.light-mode [style*="background: rgba(30, 41, 59"],
.light-mode [style*="background:rgba(30, 41, 59"],
.light-mode [style*="background: rgba(30,41,59"],
.light-mode [style*="background:rgba(30,41,59"] {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
}

.light-mode [style*="background: rgba(15, 23, 42"],
.light-mode [style*="background: rgba(15,23,42"],
.light-mode [style*="background:rgba(15,23,42"],
.light-mode [style*="background:rgba(15, 23, 42"],
.light-mode [style*="background: rgba(17, 24, 39"],
.light-mode [style*="background:rgba(17, 24, 39"],
.light-mode [style*="background: rgba(0, 0, 0, 0.15)"],
.light-mode [style*="background:rgba(0,0,0,0.15)"] {
  background: rgba(0, 0, 0, 0.015) !important;
  border-color: var(--border) !important;
}

.light-mode [style*="background: rgba(255, 255, 255, 0.02)"],
.light-mode [style*="background:rgba(255,255,255,0.02)"],
.light-mode [style*="background: rgba(255, 255, 255, 0.03)"],
.light-mode [style*="background:rgba(255,255,255,0.03)"] {
  background: rgba(0, 0, 0, 0.02) !important;
  border-color: var(--border) !important;
}

.light-mode [style*="border: 1px solid rgba(255, 255, 255"],
.light-mode [style*="border:1px solid rgba(255,255,255"],
.light-mode [style*="border: 2px solid rgba(255, 255, 255"],
.light-mode [style*="border:2px solid rgba(255,255,255"],
.light-mode [style*="border: 2px dashed rgba(255, 255, 255"],
.light-mode [style*="border:2px dashed rgba(255,255,255"],
.light-mode [style*="border-bottom: 1px solid rgba(255, 255, 255"],
.light-mode [style*="border-bottom:1px solid rgba(255,255,255"],
.light-mode [style*="border-top: 1px solid rgba(255, 255, 255"],
.light-mode [style*="border-top:1px solid rgba(255,255,255"] {
  border-color: var(--border) !important;
}

/* Force high contrast text on inline styling that sets color to white/light grey, while preserving actions/buttons */
.light-mode form [style*="color:#fff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode form [style*="color: #fff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode form [style*="color:#ffffff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode form [style*="color: #ffffff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode form [style*="color:#f8fafc"]:not(button):not(.btn):not(.badge):not(a),
.light-mode form [style*="color: #f8fafc"]:not(button):not(.btn):not(.badge):not(a),
.light-mode form [style*="color:#f1f5f9"]:not(button):not(.btn):not(.badge):not(a),
.light-mode form [style*="color: #f1f5f9"]:not(button):not(.btn):not(.badge):not(a),
.light-mode form [style*="color:#cbd5e1"]:not(button):not(.btn):not(.badge):not(a),
.light-mode form [style*="color: #cbd5e1"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .card [style*="color:#fff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .card [style*="color: #fff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .card [style*="color:#ffffff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .card [style*="color: #ffffff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .card [style*="color:#f8fafc"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .card [style*="color: #f8fafc"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .card [style*="color:#f1f5f9"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .card [style*="color: #f1f5f9"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .card [style*="color:#cbd5e1"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .card [style*="color: #cbd5e1"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .premium-card [style*="color:#fff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .premium-card [style*="color: #fff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .premium-card [style*="color:#ffffff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .premium-card [style*="color: #ffffff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .premium-card [style*="color:#cbd5e1"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .premium-card [style*="color: #cbd5e1"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .workspace-card [style*="color:#fff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .workspace-card [style*="color: #fff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .workspace-card [style*="color:#ffffff"]:not(button):not(.btn):not(.badge):not(a),
.light-mode .workspace-card [style*="color: #ffffff"]:not(button):not(.btn):not(.badge):not(a) {
  color: var(--text-heading) !important;
}

/* Ensure buttons with inline styles of white text on light backgrounds are overridden correctly to have dark text in light mode */
.light-mode .btn[style*="color:#fff"],
.light-mode .btn[style*="color: #fff"],
.light-mode .btn[style*="color:#ffffff"],
.light-mode .btn[style*="color: #ffffff"] {
  color: var(--text-heading) !important;
}
.light-mode .btn-primary[style*="color:#fff"],
.light-mode .btn-primary[style*="color: #fff"],
.light-mode .btn-primary[style*="color:#ffffff"],
.light-mode .btn-primary[style*="color: #ffffff"] {
  color: #ffffff !important; /* Keep primary buttons text white since primary background is deep indigo */
}

/* ════════════════════════════════════════════════════════════ */
/* 15. AI Question Generator Modal Overrides (Light Mode)       */
/* ════════════════════════════════════════════════════════════ */
.light-mode .ai-modal-overlay {
  background: rgba(15, 23, 42, 0.4) !important;
}

.light-mode .ai-modal-container {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow-lg) !important;
}

.light-mode .ai-modal-header {
  background: var(--bg-surface) !important;
  border-bottom-color: var(--border) !important;
}

.light-mode .ai-modal-footer {
  background: var(--bg-surface) !important;
  border-top-color: var(--border) !important;
}

.light-mode .ai-modal-body select.form-select,
.light-mode .ai-modal-body input.form-input,
.light-mode .ai-modal-body textarea.form-input {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

.light-mode .ai-modal-body select.form-select:focus,
.light-mode .ai-modal-body input.form-input:focus,
.light-mode .ai-modal-body textarea.form-input:focus {
  border-color: var(--primary) !important;
  background: #ffffff !important;
  box-shadow: 0 0 0 2px var(--primary-bg) !important;
}

.light-mode .ai-modal-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02) !important;
}

.light-mode .ai-modal-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08) !important;
}

.light-mode .ai-modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.15) !important;
}

.light-mode .ai-tab-btn.active {
  background: rgba(79, 70, 229, 0.08) !important;
  color: #4f46e5 !important;
  border-color: rgba(79, 70, 229, 0.25) !important;
}

.light-mode .ai-tab-btn:hover:not(.active) {
  color: var(--text-heading) !important;
  background: rgba(0, 0, 0, 0.03) !important;
}

.light-mode .btn[style*="color:#a5b4fc"],
.light-mode .btn[style*="color: #a5b4fc"] {
  color: #4f46e5 !important;
  background: rgba(79, 70, 229, 0.08) !important;
  border-color: rgba(79, 70, 229, 0.25) !important;
}

.light-mode .btn[style*="color:#a5b4fc"] i,
.light-mode .btn[style*="color: #a5b4fc"] i {
  color: #4f46e5 !important;
}

/* ════════════════════════════════════════════════════════════ */
/* 16. Exam Statistics Page Overrides (Light Mode)              */
/* ════════════════════════════════════════════════════════════ */
.light-mode .stat-card-premium {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow-sm) !important;
}

.light-mode .stat-card-premium:hover {
  border-color: var(--primary) !important;
  box-shadow: var(--shadow) !important;
}

.light-mode .panel-card-premium {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow-sm) !important;
}

.light-mode .toolbar-premium {
  border-bottom-color: var(--border) !important;
}

.light-mode .tabs-container-premium {
  border-bottom-color: var(--border) !important;
}

.light-mode .tab-btn-premium:hover:not(.active) {
  color: var(--text-heading) !important;
  background: rgba(0, 0, 0, 0.03) !important;
}

.light-mode .stats-table-premium th {
  background: rgba(0, 0, 0, 0.02) !important;
  border-bottom-color: var(--border) !important;
}

.light-mode .stats-table-premium td {
  border-bottom-color: var(--border) !important;
}

.light-mode .stats-table-premium tbody tr:hover {
  background: rgba(0, 0, 0, 0.01) !important;
}

.light-mode .chart-canvas-container {
  background: rgba(0, 0, 0, 0.01) !important;
  border-color: var(--border) !important;
}

.light-mode .summary-mini-card {
  border-color: var(--border) !important;
  background: rgba(0, 0, 0, 0.01) !important;
}

.light-mode .summary-mini-card.passed {
  background: rgba(16, 185, 129, 0.05) !important;
  border-color: rgba(16, 185, 129, 0.15) !important;
}

.light-mode .summary-mini-card.failed {
  background: rgba(239, 68, 68, 0.05) !important;
  border-color: rgba(239, 68, 68, 0.15) !important;
}

.light-mode .table-wrapper {
  border-color: var(--border) !important;
}




/* =============================================================
   LIGHT MODE: EXAM FORM PREMIUM UI (form.html components)
   ============================================================= */

/* --- Aurora Container --- */
.light-mode .aurora-bg-container {
  background: linear-gradient(135deg, rgba(79,70,229,0.04) 0%, rgba(139,92,246,0.02) 50%, rgba(16,185,129,0.02) 100%) !important;
  border: 1px solid rgba(0,0,0,0.07) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.04) !important;
}
.light-mode .aurora-bg-container::before {
  background: radial-gradient(circle, rgba(79,70,229,0.05) 0%, transparent 70%) !important;
}
.light-mode .aurora-bg-container::after {
  background: radial-gradient(circle, rgba(16,185,129,0.03) 0%, transparent 70%) !important;
}

/* --- Wizard Step Navigation --- */
.light-mode .tabs-progress-track {
  background: rgba(0,0,0,0.08) !important;
}
.light-mode .tabs-progress-fill {
  box-shadow: 0 0 6px rgba(79,70,229,0.3) !important;
}
.light-mode .tab-nav-step {
  background: rgba(255,255,255,0.9) !important;
  border-color: rgba(0,0,0,0.12) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
}
.light-mode .tab-nav-step i {
  color: rgba(0,0,0,0.3) !important;
}
.light-mode .tab-nav-label {
  color: #64748b !important;
}
.light-mode .tab-nav-btn:hover .tab-nav-step {
  border-color: rgba(79,70,229,0.35) !important;
  background: rgba(79,70,229,0.05) !important;
}
.light-mode .tab-nav-btn:hover .tab-nav-step i { color: #4f46e5 !important; }
.light-mode .tab-nav-btn:hover .tab-nav-label { color: #4f46e5 !important; }

.light-mode .tab-nav-btn.active .tab-nav-step {
  background: linear-gradient(135deg, rgba(79,70,229,0.12), rgba(139,92,246,0.08)) !important;
  border-color: #4f46e5 !important;
  box-shadow: 0 0 0 4px rgba(79,70,229,0.1), 0 4px 14px rgba(79,70,229,0.2) !important;
}
.light-mode .tab-nav-btn.active .tab-nav-step i { color: #4f46e5 !important; }
.light-mode .tab-nav-btn.active .tab-nav-label { color: #4f46e5 !important; font-weight: 700; }
.light-mode .tab-nav-btn.active .tab-nav-num { background: #4f46e5 !important; color: #fff !important; border-color: #4f46e5 !important; }

.light-mode .tab-nav-btn.completed .tab-nav-step {
  background: rgba(16,185,129,0.08) !important;
  border-color: rgba(16,185,129,0.4) !important;
}
.light-mode .tab-nav-btn.completed .tab-nav-step i { color: #059669 !important; }
.light-mode .tab-nav-btn.completed .tab-nav-label { color: #059669 !important; }
.light-mode .tab-nav-btn.completed .tab-nav-num { background: #059669 !important; }

.light-mode .tab-nav-num {
  background: rgba(255,255,255,0.95) !important;
  border-color: rgba(0,0,0,0.12) !important;
  color: rgba(0,0,0,0.4) !important;
}

/* --- Step indicator pill --- */
.light-mode #step-indicator {
  background: rgba(255,255,255,0.85) !important;
  border-color: rgba(0,0,0,0.08) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05) !important;
}
.light-mode #step-indicator span { color: #475569 !important; }

/* --- Form section title --- */
.light-mode .form-section-title {
  background: linear-gradient(135deg, rgba(79,70,229,0.06) 0%, transparent 100%) !important;
  border-left-color: #4f46e5 !important;
  color: #4f46e5 !important;
}

/* --- Form inputs override --- */
.light-mode .form-input-premium,
.light-mode .form-select {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  color: #0f172a !important;
}
.light-mode .form-input-premium:hover,
.light-mode .form-select:hover {
  border-color: #cbd5e1 !important;
  background: #ffffff !important;
}
.light-mode .form-input-premium:focus,
.light-mode .form-select:focus {
  border-color: #4f46e5 !important;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12) !important;
  background: #ffffff !important;
}
.light-mode .form-input-premium::placeholder { color: #94a3b8 !important; }
.light-mode .form-label,
.light-mode .form-group-premium label { color: #475569 !important; }
.light-mode .form-label i,
.light-mode .form-group-premium label i { color: #4f46e5 !important; }

/* --- Stat Input Cards (Timing tab) --- */
.light-mode .stat-input-card {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04) !important;
}
.light-mode .stat-input-card:focus-within {
  border-color: rgba(79,70,229,0.4) !important;
  box-shadow: 0 4px 16px rgba(79,70,229,0.08) !important;
}
.light-mode .stat-input-card::before {
  background: linear-gradient(90deg, #4f46e5, rgba(139,92,246,0.5)) !important;
}
.light-mode .stat-input-card-label { color: #64748b !important; }
.light-mode .stat-input-card input { color: #0f172a !important; }
.light-mode .stat-input-card-icon { background: rgba(79,70,229,0.08) !important; }

/* --- Toggle Cards --- */
.light-mode .toggle-card {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04) !important;
}
.light-mode .toggle-card::before {
  background: linear-gradient(135deg, rgba(79,70,229,0.04) 0%, transparent 60%) !important;
}
.light-mode .toggle-card:hover {
  border-color: rgba(79,70,229,0.2) !important;
  background: rgba(79,70,229,0.01) !important;
}
.light-mode .toggle-card-title { color: #0f172a !important; }
.light-mode .toggle-card-desc { color: #64748b !important; }
.light-mode .toggle-card-switch {
  background: #e2e8f0 !important;
  border-color: #cbd5e1 !important;
}
.light-mode .toggle-card-switch::after { background: #94a3b8 !important; }
.light-mode .toggle-card input:checked ~ .toggle-card-switch {
  background: rgba(79,70,229,0.7) !important;
  border-color: #4f46e5 !important;
}
.light-mode .toggle-card input:checked ~ .toggle-card-switch::after { background: #fff !important; }

.light-mode .toggle-card.security-card {
  background: rgba(220,38,38,0.02) !important;
  border-color: rgba(220,38,38,0.1) !important;
}
.light-mode .toggle-card.security-card:hover {
  border-color: rgba(220,38,38,0.2) !important;
  background: rgba(220,38,38,0.04) !important;
}
.light-mode .toggle-card.security-card input:checked ~ .toggle-card-switch {
  background: rgba(220,38,38,0.6) !important;
  border-color: #dc2626 !important;
}
.light-mode .toggle-card.security-card input:checked ~ .toggle-card-switch::after { background: #fff !important; }

/* --- Tab content card --- */
.light-mode .tab-content-card {
  background: rgba(255,255,255,0.85) !important;
  border-color: rgba(0,0,0,0.07) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.03) !important;
}

/* --- Wizard Footer buttons --- */
.light-mode .wizard-footer {
  border-top-color: rgba(0,0,0,0.08) !important;
}
.light-mode .wizard-footer::before {
  background: #4f46e5 !important;
}
.light-mode .wizard-btn-prev {
  background: rgba(0,0,0,0.02) !important;
  border-color: rgba(0,0,0,0.1) !important;
  color: #475569 !important;
}
.light-mode .wizard-btn-prev:hover {
  background: rgba(0,0,0,0.05) !important;
  border-color: rgba(0,0,0,0.15) !important;
  color: #0f172a !important;
}
.light-mode .wizard-btn-next {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%) !important;
  color: #fff !important;
  box-shadow: 0 4px 14px rgba(79,70,229,0.3) !important;
}
.light-mode .wizard-btn-next:hover {
  box-shadow: 0 8px 24px rgba(79,70,229,0.4) !important;
}
.light-mode .wizard-btn-save {
  box-shadow: 0 4px 14px rgba(16,185,129,0.25) !important;
}

/* --- Premium Card (form container) --- */
.light-mode .premium-card {
  background: rgba(255,255,255,0.88) !important;
  border-color: rgba(0,0,0,0.07) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.04) !important;
}

/* --- Question picker panels (light) --- */
.light-mode .qpick-panel {
  background: rgba(255,255,255,0.9) !important;
  border-color: rgba(0,0,0,0.08) !important;
}
.light-mode .qpick-panel-header {
  background: rgba(248,250,252,0.95) !important;
  border-bottom-color: rgba(0,0,0,0.06) !important;
}
.light-mode .qpick-filters {
  background: rgba(0,0,0,0.01) !important;
  border-bottom-color: rgba(0,0,0,0.04) !important;
}
.light-mode .qpick-filters input,
.light-mode .qpick-filters select {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  color: #0f172a !important;
}
.light-mode .qpick-panel-title.bank { color: #059669 !important; }
.light-mode .qpick-panel-title.assigned { color: #4f46e5 !important; }
.light-mode .qpick-panel-count.bank { background: rgba(16,185,129,0.1) !important; color: #059669 !important; }
.light-mode .qpick-panel-count.assigned { background: rgba(79,70,229,0.1) !important; color: #4f46e5 !important; }
.light-mode .questions-picker-header {
  background: linear-gradient(135deg, rgba(79,70,229,0.05) 0%, rgba(139,92,246,0.03) 100%) !important;
  border-color: rgba(79,70,229,0.12) !important;
}
.light-mode .qpick-stat-val { background: rgba(79,70,229,0.08) !important; color: #4f46e5 !important; }
.light-mode .qpick-stat-val.green { background: rgba(16,185,129,0.08) !important; color: #059669 !important; }

/* --- Alert error (light) --- */
.light-mode .alert-error {
  background: linear-gradient(135deg, rgba(220,38,38,0.05), rgba(220,38,38,0.02)) !important;
  border-color: rgba(220,38,38,0.15) !important;
  border-left-color: #dc2626 !important;
  color: #b91c1c !important;
}

/* --- Difficulty / Status cards text (light) --- */
.light-mode .difficulty-title,
.light-mode .status-title { color: #0f172a !important; }
.light-mode .difficulty-desc,
.light-mode .status-desc { color: #64748b !important; }

/* --- Section title inline style interceptors (form) --- */
.light-mode h2[style*="color:#f8fafc"],
.light-mode h2[style*="color: #f8fafc"] { color: #0f172a !important; }
.light-mode span[style*="color:rgba(148,163,184"],
.light-mode span[style*="color: rgba(148"] { color: #64748b !important; }


/* ============================================================
   Science Fun — Shared Admin UI (sf-*)
   Professional list/detail shells used across admin pages
   ============================================================ */
.sf-page { color: var(--text); }
.sf-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(122,82,153,0.10), rgba(226,149,53,0.10));
  border: 1px solid var(--border);
}
.sf-hero h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
}
.sf-hero p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
  max-width: 56ch;
}
.sf-hero-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(122,82,153,0.14);
  color: var(--primary);
  flex-shrink: 0;
}
.sf-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.sf-btn-cta {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: none !important;
  background: var(--accent-cta) !important;
  color: #fff !important;
  font-weight: 800 !important;
  font-size: 13px !important;
  text-decoration: none !important;
  box-shadow: 0 8px 20px rgba(226,149,53,0.35);
  cursor: pointer;
}
.sf-btn-cta:hover { background: var(--accent-cta-hover) !important; color: #fff !important; }
.sf-btn-ghost {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--border) !important;
  background: var(--bg-card) !important;
  color: var(--text-heading) !important;
  font-weight: 700 !important;
  text-decoration: none !important;
}
.sf-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.sf-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sf-stat .ico {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sf-stat .lbl { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.sf-stat .val { font-size: 20px; font-weight: 800; color: var(--text-heading); line-height: 1.2; }
.sf-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(44,48,73,0.04);
  margin-bottom: 18px;
}
.sf-card > .table-wrapper { margin: 0 -4px; }
.sf-table {
  width: 100%;
  border-collapse: collapse;
  text-align: start;
}
.sf-table thead th {
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-heading);
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.sf-table tbody td {
  padding: 14px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.sf-table tbody tr:hover td { background: rgba(122,82,153,0.04); }
.sf-table tbody tr:last-child td { border-bottom: none; }
.light-mode .sf-hero {
  background: linear-gradient(135deg, rgba(122,82,153,0.08), rgba(226,149,53,0.08));
}
.light-mode .sf-btn-cta { color: #fff !important; }

/* Light-mode safety overrides for leftover dark glass patterns */
.light-mode .premium-search-box {
  background: var(--bg-hover);
  border-color: var(--border);
}
.light-mode .premium-search-box input {
  color: var(--text-heading);
}
.light-mode .action-btn-circle {
  background: var(--bg-hover);
  border-color: var(--border);
  color: var(--text);
}
.light-mode .action-btn-circle:hover {
  color: var(--text-heading);
}
.light-mode .glass-glow-card,
.light-mode .premium-card {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  box-shadow: 0 1px 3px rgba(44,48,73,0.04) !important;
  backdrop-filter: none !important;
}
.light-mode td[style*="color:#fff"],
.light-mode td[style*="color: #fff"],
.light-mode strong[style*="color:#fff"],
.light-mode strong[style*="color: #fff"] {
  color: var(--text-heading) !important;
}
.light-mode .badge[style*="#6366f1"],
.light-mode .badge[style*="#a5b4fc"],
.light-mode .badge[style*="#a78bfa"] {
  background: rgba(122,82,153,0.12) !important;
  color: #6b3f87 !important;
  border-color: rgba(122,82,153,0.25) !important;
}
.sf-badge-primary {
  background: rgba(122,82,153,0.12);
  color: #6b3f87;
  border: 1px solid rgba(122,82,153,0.25);
}
.sf-badge-success {
  background: rgba(22,163,74,0.12);
  color: #15803d;
  border: 1px solid rgba(22,163,74,0.25);
}
.sf-badge-warning {
  background: rgba(226,149,53,0.14);
  color: #b45309;
  border: 1px solid rgba(226,149,53,0.30);
}
.sf-badge-danger {
  background: rgba(220,38,38,0.10);
  color: #dc2626;
  border: 1px solid rgba(220,38,38,0.25);
}
.sf-badge-muted {
  background: rgba(100,116,139,0.12);
  color: #475569;
  border: 1px solid rgba(100,116,139,0.25);
}

/* Light-mode safety for remaining form shells */
.light-mode .aurora-bg-container {
  background: linear-gradient(135deg, rgba(122,82,153,0.06), rgba(226,149,53,0.05));
  border-color: var(--border);
  box-shadow: 0 8px 24px rgba(44,48,73,0.06);
}
.light-mode .course-form-tabs {
  background: var(--bg-hover) !important;
  border-color: var(--border) !important;
}
.light-mode .file-drop-zone,
.light-mode .access-card {
  border-color: var(--border) !important;
  background: var(--bg-card) !important;
}

/* ── Admin bulk delete (shared) ─────────────────────────────────────────── */
.admin-bulk-check-col {
  width: 44px;
  text-align: center;
  vertical-align: middle;
}
.admin-bulk-check-col input[type="checkbox"],
.admin-bulk-row {
  width: 16px;
  height: 16px;
  accent-color: var(--primary, #7A5299);
  cursor: pointer;
}
.admin-bulk-bar {
  display: none;
  position: sticky;
  bottom: 18px;
  z-index: 45;
  margin-top: 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-radius: var(--radius-lg, 16px);
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-color, rgba(44,48,73,0.12));
  box-shadow: 0 10px 28px rgba(44, 48, 73, 0.12);
}
.admin-bulk-bar.visible { display: flex; }
.admin-bulk-bar .admin-bulk-count {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main, #2C3049);
}
.admin-bulk-bar .admin-bulk-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.admin-bulk-bar .admin-bulk-clear {
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--border-color, rgba(44,48,73,0.12));
  background: transparent;
  color: var(--text-main, #2C3049);
  font-weight: 700;
  cursor: pointer;
}
.admin-bulk-bar .admin-bulk-delete-btn {
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-md, 10px);
  border: none;
  background: #dc2626;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.admin-bulk-bar .admin-bulk-delete-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.admin-bulk-bar .admin-bulk-delete-btn:hover:not(:disabled) {
  background: #b91c1c;
}

#admin-bulk-confirm-backdrop,
#admin-bulk-confirm-backdrop:not(.open) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  position: fixed !important;
  inset: 0;
  z-index: 9999;
  opacity: 0 !important;
}
#admin-bulk-confirm-backdrop:not(.open) #admin-bulk-confirm-modal {
  display: none !important;
}
#admin-bulk-confirm-backdrop.open {
  display: flex !important;
  visibility: visible !important;
  pointer-events: auto !important;
  opacity: 1 !important;
  background: rgba(44, 48, 73, 0.45);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#admin-bulk-confirm-modal {
  width: min(480px, 100%);
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-color, rgba(44,48,73,0.12));
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 20px 48px rgba(44, 48, 73, 0.2);
  padding: 22px;
}
#admin-bulk-confirm-modal h3 {
  margin: 0 0 8px;
  font-family: var(--font-heading, Almarai, Cairo, sans-serif);
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main, #2C3049);
  display: flex;
  align-items: center;
  gap: 8px;
}
#admin-bulk-confirm-modal .admin-bulk-confirm-hint {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted, rgba(44,48,73,0.65));
  font-weight: 600;
}
#admin-bulk-confirm-modal .admin-bulk-confirm-count {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.2);
  font-size: 13px;
  font-weight: 800;
  color: #b91c1c;
}
#admin-bulk-confirm-modal .admin-bulk-confirm-typewrap {
  display: none;
  margin-bottom: 14px;
}
#admin-bulk-confirm-modal .admin-bulk-confirm-typewrap.visible { display: block; }
#admin-bulk-confirm-modal .admin-bulk-confirm-typewrap label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main, #2C3049);
}
#admin-bulk-confirm-modal .admin-bulk-confirm-typewrap input {
  width: 100%;
  height: 40px;
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--border-color, rgba(44,48,73,0.12));
  background: var(--bg-page, #F8F9FA);
  padding: 0 12px;
  font-weight: 700;
}
#admin-bulk-confirm-modal .admin-bulk-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
#admin-bulk-confirm-modal .admin-bulk-confirm-cancel {
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--border-color, rgba(44,48,73,0.12));
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}
#admin-bulk-confirm-modal .admin-bulk-confirm-ok {
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-md, 10px);
  border: none;
  background: #dc2626;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
#admin-bulk-confirm-modal .admin-bulk-confirm-ok:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Student reviews management ─────────────────────────────────────────── */
.reviews-card {
  overflow: hidden;
}
.reviews-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.reviews-table {
  min-width: 980px;
}
.reviews-table th,
.reviews-table td {
  background-clip: padding-box;
}
.reviews-actions-head,
.reviews-actions-cell {
  position: sticky;
  inset-inline-end: 0;
  min-width: 205px;
  width: 205px;
  text-align: center;
  border-inline-start: 1px solid var(--border);
}
.reviews-actions-head {
  z-index: 4;
  background: var(--bg-hover) !important;
  box-shadow: -8px 0 16px rgba(44, 48, 73, 0.04);
}
.reviews-actions-cell {
  z-index: 2;
  background: var(--bg-card);
  box-shadow: -8px 0 16px rgba(44, 48, 73, 0.04);
}
.reviews-table tbody tr:hover .reviews-actions-cell {
  background: var(--bg-card);
}
.reviews-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.reviews-actions form {
  margin: 0;
}
.review-action {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}
.review-action i,
.review-action svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.review-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(44, 48, 73, 0.09);
}
.review-action:focus-visible {
  outline: 3px solid var(--primary-bg);
  outline-offset: 2px;
}
.review-action-publish {
  color: var(--success);
  background: var(--success-bg);
  border-color: rgba(34, 197, 94, 0.22);
}
.review-action-unpublish {
  color: var(--warning);
  background: var(--warning-bg);
  border-color: rgba(245, 158, 11, 0.24);
}
.review-action-reject,
.review-action-delete {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(239, 68, 68, 0.2);
}
.review-action-delete {
  width: 34px;
  padding: 0;
}
.review-action-delete span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 768px) {
  .reviews-actions-head,
  .reviews-actions-cell {
    position: static;
    width: auto;
    min-width: 0;
    border-inline-start: none;
    box-shadow: none;
  }
  .reviews-table {
    min-width: 0;
  }
  .reviews-actions {
    justify-content: flex-start;
  }
}
@media (prefers-reduced-motion: reduce) {
  .review-action {
    transition: none;
  }
  .review-action:hover {
    transform: none;
  }
}

/* ── Page wave reveal (theme + language circular expand from toggles) ──
   Matches the student frontend: View Transitions API + clip-path circle.
   Cross-document navigations (language ?lang=) opt into same-origin MPA VT. */
@view-transition {
  navigation: auto;
}

::view-transition-group(root) {
  background-color: var(--bg, #0a0e1a);
}
html.light-mode::view-transition-group(root) {
  background-color: var(--bg, #F8F9FA);
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(root) {
  z-index: 1;
}

::view-transition-new(root) {
  z-index: 2147483646;
}

html.page-wave-active,
html.theme-wave-active {
  overflow-y: scroll !important;
  scrollbar-gutter: stable !important;
}

html.theme-wave-active *,
html.theme-wave-active *::before,
html.theme-wave-active *::after,
html.page-wave-active *,
html.page-wave-active *::before,
html.page-wave-active *::after {
  transition: none !important;
}

html.page-wave-active #theme-toggle,
html.page-wave-active #lang-toggle,
html.page-wave-active a.lang-btn,
html.theme-wave-active #theme-toggle {
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }

  @view-transition {
    navigation: none;
  }
}

/* ===== ULTIMATE UNIVERSAL MOBILE RESPONSIVENESS (ADMIN & TEACHER PANELS) ===== */
@media (max-width: 991px) {
  .admin-header {
    padding: 10px 16px !important;
    gap: 10px !important;
  }
  .admin-header > div:first-child {
    flex-wrap: wrap;
    gap: 8px;
  }
  .admin-header h1 {
    font-size: 16px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
  }
  .admin-header .badge {
    margin: 0 !important;
    font-size: 11px !important;
    padding: 4px 8px !important;
  }
}

@media (max-width: 768px) {
  /* Padding & Spacing */
  .admin-content {
    padding: 14px 12px !important;
  }
  .card, .premium-card {
    padding: 16px 14px !important;
    border-radius: 14px !important;
  }

  /* Universal Form Input & Select Touch Enhancements */
  input[type="text"], input[type="number"], input[type="password"], input[type="email"], select, textarea {
    font-size: 15px !important;
    min-height: 44px !important;
    touch-action: manipulation;
  }

  /* Select2 Mobile Polish */
  .select2-container--default .select2-selection--single {
    height: 44px !important;
  }
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 42px !important;
    font-size: 14px !important;
  }

  /* Universal Button Stacking — only known action bars, not every flex-end row */
  .form-actions, .actions-bar {
    flex-direction: column !important;
    width: 100% !important;
    gap: 10px !important;
  }
  .form-actions .btn, .actions-bar .btn {
    width: 100% !important;
    justify-content: center !important;
    min-height: 44px !important;
  }

  /* Universal Grid Collapse for known grid helper classes */
  .grid-2col, .grid-3col, .grid-4col {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  /* Modals Full Mobile Width */
  .modal-dialog, .swal2-popup {
    width: 95% !important;
    max-width: 95vw !important;
    margin: 10px auto !important;
    padding: 16px !important;
    border-radius: 16px !important;
  }

  /* Mobile Tables Horizontal Momentum Scroll */
  .table-wrapper, .table-responsive {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Mobile Drawer Sidebar Backdrop */
  .admin-sidebar {
    width: 280px !important;
  }
}

@media (max-width: 480px) {
  .admin-header h1 {
    font-size: 14px !important;
    max-width: 160px;
  }
  .btn {
    font-size: 13px !important;
    padding: 8px 12px !important;
  }
}

/* ===== STAT CARDS CONTRAST & MOBILE HEADER FIX ===== */
.stat-value {
  font-size: 26px !important;
  font-weight: 900 !important;
  line-height: 1.2 !important;
  background: none !important;
  -webkit-background-clip: initial !important;
  -webkit-text-fill-color: initial !important;
  color: var(--text-heading, #0f172a) !important;
}

/* Light mode stat cards override */
html.light-mode .stat-value,
body.light-mode .stat-value,
.light-mode .stat-value,
html:not(.dark-mode) .stat-value {
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
}

html.light-mode .stat-card,
body.light-mode .stat-card,
.light-mode .stat-card,
html:not(.dark-mode) .stat-card {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.04) !important;
}

/* Dark mode stat cards override */
html.dark-mode .stat-value,
body.dark-mode .stat-value,
.dark-mode .stat-value {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

html.dark-mode .stat-card,
body.dark-mode .stat-card,
.dark-mode .stat-card {
  background: rgba(26, 34, 53, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* Mobile Stat Card Layout Fix */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .stat-card {
    padding: 16px 18px !important;
    border-radius: 16px !important;
  }

  .stat-value {
    font-size: 22px !important;
    margin-bottom: 2px !important;
  }

  .stat-label {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: var(--text-muted) !important;
  }

  .stat-trend {
    font-size: 12px !important;
    font-weight: 700 !important;
  }
}

/* Slim Single-Row Mobile Header (56px) */
@media (max-width: 768px) {
  .admin-header {
    height: 56px !important;
    min-height: 56px !important;
    max-height: 56px !important;
    padding: 0 10px !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 6px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08) !important;
    overflow: visible !important;
  }

  .admin-header > div:first-child {
    flex-wrap: nowrap !important;
    gap: 6px !important;
    overflow: hidden !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: none !important;
    width: auto !important;
  }

  .admin-header h1 {
    font-size: 14px !important;
    font-weight: 800 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin: 0 !important;
    line-height: 1.2 !important;
    max-width: min(42vw, 160px) !important;
  }

  /* Hide long teacher/admin text badge inside 56px mobile header */
  .admin-header .badge {
    display: none !important;
  }

  .admin-header > div:last-child {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    width: auto !important;
    max-width: none !important;
    gap: 4px !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
  }

  #theme-toggle {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    padding: 0 !important;
  }

  #lang-toggle {
    padding: 0 8px !important;
    font-size: 11px !important;
    height: 34px !important;
    min-width: 0 !important;
    border-radius: 10px !important;
    line-height: 1 !important;
  }

  #lang-toggle #lang-toggle-text {
    max-width: 4.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Cache purge: icon-only on phones to keep one header row */
  .purge-cache-btn,
  #purge-cache-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    padding: 0 !important;
    border-radius: 10px !important;
    justify-content: center !important;
  }
  .purge-cache-btn .purge-cache-label,
  #purge-cache-btn .purge-cache-label {
    display: none !important;
  }

  .header-user-name-desktop {
    display: none !important;
  }
  .header-user-btn {
    padding: 2px 4px !important;
    height: 34px !important;
    min-width: 34px !important;
  }
  .header-user-btn .header-user-chevron,
  .header-user-btn #header-user-chevron {
    display: none !important;
  }
  .header-avatar-circle {
    width: 26px !important;
    height: 26px !important;
  }

  .sidebar-toggle {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
  }

  /* Shared page hero: stack cleanly */
  .sf-hero {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 14px 14px !important;
    gap: 12px !important;
    margin-bottom: 14px !important;
  }
  .sf-hero h2 {
    font-size: 17px !important;
  }
  .sf-hero p {
    font-size: 12.5px !important;
    max-width: none !important;
  }
  .sf-hero-actions {
    width: 100% !important;
  }
  .sf-hero-actions .btn,
  .sf-hero-actions .sf-btn-cta,
  .sf-hero-actions a {
    width: 100% !important;
    justify-content: center !important;
  }

  .admin-content {
    padding: 12px 10px 28px !important;
  }
  .card, .premium-card, .settings-section-card {
    padding: 14px 12px !important;
    border-radius: 14px !important;
  }
}

/* ===== GALAXY UI 3.0 HEADER USER DROPDOWN ===== */
.header-user-wrapper {
  position: relative;
}

/* Header action cluster: cache / theme / lang / profile — theme-aware contrast */
.purge-cache-btn,
#purge-cache-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(226, 149, 53, 0.55) !important;
  background: rgba(226, 149, 53, 0.16) !important;
  color: var(--accent-cta) !important;
  cursor: pointer;
  transition: var(--transition);
}
.purge-cache-btn:hover,
#purge-cache-btn:hover {
  background: rgba(226, 149, 53, 0.28) !important;
  border-color: var(--accent-cta) !important;
  color: #fff !important;
}
.purge-cache-btn i,
#purge-cache-btn i {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  color: inherit;
}

.header-theme-btn,
#theme-toggle {
  position: relative;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0 !important;
  border-radius: 50%;
  border: 1px solid var(--border) !important;
  background: var(--bg-card) !important;
  color: var(--text-heading) !important;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  line-height: 0;
  overflow: hidden;
}
.header-theme-btn:hover,
#theme-toggle:hover {
  background: var(--bg-hover) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}
/* Absolute center — defeats global Lucide margin-left: 8px */
.header-theme-btn i,
.header-theme-btn svg,
.header-theme-btn .lucide,
#theme-toggle i,
#theme-toggle svg,
#theme-toggle .lucide {
  position: absolute !important;
  inset: 0 !important;
  width: 16px !important;
  height: 16px !important;
  margin: auto !important;
  padding: 0 !important;
  display: block !important;
  flex-shrink: 0;
  stroke: currentColor;
  color: inherit;
  transform: none !important;
}
#theme-toggle-sun {
  display: none !important;
}
html.light-mode #theme-toggle-sun,
body.light-mode #theme-toggle-sun {
  display: block !important;
}
html.light-mode #theme-toggle-moon,
body.light-mode #theme-toggle-moon {
  display: none !important;
}
html.dark-mode #theme-toggle-sun,
body.dark-mode #theme-toggle-sun {
  display: none !important;
}
html.dark-mode #theme-toggle-moon,
body.dark-mode #theme-toggle-moon {
  display: block !important;
}

.header-lang-btn,
#lang-toggle {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border) !important;
  background: var(--bg-card) !important;
  color: var(--text-heading) !important;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}
.header-lang-btn:hover,
#lang-toggle:hover {
  border-color: var(--primary) !important;
  background: var(--primary-bg) !important;
  color: var(--text-heading) !important;
}
.header-lang-btn i,
#lang-toggle i {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  color: inherit;
}

.header-user-btn {
  display: flex !important;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border) !important;
  background: var(--bg-card) !important;
  color: var(--text-heading) !important;
  cursor: pointer;
  transition: var(--transition);
}
.header-user-btn:hover {
  border-color: var(--primary) !important;
  background: var(--bg-hover) !important;
}
.header-user-name-desktop {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-heading) !important;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-user-chevron,
#header-user-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted) !important;
  stroke: currentColor;
  transition: transform 0.2s ease;
}
.header-avatar-circle {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-cta));
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
  line-height: 0;
  overflow: hidden;
}
/* Absolute center — defeats global Lucide margin-left */
.header-avatar-circle i,
.header-avatar-circle svg,
.header-avatar-circle .lucide {
  position: absolute !important;
  inset: 0 !important;
  width: 14px !important;
  height: 14px !important;
  margin: auto !important;
  padding: 0 !important;
  display: block !important;
  flex-shrink: 0;
  stroke: currentColor;
  color: inherit;
  transform: none !important;
}

/* Dark mode: ensure header chips stay high-contrast (never white-on-white / navy-on-navy) */
html.dark-mode .purge-cache-btn,
body.dark-mode .purge-cache-btn,
html.dark-mode #purge-cache-btn,
body.dark-mode #purge-cache-btn {
  background: rgba(226, 149, 53, 0.22) !important;
  border-color: rgba(226, 149, 53, 0.7) !important;
  color: #f6c078 !important;
}
html.dark-mode .header-theme-btn,
html.dark-mode #theme-toggle,
body.dark-mode .header-theme-btn,
body.dark-mode #theme-toggle,
html.dark-mode .header-lang-btn,
html.dark-mode #lang-toggle,
body.dark-mode .header-lang-btn,
body.dark-mode #lang-toggle,
html.dark-mode .header-user-btn,
body.dark-mode .header-user-btn {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  color: #f1f5f9 !important;
}
html.dark-mode .header-user-name-desktop,
body.dark-mode .header-user-name-desktop {
  color: #f8fafc !important;
}
html.dark-mode .header-user-chevron,
html.dark-mode #header-user-chevron,
body.dark-mode .header-user-chevron,
body.dark-mode #header-user-chevron {
  color: #94a3b8 !important;
}
html.dark-mode .header-lang-btn:hover,
html.dark-mode #lang-toggle:hover,
body.dark-mode .header-lang-btn:hover,
body.dark-mode #lang-toggle:hover,
html.dark-mode .header-theme-btn:hover,
html.dark-mode #theme-toggle:hover,
body.dark-mode .header-theme-btn:hover,
body.dark-mode #theme-toggle:hover,
html.dark-mode .header-user-btn:hover,
body.dark-mode .header-user-btn:hover {
  background: rgba(122, 82, 153, 0.28) !important;
  border-color: rgba(143, 99, 173, 0.7) !important;
  color: #ffffff !important;
}

.header-user-dropdown {
  display: none;
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
  z-index: 999999 !important;
  padding: 14px;
  direction: rtl;
}

html.dark-mode .header-user-dropdown,
body.dark-mode .header-user-dropdown {
  background: rgba(15, 23, 42, 0.96) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.6) !important;
}

.header-user-dropdown.show {
  display: block !important;
  opacity: 1 !important;
  transform: translateY(0) scale(1) !important;
  pointer-events: auto !important;
}

.header-user-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}

html.dark-mode .header-user-card-head {
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

.header-user-avatar-lg {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary, #3b82f6), #8b5cf6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  flex-shrink: 0;
}

.header-user-meta {
  flex: 1;
  min-width: 0;
}

.header-user-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-heading, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html.dark-mode .header-user-title {
  color: #f8fafc !important;
}

.header-user-role-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary, #3b82f6);
  margin-top: 2px;
}

.header-user-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text, #334155);
  text-decoration: none;
  transition: all 0.2s ease;
  margin-bottom: 8px;
}

.header-user-nav-link:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary, #3b82f6);
}

html.dark-mode .header-user-nav-link {
  color: #cbd5e1 !important;
}

html.dark-mode .header-user-nav-link:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
}

.btn-header-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff !important;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
  transition: all 0.2s ease;
}

.btn-header-logout:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.5);
}

/* ============================================================
   LTR (English Mode) Sidebar & Page Layout Rules
   When dir="ltr" or .mode-ltr is active, sidebar MUST move to Left (left:0)
   and main area MUST take margin-left: var(--sidebar-width)
   ============================================================ */
html[dir="ltr"] .admin-sidebar,
body[dir="ltr"] .admin-sidebar,
.mode-ltr .admin-sidebar,
[dir="ltr"] .admin-sidebar {
  right: auto !important;
  left: 0 !important;
  border-left: none !important;
  border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
}

html[dir="ltr"] .admin-main,
body[dir="ltr"] .admin-main,
.mode-ltr .admin-main,
[dir="ltr"] .admin-main {
  margin-right: 0 !important;
  margin-left: var(--sidebar-width) !important;
}

/* Light mode LTR sidebar border */
body.light-mode[dir="ltr"] .admin-sidebar,
html.light-mode[dir="ltr"] .admin-sidebar,
.light-mode.mode-ltr .admin-sidebar {
  border-right: 1px solid #e2e8f0 !important;
  border-left: none !important;
}

/* Header layout direction in LTR */
html[dir="ltr"] .admin-header,
body[dir="ltr"] .admin-header,
[dir="ltr"] .admin-header {
  direction: ltr !important;
}

/* Mobile Sidebar Drawer in LTR */
@media (max-width: 1024px) {
  html[dir="ltr"] .admin-sidebar,
  body[dir="ltr"] .admin-sidebar,
  .mode-ltr .admin-sidebar,
  [dir="ltr"] .admin-sidebar {
    transform: translateX(-100%) !important;
    left: 0 !important;
    right: auto !important;
  }
  html[dir="ltr"] .admin-sidebar.open,
  body[dir="ltr"] .admin-sidebar.open,
  .mode-ltr .admin-sidebar.open,
  [dir="ltr"] .admin-sidebar.open {
    transform: translateX(0) !important;
  }
  html[dir="ltr"] .admin-main,
  body[dir="ltr"] .admin-main,
  .mode-ltr .admin-main,
  [dir="ltr"] .admin-main {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* Detailed Sidebar Nav Elements Direction in LTR */
html[dir="ltr"] .admin-sidebar,
body[dir="ltr"] .admin-sidebar,
.mode-ltr .admin-sidebar {
  direction: ltr !important;
  text-align: left !important;
}

html[dir="ltr"] .sidebar-brand,
body[dir="ltr"] .sidebar-brand,
.mode-ltr .sidebar-brand {
  flex-direction: row !important;
  text-align: left !important;
}

html[dir="ltr"] .nav-link,
body[dir="ltr"] .nav-link,
.mode-ltr .nav-link {
  flex-direction: row !important;
  text-align: left !important;
  gap: 12px !important;
}

html[dir="ltr"] .nav-dropdown-toggle,
body[dir="ltr"] .nav-dropdown-toggle,
.mode-ltr .nav-dropdown-toggle {
  flex-direction: row !important;
  justify-content: space-between !important;
}

html[dir="ltr"] .nav-dropdown-toggle .toggle-content,
body[dir="ltr"] .nav-dropdown-toggle .toggle-content,
.mode-ltr .nav-dropdown-toggle .toggle-content {
  flex-direction: row !important;
  gap: 12px !important;
}

html[dir="ltr"] .nav-dropdown-toggle .toggle-content i[data-lucide],
body[dir="ltr"] .nav-dropdown-toggle .toggle-content i[data-lucide],
.mode-ltr .nav-dropdown-toggle .toggle-content i[data-lucide] {
  margin-left: 0 !important;
  margin-right: 8px !important;
}

html[dir="ltr"] .nav-dropdown-toggle .chevron-icon,
body[dir="ltr"] .nav-dropdown-toggle .chevron-icon,
.mode-ltr .nav-dropdown-toggle .chevron-icon {
  margin-left: auto !important;
  margin-right: 0 !important;
}

html[dir="ltr"] .nav-dropdown-menu,
body[dir="ltr"] .nav-dropdown-menu,
.mode-ltr .nav-dropdown-menu {
  border-right: none !important;
  border-left: 1.5px solid rgba(255, 255, 255, 0.08) !important;
  margin-right: 0 !important;
  margin-left: 24px !important;
  padding-right: 0 !important;
  padding-left: 8px !important;
}

html[dir="ltr"] .nav-dropdown-link,
body[dir="ltr"] .nav-dropdown-link,
.mode-ltr .nav-dropdown-link {
  flex-direction: row !important;
  text-align: left !important;
  gap: 8px !important;
}

html[dir="ltr"] .nav-dropdown-link .sub-nav-icon,
body[dir="ltr"] .nav-dropdown-link .sub-nav-icon,
.mode-ltr .nav-dropdown-link .sub-nav-icon {
  margin-left: 0 !important;
  margin-right: 8px !important;
}

html[dir="ltr"] .sidebar-user,
body[dir="ltr"] .sidebar-user,
.mode-ltr .sidebar-user {
  flex-direction: row !important;
  text-align: left !important;
}

html[dir="ltr"] .sidebar-user .user-info,
body[dir="ltr"] .sidebar-user .user-info,
.mode-ltr .sidebar-user .user-info {
  text-align: left !important;
}

/* Ensure Select2 dropdowns and modal country dropdowns always have highest z-index */
.select2-container--open,
.select2-dropdown,
.select2-container--default .select2-dropdown {
  z-index: 9999999 !important;
}

/* ===== Final mobile safety net (admin + teacher share this layout) ===== */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
  }
  .admin-layout,
  .admin-main,
  .admin-content {
    max-width: 100vw;
    min-width: 0;
  }
  .table-wrapper,
  .table-responsive,
  .dashboard-tabs,
  .settings-tabs-bar {
    max-width: 100% !important;
  }

  /* Light mode: mobile table-cards / cards must match desktop light surfaces */
  .light-mode .table-wrapper tr,
  html.light-mode .table-wrapper tr,
  body.light-mode .table-wrapper tr {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(44, 48, 73, 0.06) !important;
    color: #334155 !important;
  }
  .light-mode .table-wrapper td,
  html.light-mode .table-wrapper td,
  body.light-mode .table-wrapper td {
    color: #334155 !important;
    border-bottom-color: #e2e8f0 !important;
    background: transparent !important;
  }
  .light-mode .table-wrapper td::before,
  html.light-mode .table-wrapper td::before,
  body.light-mode .table-wrapper td::before {
    color: #64748b !important;
  }
  .light-mode .card,
  .light-mode .sf-card,
  .light-mode .premium-card,
  .light-mode .stat-card,
  html.light-mode .card,
  html.light-mode .sf-card,
  html.light-mode .stat-card {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(44, 48, 73, 0.06) !important;
    color: #334155 !important;
  }
  .light-mode .stat-value,
  html.light-mode .stat-value {
    color: #2C3049 !important;
    -webkit-text-fill-color: #2C3049 !important;
    background: none !important;
  }
  .light-mode .sf-table tbody td,
  html.light-mode .sf-table tbody td {
    color: #334155 !important;
  }
  .light-mode .admin-header,
  html.light-mode .admin-header {
    background: rgba(255, 255, 255, 0.92) !important;
    border-bottom-color: #e2e8f0 !important;
  }
}

.light-mode .builder-wrapper .section-card-premium,
.light-mode .builder-wrapper .panel-card-premium,
.light-mode .builder-wrapper .stat-card-premium,
.light-mode .builder-wrapper .modal-content-premium,
.light-mode .builder-wrapper .custom-confirm-modal,
.light-mode .builder-wrapper .builder-table-wrap {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
  box-shadow: var(--shadow);
}

.light-mode .builder-wrapper .q-table-premium th {
  background: var(--bg-hover);
  color: var(--text-heading);
  border-bottom-color: var(--border);
}

.light-mode .builder-wrapper .q-table-premium td {
  color: var(--text);
  border-bottom-color: var(--border);
}

.light-mode .builder-wrapper .form-control-premium {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color: var(--text-heading) !important;
}


/* ==================== Credit offer cards + toggles ==================== */
.credit-offer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 992px) {
  .credit-offer-grid { grid-template-columns: 1fr !important; }
}
.credit-offer-card {
  border: 1px solid var(--border-color, rgba(44,48,73,0.12));
  border-radius: var(--radius-md, 10px);
  padding: 14px;
  background: var(--bg-card, #fff);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}
.credit-offer-card.is-unified {
  border-color: rgba(122, 82, 153, 0.28);
  background: rgba(122, 82, 153, 0.06);
}
.credit-offer-card.is-enabled {
  box-shadow: 0 8px 24px rgba(44, 48, 73, 0.06);
  border-color: rgba(122, 82, 153, 0.45);
}
.credit-offer-card.is-disabled {
  opacity: 0.72;
  background: rgba(44, 48, 73, 0.03);
}
.credit-offer-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.credit-offer-card-head strong {
  font-size: 14px;
  color: var(--primary, #7A5299);
  line-height: 1.35;
}
.credit-offer-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.credit-offer-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.credit-offer-switch-track {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(44, 48, 73, 0.18);
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.credit-offer-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(44, 48, 73, 0.25);
  transition: transform 0.2s ease;
}
.credit-offer-switch input:checked + .credit-offer-switch-track {
  background: var(--accent-cta, #E29535);
}
.credit-offer-switch input:checked + .credit-offer-switch-track::after {
  transform: translateX(18px);
}
[dir="rtl"] .credit-offer-switch input:checked + .credit-offer-switch-track::after,
html[dir="rtl"] .credit-offer-switch input:checked + .credit-offer-switch-track::after {
  transform: translateX(-18px);
}
.credit-offer-switch-text {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  white-space: nowrap;
}
.credit-offer-switch input:checked ~ .credit-offer-switch-text {
  color: var(--accent-cta, #E29535);
}
.credit-offer-card.is-disabled .credit-offer-body {
  pointer-events: none;
}
.credit-offer-card.is-disabled .form-input,
.credit-offer-card.is-disabled .numeric-stepper {
  opacity: 0.55;
}
