/* ============ فهمولوجي — الهوية الجديدة: الأبيض والأزرق الموثوق (نسخة محسّنة) ============ */
:root {
  --primary: #1a56db;       /* Trust Blue */
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --primary-dark: #16307f;

  --secondary: #f59e0b;     /* Warm Gold */
  --secondary-hover: #d97706;
  --secondary-light: #fef3c7;

  --bg-page: #f6f8fb;       /* خلفية رمادية فاتحة مريحة للعين */
  --bg-card: #ffffff;       /* كروت بيضاء */
  --border: #e2e8f0;
  --border-focus: #93c5fd;

  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --ok: #10b981;
  --ok-bg: #d1fae5;
  --err: #ef4444;
  --err-bg: #fee2e2;

  /* ظلال متدرّجة لعمق بصري أكثر اتساقًا */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.07), 0 1px 2px -1px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 28px -8px rgba(15, 23, 42, 0.18), 0 4px 10px -4px rgba(15, 23, 42, 0.08);

  /* نظام مسافات موحّد */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;

  --ease: cubic-bezier(.4, 0, .2, 1);

  --font-display: "Baloo Bhaijaan 2", sans-serif;
  --font-body: "IBM Plex Sans Arabic", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--font-display); color: var(--text-main); letter-spacing: -.01em; }
h1 { font-size: 1.85rem; margin-bottom: 6px; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 14px; }
.sub { color: var(--text-muted); margin-bottom: 28px; font-size: .95rem; }

