/* ════════════════════════════════════════════════════════════════
   نظام «إنجاز» — مكتبة المكوّنات
   تعتمد كليًا على رموز theme.css — لا قيمة لونية خام هنا.
   ════════════════════════════════════════════════════════════════ */

/* ─── الأزرار ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 10px 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  color: var(--ink);
  font: inherit; font-weight: 800; font-size: var(--fs-sm);
  cursor: pointer;
  box-shadow: var(--sh-1);
  transition: transform var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover  { background: linear-gradient(180deg, #24333f, var(--surface-3));
              border-color: var(--ink-faint); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled {
  opacity: .45; cursor: not-allowed; transform: none;
}

.btn-primary {
  border-color: var(--brand-600);
  background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
  color: #fff; box-shadow: var(--sh-brand);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--brand-400), var(--brand-600));
                     border-color: var(--brand-400); }

.btn-gold {
  border-color: var(--gold-600);
  background: linear-gradient(180deg, var(--gold-400), var(--gold-600));
  color: var(--gold-ink); box-shadow: var(--sh-gold);
}
.btn-gold:hover { background: linear-gradient(180deg, var(--gold-200), var(--gold-500)); }

.btn-danger { border-color: #7f2323;
              background: linear-gradient(180deg, #b23232, #7f2323); color: #fff; }
.btn-ghost  { background: transparent; border-color: transparent; color: var(--ink-soft);
              box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border); }

.btn-lg  { min-height: 54px; padding: 14px 28px; font-size: var(--fs-md); }
.btn-sm  { min-height: 36px; padding: 6px 14px;  font-size: var(--fs-xs); }
.btn-block { width: 100%; }

/* ⚠ زرّ الأيقونة وحدها: كان في مشروع سابق 22×22 فأخطأته الإصبع.
   حدّ أدنى غير مشروط — لا تعتمد على pointer:coarse فمتصفح
   الفحص يبلّغ fine دائمًا فلا تُختبر القاعدة أصلًا. */
.btn:has(> svg:only-child),
.icon-btn {
  min-width: 40px; min-height: 40px; padding: 8px;
}
@media (pointer: coarse) {
  .btn:has(> svg:only-child), .icon-btn { min-width: var(--tap); min-height: var(--tap); }
}

.btn svg { width: 18px; height: 18px; flex: none; }
.btn-lg svg { width: 20px; height: 20px; }

/* ─── البطاقات ─────────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  padding: var(--s5);
}
.card-tight { padding: var(--s4); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); flex-wrap: wrap;
  margin-bottom: var(--s4); padding-bottom: var(--s3);
  border-bottom: 1px solid var(--border);
}
.card-link { cursor: pointer; transition: border-color var(--t-fast) var(--ease),
                                          transform var(--t-fast) var(--ease); }
.card-link:hover { border-color: var(--brand-600); transform: translateY(-2px); }

/* ─── الحقول ───────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--s2); }
.label { font-size: var(--fs-sm); font-weight: 800; color: var(--ink-soft); }
.hint  { font-size: var(--fs-xs); color: var(--ink-muted); }

.input, .select, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  background: var(--canvas);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--ink);
  font: inherit; font-weight: 600;
  /* ⚠ iOS يقرّب الصفحة تلقائيًا لو صغر خط الحقل عن 16px */
  font-size: max(16px, var(--fs-sm));
  box-shadow: inset 0 2px 5px rgba(0,0,0,.45);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: inset 0 2px 5px rgba(0,0,0,.45), 0 0 0 3px rgba(20,184,166,.18);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); font-weight: 500; }
.textarea { min-height: 110px; resize: vertical; line-height: 1.7; }
.select {
  appearance: none; cursor: pointer; padding-left: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d92a6' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; background-size: 18px;
}

