/* ============================================================
   نادي العقيق الرياضي النسائي — نظام التصميم
   assets/css/app.css
   ============================================================
   الهوية اللونية مستوحاة من حجر العقيق: أحمر عميق دافئ مع
   لمسات ذهبية وردية على خلفية كريمية. مصمَّم RTL أولاً.
   ============================================================ */

@layer base, components, utilities;

:root {
  /* ── الألوان الأساسية ── */
  --agate-950: #2A0A18;
  --agate-900: #45102A;
  --agate-800: #5E1638;
  --agate-700: #7A1C46;
  --agate-600: #9B2454;
  --agate-500: #B93A6B;
  --agate-400: #D2648D;
  --agate-300: #E695B2;
  --agate-200: #F3C4D5;
  --agate-100: #FBE6EE;
  --agate-50:  #FEF5F8;

  /* ── الذهبي الوردي ── */
  --gold-700: #8A6A32;
  --gold-600: #A98543;
  --gold-500: #C9A46B;
  --gold-400: #DCC094;
  --gold-200: #F0E3CD;
  --gold-100: #F9F2E6;

  /* ── محايدة دافئة ── */
  --ink-900: #1C1218;
  --ink-800: #2E2029;
  --ink-700: #453542;
  --ink-600: #5E4C58;
  --ink-500: #7C6A76;
  --ink-400: #A2939C;
  --ink-300: #C9BDC5;
  --ink-200: #E4DBE0;
  --ink-100: #F2ECEF;
  --cream:   #FDFAF8;
  --white:   #FFFFFF;

  /* ── دلالية ── */
  --ok-600:   #12805C;
  --ok-500:   #17A673;
  --ok-100:   #DFF5EC;
  --warn-600: #B45309;
  --warn-500: #E08A16;
  --warn-100: #FDF0DA;
  --danger-700: #A0161B;
  --danger-600: #C81E24;
  --danger-500: #E63A40;
  --danger-100: #FDE4E5;
  --info-600: #1E5FA8;
  --info-100: #E2EDF9;

  /* ── الأسطح ── */
  --bg:        var(--cream);
  --surface:   var(--white);
  --surface-2: var(--agate-50);
  --border:    var(--ink-200);
  --text:      var(--ink-900);
  --text-soft: var(--ink-600);
  --text-mute: var(--ink-400);

  /* ── الظلال ── */
  --sh-xs: 0 1px 2px rgba(42, 10, 24, .06);
  --sh-sm: 0 2px 8px rgba(42, 10, 24, .07);
  --sh-md: 0 6px 20px rgba(42, 10, 24, .09);
  --sh-lg: 0 16px 44px rgba(42, 10, 24, .13);
  --sh-glow: 0 0 0 4px var(--agate-100);

  /* ── القياسات ── */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;
  --r-full: 999px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  --font: "IBM Plex Sans Arabic", "Tajawal", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-num: "IBM Plex Sans Arabic", ui-monospace, "SF Mono", monospace;

  --ease: cubic-bezier(.22, 1, .36, 1);
}

/* الوضع الليلي — لشاشات الاستقبال المسائية */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #17090F;
    --surface:   #21101A;
    --surface-2: #2B1622;
    --border:    #3D2231;
    --text:      #F7EEF2;
    --text-soft: #D3BDC8;
    --text-mute: #9C8593;
    --sh-glow: 0 0 0 4px rgba(155, 36, 84, .25);
  }
}

/* ============================================================
   الأساس
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0 0 var(--sp-3); line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.4vw, 3rem); }
h2 { font-size: clamp(1.4rem, 1.1rem + 1.3vw, 2rem); }
h3 { font-size: 1.25rem; }
p  { margin: 0 0 var(--sp-4); }

a { color: var(--agate-600); text-decoration: none; transition: color .18s var(--ease); }
a:hover { color: var(--agate-800); }

img, svg { max-width: 100%; height: auto; display: block; }

:focus-visible {
  outline: 3px solid var(--agate-400);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--agate-200); color: var(--agate-950); }

/* أرقام مصفوفة عمودياً (مهم للتايمر) */
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ============================================================
   التخطيط
   ============================================================ */
