/* ═══════════════════════════════════════════════════════════════
   Control Room Academy — Design System
   Professional & Corporate Theme
   Dark / Light modes + RTL / LTR support
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Noto+Sans+Arabic:wght@300;400;500;600;700;800;900&display=swap');

/* ── Root Variables ───────────────────────────────────────── */
:root {
  /* Brand */
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-300: #93c5fd;
  --brand-400: #60a5fa;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-800: #1e40af;
  --brand-900: #1e3a8a;

  /* Semantic */
  --success:   #16a34a;
  --success-bg:#f0fdf4;
  --warning:   #d97706;
  --warning-bg:#fffbeb;
  --danger:    #dc2626;
  --danger-bg: #fef2f2;
  --info:      #0891b2;
  --info-bg:   #ecfeff;

  /* Radius */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;
  --r-2xl: 28px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.12);
  --shadow-xl:  0 16px 40px rgba(0,0,0,0.16);

  /* Transitions */
  --t-fast:   0.15s ease;
  --t-normal: 0.25s ease;
  --t-slow:   0.4s ease;

  /* Fonts */
  --font-en: 'Inter', system-ui, sans-serif;
  --font-ar: 'Noto Sans Arabic', 'Segoe UI', system-ui, sans-serif;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
}

/* ── Dark Theme (Default) ─────────────────────────────────── */
[data-theme="dark"], :root {
  --bg:         #07090f;
  --bg-2:       #0d1117;
  --bg-3:       #111827;
  --bg-4:       #1f2937;
  --bg-hover:   rgba(255,255,255,0.04);
  --bg-active:  rgba(59,130,246,0.08);

  --border:     rgba(255,255,255,0.08);
  --border-2:   rgba(255,255,255,0.12);
  --border-focus: var(--brand-500);

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary:  #64748b;
  --text-disabled:  #475569;
  --text-inverse:   #0f172a;

  --primary:     var(--brand-500);
  --primary-hover: var(--brand-400);
  --primary-text: #fff;

  --card-bg:     var(--bg-2);
  --card-border: var(--border);
  --card-shadow: 0 2px 8px rgba(0,0,0,0.4);

  --sidebar-bg:  var(--bg-2);
  --topbar-bg:   rgba(7,9,15,0.85);

  --input-bg:    rgba(255,255,255,0.04);
  --input-border: var(--border);
  --input-text:  var(--text-primary);

  --overlay:     rgba(0,0,0,0.7);

  --badge-blue-bg:   rgba(59,130,246,0.12);
  --badge-blue-text: #93c5fd;
  --badge-green-bg:  rgba(22,163,74,0.12);
  --badge-green-text:#86efac;
  --badge-red-bg:    rgba(220,38,38,0.12);
  --badge-red-text:  #fca5a5;
  --badge-yellow-bg: rgba(217,119,6,0.12);
  --badge-yellow-text:#fcd34d;
  --badge-gray-bg:   rgba(255,255,255,0.06);
  --badge-gray-text: var(--text-secondary);

  --scrollbar-thumb: rgba(255,255,255,0.1);
  --scrollbar-track: transparent;
}

/* ── Light Theme ─────────────────────────────────────────── */
[data-theme="light"] {
  --bg:         #f8fafc;
  --bg-2:       #ffffff;
  --bg-3:       #f1f5f9;
  --bg-4:       #e2e8f0;
  --bg-hover:   rgba(0,0,0,0.03);
  --bg-active:  rgba(59,130,246,0.06);

  --border:     rgba(0,0,0,0.08);
  --border-2:   rgba(0,0,0,0.12);
  --border-focus: var(--brand-600);

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-tertiary:  #94a3b8;
  --text-disabled:  #cbd5e1;
  --text-inverse:   #f1f5f9;

  --primary:      var(--brand-600);
  --primary-hover: var(--brand-700);
  --primary-text: #fff;

  --card-bg:     #ffffff;
  --card-border: rgba(0,0,0,0.07);
  --card-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);

  --sidebar-bg:  #1e3a8a;
  --topbar-bg:   rgba(248,250,252,0.9);

  --input-bg:    #ffffff;
  --input-border: rgba(0,0,0,0.12);
  --input-text:  #0f172a;

  --overlay:     rgba(0,0,0,0.5);

  --badge-blue-bg:   #dbeafe;
  --badge-blue-text: #1d4ed8;
  --badge-green-bg:  #dcfce7;
  --badge-green-text:#15803d;
  --badge-red-bg:    #fee2e2;
  --badge-red-text:  #b91c1c;
  --badge-yellow-bg: #fef3c7;
  --badge-yellow-text:#92400e;
  --badge-gray-bg:   #f1f5f9;
  --badge-gray-text: #475569;

  --scrollbar-thumb: rgba(0,0,0,0.15);
  --scrollbar-track: transparent;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-en);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--t-slow), color var(--t-slow);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body[dir="rtl"] { font-family: var(--font-ar); }