/* ─── الشارات الصغيرة (حالات ووسوم) ────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 800;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--ink-soft);
}
.chip svg { width: 14px; height: 14px; }
.chip-ok     { color: var(--ok);     background: var(--ok-bg);     border-color: var(--ok); }
.chip-warn   { color: var(--warn);   background: var(--warn-bg);   border-color: var(--warn); }
.chip-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger); }
.chip-info   { color: var(--info);   background: var(--info-bg);   border-color: var(--info); }
.chip-gold   { color: var(--gold-400); background: #2a2008; border-color: var(--gold-600); }

/* ─── الجداول ──────────────────────────────────────────────── */
/* ⚠ كل الجدول يمينًا. لا محاذاة مخالفة لعمود واحد — جرّبناها
   في مشروع سابق فصارت العناوين في جهة والقيم في أخرى. */
.table-wrap { overflow-x: auto; border: 1px solid var(--border);
              border-radius: var(--r-lg); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; text-align: right; }
.tbl th {
  padding: 12px 16px; font-size: var(--fs-xs); font-weight: 800;
  color: var(--ink-muted); background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap; text-align: right;
}
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--border);
          font-size: var(--fs-sm); text-align: right; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background var(--t-fast) var(--ease); }
.tbl tbody tr:hover { background: var(--surface-2); }

/* ─── حالة الفراغ ──────────────────────────────────────────── */
.empty { text-align: center; padding: var(--s7) var(--s4); color: var(--ink-muted); }
.empty svg { width: 56px; height: 56px; color: var(--ink-faint); margin-bottom: var(--s3); }
.empty h3 { color: var(--ink-soft); margin-bottom: var(--s2); }

/* ─── النوافذ ──────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(3,7,11,.78); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: var(--s4);
  animation: fade var(--t-mid) var(--ease);
}
.modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-strong); border-radius: var(--r-xl);
  box-shadow: var(--sh-3); padding: var(--s5);
  animation: rise var(--t-mid) var(--ease);
}
.modal-wide { max-width: 860px; }
@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98) } }

/* ─── التنبيهات العائمة ────────────────────────────────────── */
.toasts { position: fixed; bottom: var(--s5); left: var(--s5); z-index: 100;
          display: flex; flex-direction: column; gap: var(--s2); }
.toast {
  display: flex; align-items: center; gap: var(--s2);
  padding: 12px 18px; border-radius: var(--r-md);
  background: var(--surface-3); border: 1px solid var(--border-strong);
  box-shadow: var(--sh-3); font-size: var(--fs-sm); font-weight: 700;
  animation: rise var(--t-mid) var(--ease);
}
.toast-ok     { border-color: var(--ok);     color: var(--ok); }
.toast-danger { border-color: var(--danger); color: var(--danger); }

/* ─── القوقعة والشريط الجانبي ──────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: linear-gradient(180deg, var(--surface), var(--canvas));
  border-left: 1px solid var(--border);
  padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand-mark { display: flex; align-items: center; gap: var(--s3);
              padding: var(--s3) var(--s2) var(--s5); }
.brand-mark .logo {
  width: 44px; height: 44px; border-radius: var(--r-md); flex: none;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand-400), var(--brand-700));
  box-shadow: var(--sh-brand); color: #fff;
}
.brand-mark .logo svg { width: 26px; height: 26px; }
.brand-mark b { font-size: var(--fs-lg); font-weight: 900; display: block; line-height: 1.2; }

.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: 10px 12px; border-radius: var(--r-md);
  color: var(--ink-soft); font-weight: 700; font-size: var(--fs-sm);
  cursor: pointer; border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  min-height: var(--tap);
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(20,184,166,.16), transparent);
  border-color: var(--brand-900); color: var(--brand-200);
}
/* الأيقونة في مربّع — الزرّ الذي لا يشبه الزرّ لا يُضغط */
.nav-icon {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-3); border: 1px solid var(--border);
}
.nav-item.active .nav-icon {
  background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
  border-color: var(--brand-500); color: #fff;
}
.nav-icon svg { width: 17px; height: 17px; }
.nav-badge { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 6px;
             border-radius: var(--r-pill); background: var(--danger); color: #fff;
             font-size: 12px; font-weight: 800; display: grid; place-items: center; }