.container { width: min(1180px, 100% - 2 * var(--sp-5)); margin-inline: auto; }
.container-narrow { width: min(760px, 100% - 2 * var(--sp-5)); margin-inline: auto; }

.stack > * + * { margin-top: var(--sp-4); }
.row { display: flex; gap: var(--sp-3); align-items: center; }
.row-between { display: flex; gap: var(--sp-3); align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.section { padding-block: clamp(var(--sp-6), 6vw, var(--sp-8)); }

/* ============================================================
   البطاقات
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--sh-sm);
}
.card-flat { box-shadow: none; }
.card-pad-sm { padding: var(--sp-4); }

.card-hero {
  background: linear-gradient(150deg, var(--agate-800), var(--agate-950) 70%);
  color: var(--agate-50);
  border: none;
  position: relative;
  overflow: hidden;
}
.card-hero::after {
  content: "";
  position: absolute;
  inset-block-start: -40%;
  inset-inline-end: -20%;
  width: 60%;
  aspect-ratio: 1;
  background: radial-gradient(circle, rgba(201,164,107,.35), transparent 70%);
  pointer-events: none;
}

/* ============================================================
   الأزرار
   ============================================================ */
.btn {
  --btn-bg: var(--agate-700);
  --btn-fg: #fff;
  --btn-bd: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 13px 26px;
  min-height: 50px;
  border: 1.5px solid var(--btn-bd);
  border-radius: var(--r-full);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease), opacity .16s;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--sh-md); }
.btn:active:not(:disabled) { transform: translateY(0); box-shadow: var(--sh-xs); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }

.btn-lg { padding: 18px 36px; min-height: 62px; font-size: 1.15rem; }
.btn-xl { padding: 22px 44px; min-height: 74px; font-size: 1.3rem; border-radius: var(--r-xl); }
.btn-sm { padding: 8px 16px; min-height: 38px; font-size: .875rem; }
.btn-block { width: 100%; }

.btn-ghost   { --btn-bg: transparent; --btn-fg: var(--agate-700); --btn-bd: var(--border); }
.btn-ghost:hover:not(:disabled) { --btn-bg: var(--agate-50); --btn-bd: var(--agate-300); }
.btn-soft    { --btn-bg: var(--agate-100); --btn-fg: var(--agate-800); }
.btn-gold    { --btn-bg: var(--gold-500); --btn-fg: var(--agate-950); }
.btn-ok      { --btn-bg: var(--ok-500); }
.btn-warn    { --btn-bg: var(--warn-500); --btn-fg: #22160a; }
.btn-danger  { --btn-bg: var(--danger-600); }
.btn-light   { --btn-bg: rgba(255,255,255,.14); --btn-fg: #fff; --btn-bd: rgba(255,255,255,.3); }

/* ============================================================
   النماذج
   ============================================================ */
.field { display: block; margin-bottom: var(--sp-4); }
.field-label {
  display: block;
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: var(--sp-2);
  color: var(--text-soft);
}
.field-hint { font-size: .85rem; color: var(--text-mute); margin-top: var(--sp-2); }
.field-error { font-size: .875rem; color: var(--danger-600); margin-top: var(--sp-2); font-weight: 600; }

.input, .select, .textarea {
  width: 100%;
  padding: 14px 18px;
  min-height: 52px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color .16s, box-shadow .16s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--agate-500);
  box-shadow: var(--sh-glow);
}
.input::placeholder { color: var(--text-mute); }
.input:disabled { background: var(--ink-100); cursor: not-allowed; }
.textarea { min-height: 110px; resize: vertical; }

/* حقل رقم الهوية — كبير ومتباعد لسهولة الإدخال على شاشة اللمس */
.input-id {
  font-family: var(--font-num);
  font-size: clamp(1.6rem, 1.2rem + 2.2vw, 2.6rem);
  font-weight: 700;
  letter-spacing: .28em;
  text-align: center;
  padding: 20px 12px;
  min-height: 84px;
  border-width: 2px;
  border-radius: var(--r-lg);
  direction: ltr;
}

.check { display: flex; align-items: flex-start; gap: var(--sp-3); cursor: pointer; }
.check input[type="checkbox"] {
  width: 22px; height: 22px; margin: 2px 0 0;
  accent-color: var(--agate-600); cursor: pointer; flex: none;
}

/* ============================================================
   لوحة الأرقام (Keypad) لشاشة اللمس
   ============================================================ */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  max-width: 420px;
  margin-inline: auto;
}
.key {
  aspect-ratio: 1.55;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.4rem, 1rem + 1.6vw, 2rem);
  font-weight: 700;
  font-family: var(--font-num);
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .12s, transform .1s, border-color .12s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.key:hover { background: var(--agate-50); border-color: var(--agate-300); }
.key:active { transform: scale(.95); background: var(--agate-100); }
.key-fn { font-size: 1.1rem; color: var(--agate-700); background: var(--surface-2); }