a { text-decoration: none; color: var(--primary); transition: color .15s var(--ease); }
a:hover { text-decoration: underline; color: var(--primary-hover); }
:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; border-radius: 6px; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 250px; min-height: 100vh; position: sticky; top: 0;
  background: #ffffff; color: var(--text-main);
  display: flex; flex-direction: column; padding: 24px 18px;
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 32px; text-decoration: none !important; }
.brand strong { font-family: var(--font-display); font-size: 1.35rem; color: var(--text-main); display: block; line-height: 1.1; font-weight: 800; }
.brand small { color: var(--text-muted); font-size: .8rem; font-weight: 500; }
.brand-coin {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-family: var(--font-display); font-weight: 800; font-size: 1.4rem;
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a {
  color: var(--text-muted); text-decoration: none !important; padding: 11px 16px;
  border-radius: 12px; font-size: .95rem; font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
  position: relative;
}
.sidebar nav a:hover { background: var(--bg-page); color: var(--primary); }
.sidebar nav a.on { background: var(--primary-light); color: var(--primary); font-weight: 700; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 20px; }
.whoami { color: var(--text-main); font-weight: 700; font-size: .95rem; margin-bottom: 6px; }
.logout { color: var(--err); font-size: .85rem; font-weight: 500; text-decoration: none !important; transition: background .15s var(--ease); border-radius: 6px; }
.logout:hover { background: var(--err-bg); padding: 4px 8px; margin: -4px -8px; }

/* ---------------- Main ---------------- */
main.with-side { flex: 1; padding: 36px 42px; max-width: 1200px; }
main.solo { flex: 1; display: grid; place-items: center; padding: 30px; }

.flash {
  padding: 14px 20px; border-radius: 12px; margin-bottom: 24px; font-size: .95rem; font-weight: 500;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-xs);
  animation: flash-in .25s var(--ease);
}
.flash.ok  { background: var(--ok-bg); color: #065f46; border: 1px solid #a7f3d0; }
.flash.error { background: var(--err-bg); color: #991b1b; border: 1px solid #fecaca; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------- Cards & stats ---------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 32px; }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-xs); transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card .num { font-family: var(--font-display); font-size: 2.2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.card .lbl { color: var(--text-muted); font-size: .9rem; margin-top: 8px; font-weight: 500; }
.card.gold { background: var(--secondary-light); border-color: #fde68a; }
.card.gold .num { color: #92400e; }
.card.gold .lbl { color: #b45309; }

.panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; margin-bottom: 28px; box-shadow: var(--shadow-xs);
}
.panel h2 { margin-bottom: 18px; }

/* ---------------- Tables ---------------- */
table { width: 100%; border-collapse: collapse; font-size: .95rem; text-align: right; }
th {
  color: var(--text-muted); font-weight: 600; font-size: .82rem; letter-spacing: .02em;
  padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--bg-page);
  position: sticky; top: 0;
}
th:first-child { border-top-right-radius: 10px; } th:last-child { border-top-left-radius: 10px; }
td { padding: 14px; border-bottom: 1px solid var(--border); color: var(--text-main); font-weight: 500; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--bg-page); }

.badge { display: inline-flex; align-items: center; justify-content: center; padding: 4px 12px; border-radius: 99px; font-size: .8rem; font-weight: 600; line-height: 1.4; }
.badge.ok { background: var(--ok-bg); color: #065f46; }
.badge.off { background: #f1f5f9; color: var(--text-muted); }
.badge.gold { background: var(--secondary-light); color: #92400e; }

/* ---------------- Forms ---------------- */
form.stack { display: flex; flex-direction: column; gap: 16px; }
form.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
label { font-size: .88rem; font-weight: 600; color: var(--text-main); display: block; margin-bottom: 6px; }
input, select, textarea {
  font-family: var(--font-body); font-size: .95rem; font-weight: 500;
  padding: 12px 16px; border: 1.5px solid var(--border); border-radius: 12px;
  background: #fff; color: var(--text-main); width: 100%;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { resize: vertical; min-height: 120px; direction: ltr; text-align: left; font-family: monospace; font-size: .9rem; }
textarea.ar { direction: rtl; text-align: right; font-family: var(--font-body); font-size: .95rem; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 4px var(--primary-light); }
input:disabled, select:disabled, textarea:disabled { background: var(--bg-page); color: var(--text-faint); cursor: not-allowed; }
.field { flex: 1; min-width: 180px; }
.field .help { font-size: .8rem; color: var(--text-muted); margin-top: 6px; }

/* ---------------- Buttons ---------------- */
button, .btn {
  font-family: var(--font-display); font-size: 1.02rem; font-weight: 700;
  background: var(--primary); color: #fff; border: 0; border-radius: 12px;
  padding: 12px 28px; cursor: pointer; text-decoration: none !important;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease);
  box-shadow: 0 4px 10px rgba(26, 86, 219, .22);
}
button:hover, .btn:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 8px 16px rgba(26, 86, 219, .3); }
button:active, .btn:active { transform: translateY(0); box-shadow: 0 2px 6px rgba(26, 86, 219, .25); }
button:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.gold { background: var(--secondary); box-shadow: 0 4px 10px rgba(245, 158, 11, .22); }
.btn.gold:hover { background: var(--secondary-hover); box-shadow: 0 8px 16px rgba(245, 158, 11, .3); }

.btn.ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--border); box-shadow: none; font-weight: 600; font-family: var(--font-body); font-size: .95rem; padding: 10px 20px; }
.btn.ghost:hover { background: var(--primary-light); border-color: var(--primary-light); color: var(--primary-hover); transform: none; box-shadow: none; }

.btn.sm { padding: 8px 18px; font-size: .88rem; border-radius: 10px; }

.btn.danger { background: transparent; color: var(--err); border: 1.5px solid #fecaca; font-family: var(--font-body); font-size: .9rem; box-shadow: none; }
.btn.danger:hover { background: var(--err-bg); border-color: #fca5a5; transform: none; box-shadow: none; }

/* ---------------- Signature: كود كتذكرة ---------------- */
.ticket {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--primary-light); border: 1.5px dashed var(--border-focus);
  border-radius: 10px; padding: 6px 16px;
  font-family: monospace; font-size: .95rem; font-weight: 700; color: var(--primary);
  letter-spacing: 1.5px; direction: ltr;
}
.ticket.used { background: #f1f5f9; border-color: #cbd5e1; color: #94a3b8; text-decoration: line-through; }

/* ---------------- Login ---------------- */
.login-box {
  width: 100%; max-width: 420px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 44px 36px;
  box-shadow: var(--shadow-lg); text-align: center;
}
.login-box .brand { padding-bottom: 24px; justify-content: center; }
.login-box .brand strong { color: var(--text-main); font-size: 1.8rem; }
.login-box .brand small { color: var(--text-muted); }
.login-box p.hint { font-size: .9rem; color: var(--text-muted); margin-top: 20px; font-weight: 500; }
.login-box .btn { width: 100%; margin-top: 10px; }

/* ---------------- Misc ---------------- */
.empty { text-align: center; color: var(--text-muted); padding: 48px 20px; font-size: 1rem; font-weight: 500; background: var(--bg-page); border-radius: 16px; border: 1px dashed var(--border); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
pre.code-example {
  background: #0f172a; color: #e2e8f0; padding: 20px; border-radius: 14px;
  font-size: .85rem; overflow-x: auto; direction: ltr; text-align: left; line-height: 1.7; font-weight: 500;
}
.copy-note { font-size: .85rem; color: var(--text-muted); margin-top: 10px; font-weight: 500; }
.rank-1 td:first-child::before { content: "🥇 "; }
.rank-2 td:first-child::before { content: "🥈 "; }
.rank-3 td:first-child::before { content: "🥉 "; }

/* شريط تحميل بسيط عند الحاجة */
.skeleton { background: linear-gradient(90deg, var(--bg-page) 25%, #eef2f7 37%, var(--bg-page) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; min-height: auto; position: static; flex-direction: column; align-items: stretch; border-left: 0; border-bottom: 1px solid var(--border); padding: 20px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .sidebar nav a { flex: 1; text-align: center; min-width: 100px; }
  .sidebar-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
  .whoami { margin-bottom: 0; }
  main.with-side { padding: 24px 20px; }
  .grid-2 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 500px) {
  .cards { grid-template-columns: 1fr; }
  .sidebar nav a { min-width: 100%; }
  .login-box { padding: 32px 22px; border-radius: var(--radius); }
}

@media print {
  .sidebar, button, .btn { display: none !important; }
  main.with-side { max-width: 100%; padding: 0; }
}