.main { flex: 1 1 auto; min-width: 0; }

.topbar {
  display: none; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}

@media (max-width: 960px) {
  .shell { flex-direction: column; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 80;
    transform: translateX(100%); transition: transform var(--t-mid) var(--ease);
    box-shadow: var(--sh-3);
  }
  .sidebar.open { transform: none; }
}

/* ─── ترويسة الصفحة ────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-start; justify-content: space-between;
             gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head h1 { margin-bottom: 4px; }

/* ─── شارة الإنجاز الدائرية ────────────────────────────────── */
.badge-coin {
  --c: var(--gold-500);
  width: 64px; height: 64px; border-radius: 50%; flex: none;
  display: grid; place-items: center; position: relative;
  background: radial-gradient(circle at 32% 28%,
              color-mix(in srgb, var(--c) 78%, #fff),
              color-mix(in srgb, var(--c) 88%, #000) 78%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 26%, transparent),
              0 10px 22px -8px color-mix(in srgb, var(--c) 65%, transparent),
              inset 0 2px 4px rgba(255,255,255,.4);
  color: #fff;
}
.badge-coin svg { width: 30px; height: 30px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.badge-coin.sm { width: 42px; height: 42px; }
.badge-coin.sm svg { width: 21px; height: 21px; }
.badge-coin.lg { width: 92px; height: 92px; }
.badge-coin.lg svg { width: 44px; height: 44px; }
.badge-coin.locked {
  background: var(--surface-3); box-shadow: inset 0 0 0 2px var(--border-strong);
  color: var(--ink-faint); opacity: .55;
}
.badge-tier {
  position: absolute; inset-block-end: -4px; inset-inline-end: -4px;
  min-width: 22px; height: 22px; padding: 0 5px; border-radius: var(--r-pill);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 900; color: #fff;
  border: 2px solid var(--surface);
}

/* ─── أزرار حالة الحضور ────────────────────────────────────── */
.att-btn {
  min-height: 46px; min-width: 46px;
  border-radius: var(--r-md); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--ink-muted);
  font-weight: 800; font-size: var(--fs-xs); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all var(--t-fast) var(--ease);
}
.att-btn:active { transform: translateY(1px); }
.att-btn[data-on="present"] { background: color-mix(in srgb, var(--att-present) 20%, var(--surface));
  border-color: var(--att-present); color: var(--att-present); }
.att-btn[data-on="absent"]  { background: color-mix(in srgb, var(--att-absent) 22%, var(--surface));
  border-color: var(--att-absent);  color: #ff8f8f; }
.att-btn[data-on="late"]    { background: color-mix(in srgb, var(--att-late) 20%, var(--surface));
  border-color: var(--att-late);    color: var(--att-late); }
.att-btn[data-on="excused"] { background: var(--surface-3);
  border-color: var(--ink-faint);   color: var(--ink-soft); }

/* ─── شريط التقدّم ─────────────────────────────────────────── */
.meter { height: 9px; border-radius: var(--r-pill); background: var(--surface-3);
         overflow: hidden; border: 1px solid var(--border); }
.meter > i { display: block; height: 100%; border-radius: inherit;
             background: linear-gradient(90deg, var(--brand-600), var(--brand-400)); }
.meter.gold > i { background: linear-gradient(90deg, var(--gold-600), var(--gold-400)); }

/* ─── شاشة الدخول ──────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); }
.auth-card { width: 100%; max-width: 430px; }
.auth-logo {
  width: 78px; height: 78px; margin: 0 auto var(--s4); border-radius: var(--r-xl);
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, var(--brand-400), var(--brand-700));
  box-shadow: var(--sh-brand);
}
.auth-logo svg { width: 44px; height: 44px; }

/* ─── مساعدات ──────────────────────────────────────────────── */
.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; }

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