/* ============================================================
   الشارات والحالات
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: var(--r-full);
  font-size: .82rem;
  font-weight: 700;
  background: var(--ink-100);
  color: var(--ink-700);
  white-space: nowrap;
}
.badge-ok     { background: var(--ok-100);     color: var(--ok-600); }
.badge-warn   { background: var(--warn-100);   color: var(--warn-600); }
.badge-danger { background: var(--danger-100); color: var(--danger-700); }
.badge-info   { background: var(--info-100);   color: var(--info-600); }
.badge-gold   { background: var(--gold-100);   color: var(--gold-700); }
.badge-agate  { background: var(--agate-100);  color: var(--agate-700); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.dot-pulse { animation: pulse 1.8s var(--ease) infinite; }

/* ============================================================
   التنبيهات
   ============================================================ */
.alert {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1.5px solid;
  font-weight: 500;
  align-items: flex-start;
}
.alert-icon { font-size: 1.3rem; line-height: 1.3; flex: none; }
.alert-ok     { background: var(--ok-100);     border-color: var(--ok-500);     color: #0B5741; }
.alert-warn   { background: var(--warn-100);   border-color: var(--warn-500);   color: #7A3A06; }
.alert-danger { background: var(--danger-100); border-color: var(--danger-500); color: var(--danger-700); }
.alert-info   { background: var(--info-100);   border-color: var(--info-600);   color: #16406F; }

/* ============================================================
   الجداول
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .94rem; }
.table th, .table td { padding: 13px 16px; text-align: right; border-bottom: 1px solid var(--border); }
.table th {
  background: var(--surface-2);
  font-weight: 700;
  font-size: .85rem;
  color: var(--text-soft);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--agate-50); }
.table-empty { text-align: center; padding: var(--sp-7); color: var(--text-mute); }

/* ============================================================
   مؤشرات الإحصاء
   ============================================================ */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}
.stat-label { font-size: .85rem; color: var(--text-mute); font-weight: 600; margin-bottom: 6px; }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-sub   { font-size: .82rem; color: var(--text-mute); margin-top: 4px; }

/* ============================================================
   الحركات
   ============================================================ */
@keyframes pulse    { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes fadeUp   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes shake    { 10%,90% { transform: translateX(-2px); } 20%,80% { transform: translateX(4px); }
                      30%,50%,70% { transform: translateX(-7px); } 40%,60% { transform: translateX(7px); } }
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes flashRed { 0%,100% { background-color: var(--danger-700); } 50% { background-color: var(--danger-500); } }

.anim-in { animation: fadeUp .4s var(--ease) both; }
.anim-shake { animation: shake .5s var(--ease); }

.spinner {
  width: 22px; height: 22px; flex: none;
  border: 2.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================
   أدوات
   ============================================================ */
.text-center { text-align: center; }
.text-soft   { color: var(--text-soft); }
.text-mute   { color: var(--text-mute); }
.text-sm     { font-size: .875rem; }
.text-xs     { font-size: .78rem; }
.text-lg     { font-size: 1.15rem; }
.fw-700      { font-weight: 700; }
.fw-800      { font-weight: 800; }
.mt-0 { margin-top: 0; }   .mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: var(--sp-4); }  .mt-5 { margin-top: var(--sp-5); }
.mb-4 { margin-bottom: var(--sp-4); } .mb-5 { margin-bottom: var(--sp-5); }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.divider { height: 1px; background: var(--border); margin-block: var(--sp-5); border: 0; }
