/* ============ فهمولوجي — الهوية الجديدة: الأبيض والأزرق الموثوق ============ */
:root {
  --primary: #1a56db;       /* Trust Blue */
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  
  --secondary: #f59e0b;     /* Warm Gold */
  --secondary-hover: #d97706;
  --secondary-light: #fef3c7;
  
  --bg-page: #f8fafc;       /* خلفية رمادية فاتحة مريحة للعين */
  --bg-card: #ffffff;       /* كروت بيضاء */
  --border: #e2e8f0;
  --border-focus: #93c5fd;
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  
  --ok: #10b981;
  --ok-bg: #d1fae5;
  --err: #ef4444;
  --err-bg: #fee2e2;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  
  --radius: 16px;
  --font-display: "Baloo Bhaijaan 2", sans-serif;
  --font-body: "IBM Plex Sans Arabic", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); color: var(--text-main); }
h1 { font-size: 1.8rem; margin-bottom: 6px; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 14px; }
.sub { color: var(--text-muted); margin-bottom: 26px; font-size: .95rem; }
a { text-decoration: none; color: var(--primary); }
a:hover { text-decoration: underline; }
: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-sm);
}
.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%;
  background: var(--primary); 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: 6px; flex: 1; }
.sidebar nav a {
  color: var(--text-muted); text-decoration: none !important; padding: 12px 16px;
  border-radius: 12px; font-size: .95rem; font-weight: 500; transition: all .2s;
}
.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; }
.logout:hover { background: var(--err-bg); padding: 4px 8px; border-radius: 6px; 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; }
.flash.ok  { background: var(--ok-bg); color: #065f46; border: 1px solid #a7f3d0; }
.flash.error { background: var(--err-bg); color: #991b1b; border: 1px solid #fecaca; }

/* ---------------- 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-sm); transition: transform 0.2s, box-shadow 0.2s;
}
.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-sm); }
.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: .85rem; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--bg-page); }
th:first-child { border-top-right-radius: 10px; } th:last-child { border-top-left-radius: 10px; }
td { padding: 14px 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; }
.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: .9rem; 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: 1px solid var(--border); border-radius: 12px;
  background: #fff; color: var(--text-main); width: 100%; transition: all .2s;
}
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 3px var(--primary-light); }
.field { flex: 1; min-width: 180px; }

/* ---------------- Buttons ---------------- */
button, .btn {
  font-family: var(--font-display); font-size: 1.05rem; 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: all .2s; box-shadow: 0 4px 10px rgba(26, 86, 219, 0.2);
}
button:hover, .btn:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 6px 14px rgba(26, 86, 219, 0.3); }
button:active, .btn:active { transform: translateY(1px); }

.btn.gold { background: var(--secondary); color: #fff; box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2); }
.btn.gold:hover { background: var(--secondary-hover); box-shadow: 0 6px 14px rgba(245, 158, 11, 0.3); }

.btn.ghost { background: transparent; color: var(--primary); border: 2px 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: .9rem; border-radius: 10px; }

.btn.danger { background: transparent; color: var(--err); border: 2px 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: 24px; padding: 42px 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: "🥉 "; }

/* ---------------- 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%; }
}
