/* ═══════════════════════════════════════════════
   BotForge Design System
   Dark / Light · Arabic / English · Animations
═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&family=Cabinet+Grotesk:wght@300;400;500;700;800;900&display=swap');

/* ── CSS Variables ── */
:root {
  --font-ar: 'Tajawal', sans-serif;
  --font-en: 'Cabinet Grotesk', sans-serif;

  /* Brand */
  --brand:        #FF5C28;
  --brand-dim:    #cc4a20;
  --brand-glow:   rgba(255, 92, 40, 0.18);
  --brand-pale:   rgba(255, 92, 40, 0.08);

  /* Dark mode (default) */
  --bg:           #0C0C0F;
  --bg2:          #131318;
  --bg3:          #1A1A22;
  --surface:      #1E1E28;
  --surface2:     #25252F;
  --surface3:     #2E2E3A;
  --border:       rgba(255,255,255,0.07);
  --border2:      rgba(255,255,255,0.12);
  --ink:          #F0EEF8;
  --ink2:         #A09EB8;
  --ink3:         #5C5A72;
  --green:        #22C55E;
  --green-pale:   rgba(34,197,94,0.1);
  --red:          #EF4444;
  --amber:        #F59E0B;

  /* Shadows */
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.4);
  --shadow:       0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:    0 20px 60px rgba(0,0,0,0.6);
  --shadow-brand: 0 8px 32px rgba(255,92,40,0.25);

  /* Motion */
  --ease:         cubic-bezier(0.34, 1.2, 0.64, 1);
  --ease-out:     cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    16px;
  --radius-xl:    24px;
}

/* ── Light Mode ── */
[data-theme="light"] {
  --bg:           #F8F7FC;
  --bg2:          #F0EEF8;
  --bg3:          #E8E5F5;
  --surface:      #FFFFFF;
  --surface2:     #F4F3FA;
  --surface3:     #EAE8F5;
  --border:       rgba(0,0,0,0.07);
  --border2:      rgba(0,0,0,0.12);
  --ink:          #0D0C1A;
  --ink2:         #4A4860;
  --ink3:         #9896B0;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
  --shadow:       0 4px 20px rgba(0,0,0,0.1);
  --shadow-lg:    0 20px 60px rgba(0,0,0,0.12);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Language-aware font ── */
[lang="ar"], .lang-ar { font-family: var(--font-ar); direction: rtl; }
[lang="en"], .lang-en { font-family: var(--font-en); direction: ltr; }
body { font-family: var(--font-en); }
body.ar { font-family: var(--font-ar); direction: rtl; }

/* ── Grain texture overlay ── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px;
}

/* ── NAVIGATION ── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 5vw;
  background: rgba(12,12,15,0.8);
  backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s;
}
[data-theme="light"] .nav {
  background: rgba(248,247,252,0.85);
}
.nav-logo {
  font-family: var(--font-en);
  font-size: 20px; font-weight: 900;
  color: var(--ink);
  text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.nav-logo .dot { color: var(--brand); }
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-link {
  padding: 7px 14px; border-radius: 99px;
  font-size: 13px; font-weight: 500;
  color: var(--ink2); text-decoration: none;
  transition: all 0.2s; border: none; background: none; cursor: pointer;
  font-family: inherit;
}
.nav-link:hover { color: var(--ink); background: var(--surface2); }
.nav-btn {
  padding: 8px 18px; border-radius: 99px;
  background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 700;
  text-decoration: none; border: none; cursor: pointer;
  transition: all 0.2s; font-family: inherit;
  box-shadow: var(--shadow-brand);
}
.nav-btn:hover { background: var(--brand-dim); transform: translateY(-1px); }
.nav-controls { display: flex; align-items: center; gap: 6px; }

/* Theme toggle */
.theme-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--surface2); color: var(--ink2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: all 0.2s;
}
.theme-btn:hover { background: var(--surface3); color: var(--ink); }