body[dir="ltr"] { font-family: var(--font-en); }

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 99px; }

/* ── Typography ─────────────────────────────────────────── */
.text-xs   { font-size: 11px; }
.text-sm   { font-size: 13px; }
.text-base { font-size: 15px; }
.text-lg   { font-size: 17px; }
.text-xl   { font-size: 20px; }
.text-2xl  { font-size: 24px; }
.text-3xl  { font-size: 30px; }
.text-4xl  { font-size: 38px; }
.text-5xl  { font-size: 48px; }

.font-light    { font-weight: 300; }
.font-normal   { font-weight: 400; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.font-extrabold{ font-weight: 800; }
.font-black    { font-weight: 900; }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary  { color: var(--text-tertiary); }
.text-brand     { color: var(--primary); }
.text-success   { color: var(--success); }
.text-danger    { color: var(--danger); }
.text-warning   { color: var(--warning); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--t-normal);
  white-space: nowrap;
  font-family: inherit;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(37,99,235,0.35);
}
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-2);
}
.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
}

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

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(220,38,38,0.2);
}
.btn-danger:hover { background: var(--danger); color: white; }

.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { padding: 13px 28px; font-size: 16px; border-radius: var(--r-lg); }
.btn-xl { padding: 16px 36px; font-size: 17px; border-radius: var(--r-lg); }
.btn-full { width: 100%; }

.btn-loading .btn-text { visibility: hidden; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Form Elements ──────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--input-text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}
.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.form-control::placeholder { color: var(--text-tertiary); }
select.form-control option { background: var(--bg-3); }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-xl);
  box-shadow: var(--card-shadow);
}
.card-body { padding: 24px; }
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 700; }
.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge-blue   { background: var(--badge-blue-bg);   color: var(--badge-blue-text); }
.badge-green  { background: var(--badge-green-bg);  color: var(--badge-green-text); }
.badge-red    { background: var(--badge-red-bg);    color: var(--badge-red-text); }
.badge-yellow { background: var(--badge-yellow-bg); color: var(--badge-yellow-text); }
.badge-gray   { background: var(--badge-gray-bg);   color: var(--badge-gray-text); }

/* ── Alert ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
}
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(220,38,38,0.2); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(22,163,74,0.2); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(217,119,6,0.2); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid rgba(8,145,178,0.2); }

/* ── Table ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  text-align: start;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 13px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-hover); }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn var(--t-fast);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp var(--t-normal);
}
.modal-header {
  padding: 24px 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 18px; font-weight: 800; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: var(--bg-hover);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--t-fast);
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-body { padding: 20px 28px 28px; }

/* ── Spinner / Loading ──────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }
.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ── Divider ────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}
.divider-label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-tertiary);
  font-size: 13px;
  margin: 20px 0;
}
.divider-label::before, .divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Avatar ─────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  background: var(--brand-900);
  color: var(--brand-300);
}
.avatar-sm  { width: 32px; height: 32px; font-size: 13px; }
.avatar-md  { width: 40px; height: 40px; font-size: 15px; }
.avatar-lg  { width: 52px; height: 52px; font-size: 18px; }
.avatar-xl  { width: 72px; height: 72px; font-size: 26px; }

/* ── Topbar Controls (Theme + Lang) ─────────────────────── */
.ctrl-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ctrl-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-md);
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: all var(--t-fast);
}
.ctrl-btn:hover { background: var(--bg-4); color: var(--text-primary); border-color: var(--border-2); }
.ctrl-btn svg { width: 15px; height: 15px; }

/* ── Animations ─────────────────────────────────────────── */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse   { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Utilities ──────────────────────────────────────────── */
.flex   { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.flex-1 { flex: 1; }
.min-w-0 { min-width: 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.mt-auto { margin-top: auto; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .btn-xl { padding: 14px 24px; font-size: 15px; }
}
@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}