/* Lang toggle */
.lang-btn {
  padding: 6px 12px; border-radius: 99px;
  border: 1px solid var(--border2);
  background: var(--surface2); color: var(--ink2);
  cursor: pointer; font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em; transition: all 0.2s;
  font-family: var(--font-en);
}
.lang-btn:hover { background: var(--surface3); color: var(--ink); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 20px; border-radius: 99px;
  font-size: 14px; font-weight: 700;
  cursor: pointer; border: none; text-decoration: none;
  font-family: inherit; transition: all 0.2s; letter-spacing: -0.01em;
}
.btn-brand {
  background: var(--brand); color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-brand:hover { background: var(--brand-dim); transform: translateY(-2px); box-shadow: 0 12px 40px rgba(255,92,40,0.35); }
.btn-ghost {
  background: var(--surface2); color: var(--ink);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { background: var(--surface3); }
.btn-outline {
  background: transparent; color: var(--brand);
  border: 1.5px solid var(--brand);
}
.btn-outline:hover { background: var(--brand-pale); }
.btn-lg { padding: 14px 32px; font-size: 16px; }
.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: 50%; }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover { border-color: var(--border2); }
.card-hover:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title {
  font-size: 14px; font-weight: 700; color: var(--ink);
}
.card-body { padding: 20px; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.badge-green  { background: var(--green-pale); color: var(--green); }
.badge-brand  { background: var(--brand-pale); color: var(--brand); }
.badge-amber  { background: rgba(245,158,11,0.1); color: var(--amber); }
.badge-red    { background: rgba(239,68,68,0.1); color: var(--red); }
.badge-ghost  { background: var(--surface2); color: var(--ink2); }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 600; color: var(--ink2);
  margin-bottom: 6px; letter-spacing: 0.02em;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 11px 14px;
  background: var(--surface2); border: 1.5px solid var(--border2);
  border-radius: var(--radius); color: var(--ink);
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand); background: var(--surface3);
}
.form-input::placeholder { color: var(--ink3); }
.form-textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 11px; color: var(--ink3); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; display: none; }
.form-error.show { display: block; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink3);
  background: var(--surface2); border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--ink);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
.ar th, .ar td { text-align: right; }

/* ── STAT CARDS ── */
.stat-grid { display: grid; gap: 16px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-label { font-size: 11px; color: var(--ink3); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.stat-val {
  font-family: var(--font-en); font-size: 34px; font-weight: 900;
  color: var(--ink); margin-top: 6px; line-height: 1;
}
.stat-sub { font-size: 12px; color: var(--green); margin-top: 6px; font-weight: 600; }

/* ── TOAST ── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  background: var(--surface3); color: var(--ink);
  border: 1px solid var(--border2);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s var(--ease);
  pointer-events: all;
}
.toast.success { background: var(--green-pale); color: var(--green); border-color: rgba(34,197,94,0.2); }
.toast.error   { background: rgba(239,68,68,0.1); color: var(--red); border-color: rgba(239,68,68,0.2); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.95); } to { opacity: 1; transform: none; } }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl);
  width: 520px; max-width: 100%;
  max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.35s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.94) translateY(12px); } to { opacity: 1; transform: none; } }
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── REVEAL ANIMATIONS ── */
.reveal {
  opacity: 0; transform: translateY(28px);
  transition: opacity 0.65s var(--ease-out), transform 0.65s var(--ease-out);
}
.reveal.delay-1 { transition-delay: 0.1s; }
.reveal.delay-2 { transition-delay: 0.2s; }
.reveal.delay-3 { transition-delay: 0.3s; }
.reveal.delay-4 { transition-delay: 0.4s; }
.reveal.visible { opacity: 1; transform: none; }

/* ── HERO GLOW ── */
.hero-glow {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle, var(--brand-glow), transparent 70%);
  pointer-events: none; z-index: 0;
}

/* ── CODE BLOCK ── */
.code-block {
  background: #0D0C14; border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 16px;
  font-family: 'Courier New', monospace; font-size: 12.5px;
  color: #A8FF78; line-height: 1.7; overflow-x: auto;
  position: relative;
}
.code-copy {
  position: absolute; top: 10px; right: 10px;
  background: var(--surface3); border: 1px solid var(--border2);
  color: var(--ink2); padding: 4px 10px;
  border-radius: var(--radius-sm); font-size: 11px;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.code-copy:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink3); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .nav { padding: 0 16px; }
  .form-row { grid-template-columns: 1fr; }
}

/* ── PROGRESS BAR ── */
.progress { height: 5px; background: var(--surface3); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--brand); border-radius: 99px; transition: width 0.4s var(--ease); }

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

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 44px; margin-bottom: 14px; opacity: 0.6; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.empty-text { font-size: 14px; color: var(--ink2); line-height: 1.65; }

/* ── RTL SUPPORT ── */
body.ar .nav { flex-direction: row-reverse; }
body.ar th { text-align: right; }
body.ar .stat-val { font-family: var(--font-ar); }
