/* ═══════════════════════════════════════════════════════════
   نظام حجز العيادة
   عربي RTL · من غير أي مكتبة خارجية · ملفات ساكنة بس

   الهوية: أبيض بحواف زرقا. الأزرق الطبي (#0284C7) للحواف
   والإشارات، ودرجة أغمق (#0369A1) للنص والزراير عشان تباين
   الأبيض عليها يعدّي ٤.٥:١ — الدرجة الفاتحة كانت ٤.٠٩ بس.
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  --blue:        #0284c7;   /* الحواف والإشارات */
  --blue-ink:    #0369a1;   /* النص والزراير — ٥.٩:١ على الأبيض */
  --blue-deep:   #075985;
  --blue-soft:   #38bdf8;
  --blue-tint:   #f0f9ff;
  --blue-line:   #d8ecf8;

  --bg:          #ffffff;
  --ink:         #0f172a;
  --ink-soft:    #475569;
  --ink-mute:    #6b7a8f;   /* ٤.٦:١ على الأبيض */
  --line:        #e5edf3;

  --red:         #dc2626;
  --amber:       #b45309;

  --r-sm:  10px;
  --r:     14px;
  --r-lg:  20px;
  --r-pill: 999px;

  --sh-sm: 0 1px 2px rgba(15,23,42,.05);
  --sh:    0 4px 16px rgba(2,132,199,.08);
  --sh-lg: 0 18px 48px rgba(2,132,199,.16);

  --fs-2xs: 12px; --fs-xs: 13px; --fs-sm: 15px; --fs-md: 17px;
  --fs-lg: 20px;  --fs-xl: 25px; --fs-2xl: 32px;

  --ease: cubic-bezier(.22,.61,.36,1);
  --ease-out-back: cubic-bezier(.34,1.36,.64,1);

  --font: 'IBM Plex Sans Arabic', 'Segoe UI', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  direction: rtl;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}

/* ضوء أزرق خافت جداً ورا الصفحة — بيدّي عمق من غير ما ياخد انتباه */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(680px 460px at 88% -8%, rgba(2,132,199,.10), transparent 68%),
    radial-gradient(560px 420px at 4% 104%, rgba(56,189,248,.10), transparent 70%);
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
input, select, button, textarea { font: inherit; color: inherit; }

.wrap { width: 100%; max-width: 920px; margin: 0 auto; padding: 0 20px; }

/* كل رقم بخانات ثابتة — الأرقام في الجدول لازم تترصّ فوق بعضها */
.num, td.num, .stat b { font-variant-numeric: tabular-nums; }

/* ═══════════ الترويسة ═══════════ */
.top {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 920px; margin: 0 auto; padding: 0 20px;
  height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(140deg, var(--blue), var(--blue-deep));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 12px rgba(2,132,199,.32);
}
.brand-mark svg { width: 20px; height: 20px; stroke-width: 2.2; }
.brand-txt b { display: block; font-size: var(--fs-md); font-weight: 600; line-height: 1.3; }
.brand-txt span { display: block; font-size: var(--fs-2xs); color: var(--ink-mute); }

.tabs { display: flex; gap: 4px; background: var(--blue-tint); padding: 4px; border-radius: var(--r-pill); }
.tabs a {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 44px; padding: 0 16px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; color: var(--ink-soft);
  transition: background .22s var(--ease), color .22s;
}
.tabs a svg { width: 15px; height: 15px; stroke-width: 2.4; }
.tabs a:hover { color: var(--blue-ink); }
.tabs a.on { background: #fff; color: var(--blue-ink); box-shadow: var(--sh-sm); }

/* ═══════════ الجسم ═══════════ */
main { flex: 1; padding: 44px 0 64px; }

.head { text-align: center; margin-bottom: 32px; }
.head h1 {
  font-size: clamp(25px, 4vw, 32px); font-weight: 700;
  letter-spacing: -.6px; margin-bottom: 8px;
}
.head p { color: var(--ink-mute); font-size: var(--fs-sm); }

/* ═══════════ الكارت ═══════════
   الحافة الزرقا فوق الكارت هي العنصر اللي بيدّي الصفحة هويّتها —
   أبيض نضيف وخط أزرق واحد. */
.card {
  position: relative;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh);
  overflow: hidden;
}
.card::before {
  content: ''; position: absolute; top: 0; inset-inline: 0; height: 3px;
  background: linear-gradient(90deg, var(--blue-deep), var(--blue), var(--blue-soft));
}
.card-in { padding: 34px 32px; }

/* ═══════════ الحقول ═══════════ */
.field { margin-bottom: 22px; }
.field > label {
  display: block; font-size: var(--fs-xs); font-weight: 600;
  color: var(--ink-soft); margin-bottom: 8px;
}
.field .req { color: var(--red); }

.control { position: relative; }
.control > svg.lead {
  position: absolute; inset-inline-start: 15px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; stroke-width: 2; color: var(--ink-mute);
  pointer-events: none; transition: color .2s;
}
.control input, .control select {
  width: 100%; min-height: 54px;
  padding-inline: 46px 16px;
  border: 1.5px solid var(--line); border-radius: var(--r);
  background: #fff; font-size: var(--fs-sm); color: var(--ink);
  outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
.control select {
  appearance: none; cursor: pointer;
  padding-inline-end: 44px;
}
/* السهم بيتحط بإيدنا عشان يبقى بنفس شكل باقي الأيقونات */
.control > svg.caret {
  position: absolute; inset-inline-end: 16px; top: 50%;
  width: 16px; height: 16px; stroke-width: 2.4; color: var(--ink-mute);
  pointer-events: none; transition: transform .25s var(--ease);
  transform: translateY(-50%);
}
.control:focus-within > svg.lead,
.control:focus-within > svg.caret { color: var(--blue-ink); }
.control:focus-within > svg.caret { transform: translateY(-50%) rotate(180deg); }

.control input:hover, .control select:hover { border-color: var(--blue-line); }
.control input:focus, .control select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(2,132,199,.14);
}
.control input::placeholder { color: #9aa8b8; }

.field.bad .control input, .field.bad .control select { border-color: var(--red); }
.field.bad .control:focus-within input { box-shadow: 0 0 0 4px rgba(220,38,38,.13); }
.err {
  display: none; align-items: center; gap: 6px;
  font-size: var(--fs-2xs); font-weight: 600; color: var(--red); margin-top: 8px;
}
.err svg { width: 14px; height: 14px; stroke-width: 2.4; flex-shrink: 0; }
.field.bad .err { display: flex; animation: shake .34s var(--ease); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-4px); }
  75%     { transform: translateX(4px); }
}

/* ═══════════ الزراير ═══════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 52px; padding: 0 26px; border-radius: var(--r);
  border: 1.5px solid transparent; cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
  transition: transform .18s var(--ease), box-shadow .22s, background .22s, border-color .22s, color .22s;
}
.btn svg { width: 17px; height: 17px; stroke-width: 2.2; }
.btn-main {
  width: 100%;
  background: linear-gradient(140deg, var(--blue-ink), var(--blue-deep));
  color: #fff; box-shadow: 0 6px 18px rgba(3,105,161,.30);
}
.btn-main:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(3,105,161,.38); }
.btn-main:active { transform: translateY(0) scale(.985); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue-ink); transform: translateY(-1px); }
.btn-sm { min-height: 42px; padding: 0 16px; font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-danger { background: #fff; border-color: #f3d0d0; color: var(--red); }
.btn-danger:hover { background: #fef4f4; border-color: var(--red); }

/* ═══════════ رسالة النجاح ═══════════ */
.done {
  position: fixed; inset-inline: 0; bottom: 24px; z-index: 90;
  display: flex; justify-content: center; padding: 0 20px;
  pointer-events: none;
}
.done-in {
  display: inline-flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--blue-line);
  border-radius: var(--r-pill); padding: 12px 22px 12px 16px;
  box-shadow: var(--sh-lg);
  font-size: var(--fs-sm); font-weight: 600;
  opacity: 0; transform: translateY(16px) scale(.96);
  transition: opacity .3s var(--ease), transform .42s var(--ease-out-back);
}
.done.on .done-in { opacity: 1; transform: none; }
.tick {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--blue-tint); display: grid; place-items: center; color: var(--blue-ink);
}
.tick svg { width: 17px; height: 17px; stroke-width: 2.8; }
/* العلامة بترسم نفسها بدل ما تظهر فجأة — الحركة بتقول «اتسجّل» */
.tick path { stroke-dasharray: 26; stroke-dashoffset: 26; }
.done.on .tick path { animation: draw .42s var(--ease) .12s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ═══════════ آخر الحجوزات تحت الفورم ═══════════ */
.recent { margin-top: 26px; }
.recent-h {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; padding-inline: 4px;
}
.recent-h b { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-mute); }
.recent-h a {
  display: inline-flex; align-items: center; min-height: 44px;
  font-size: var(--fs-xs); font-weight: 600; color: var(--blue-ink);
}
.recent-h a:hover { text-decoration: underline; }
.mini { display: flex; flex-direction: column; gap: 8px; }
.mini li {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 12px 16px;
  animation: pop .38s var(--ease-out-back) both;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.mini .nm { font-size: var(--fs-sm); font-weight: 600; flex: 1; min-width: 0;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini .tm { font-size: var(--fs-2xs); color: var(--ink-mute); }

/* ═══════════ الشارات ═══════════ */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: var(--r-pill);
  font-size: var(--fs-2xs); font-weight: 600; white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-k { background: var(--blue-tint); color: var(--blue-deep); }
.pill-s { background: #fdf4e7; color: var(--amber); }

/* ═══════════ الإحصائيات ═══════════ */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px 16px; text-align: center; position: relative; overflow: hidden;
  animation: pop .4s var(--ease-out-back) both;
}
.stat::before {
  content: ''; position: absolute; top: 0; inset-inline: 50% auto;
  transform: translateX(50%); width: 26px; height: 3px;
  background: var(--blue); border-radius: 0 0 3px 3px;
}
.stat:nth-child(2) { animation-delay: .06s; }
.stat:nth-child(3) { animation-delay: .12s; }
.stat b { display: block; font-size: var(--fs-xl); font-weight: 600; line-height: 1.2; }
.stat span { font-size: var(--fs-2xs); color: var(--ink-mute); font-weight: 600; }

/* ═══════════ أدوات السجلات ═══════════ */
.tools { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.tools .control { flex: 1 1 220px; }
.tools .control input { min-height: 46px; }
.seg { display: flex; gap: 3px; background: var(--blue-tint); padding: 3px; border-radius: var(--r-sm); }
.seg button {
  min-height: 44px; padding: 0 15px; border: none; border-radius: 8px; cursor: pointer;
  background: transparent; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-soft);
  transition: background .2s, color .2s;
}
.seg button:hover { color: var(--blue-ink); }
.seg button.on { background: #fff; color: var(--blue-ink); box-shadow: var(--sh-sm); }

/* ═══════════ الجدول ═══════════ */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
thead th {
  text-align: start; font-size: var(--fs-2xs); font-weight: 600; color: var(--ink-mute);
  padding: 0 16px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background .18s;
  animation: rowin .34s var(--ease) both;
}
@keyframes rowin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
tbody tr:hover { background: var(--blue-tint); }
tbody tr.going { animation: rowout .3s var(--ease) forwards; }
@keyframes rowout {
  to { opacity: 0; transform: translateX(28px); }
}
tbody td { padding: 14px 16px; font-size: var(--fs-sm); vertical-align: middle; }
td.idx { color: var(--ink-mute); font-size: var(--fs-xs); width: 46px; }
td.nm { font-weight: 600; }
td.dt { color: var(--ink-soft); font-size: var(--fs-xs); white-space: nowrap; }
td.act { width: 44px; text-align: end; }
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 9px; background: transparent;
  color: var(--ink-mute); cursor: pointer;
  transition: background .18s, color .18s, border-color .18s;
}
.icon-btn { position: relative; }
.icon-btn::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 44px; height: 44px; transform: translate(-50%, -50%);
}
.icon-btn svg { width: 16px; height: 16px; stroke-width: 2.2; }
.icon-btn:hover { background: #fef4f4; color: var(--red); border-color: #f3d0d0; }

/* ═══════════ الجدول على الموبايل ═══════════
   الجدول عرضه ٥٦٠ بكسل جوه سكرول أفقي. على شاشة ٣٩٠ ده معناه إن
   عمود المسح بيقع بره الشاشة والزائر لازم يسحب عشان يوصله. فبدل
   الجدول، كل صف بيبقى كارت مستقل — كل حاجة بانة من غير سحب. */
@media (max-width: 640px) {
  .tbl-wrap { overflow-x: visible; }
  table { min-width: 0; display: block; }
  thead { display: none; }
  tbody { display: block; }

  tbody tr {
    display: block; position: relative;
    border: 1px solid var(--line); border-radius: var(--r);
    padding: 14px 16px; margin-bottom: 10px;
  }
  tbody tr:hover { background: #fff; }
  tbody tr::before {
    content: ''; position: absolute; top: 14px; bottom: 14px;
    inset-inline-start: 0; width: 3px; border-radius: 0 3px 3px 0;
    background: var(--blue);
  }

  tbody td { display: block; padding: 0; }
  td.idx { display: none; }
  td.nm {
    font-size: var(--fs-md); margin-bottom: 8px;
    padding-inline-end: 46px;   /* مكان زرار المسح */
  }
  td.dt { margin-top: 8px; }
  td.act {
    position: absolute; top: 10px; inset-inline-end: 10px;
    width: auto; text-align: unset;
  }
  .icon-btn { width: 40px; height: 40px; }
}

/* ═══════════ لا يوجد ═══════════ */
.empty { text-align: center; padding: 56px 24px; animation: pop .42s var(--ease-out-back) both; }
.empty-ico {
  width: 68px; height: 68px; margin: 0 auto 18px; border-radius: 20px;
  background: var(--blue-tint); display: grid; place-items: center; color: var(--blue);
}
.empty-ico svg { width: 30px; height: 30px; stroke-width: 1.8; }
.empty b { display: block; font-size: var(--fs-md); font-weight: 600; margin-bottom: 6px; }
.empty p { color: var(--ink-mute); font-size: var(--fs-sm); max-width: 34ch; margin: 0 auto 20px; }

/* ═══════════ التذييل ═══════════ */
.foot {
  text-align: center; padding: 22px 20px 30px;
  font-size: var(--fs-2xs); color: var(--ink-mute);
  border-top: 1px solid var(--line);
}
.foot a {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--blue-ink); font-weight: 600;
}

/* ═══════════ التركيز بلوحة المفاتيح ═══════════ */
:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}
.control input:focus-visible, .control select:focus-visible { outline: none; }

/* ═══════════ دخول الصفحة ═══════════ */
.rise { opacity: 0; animation: rise .58s var(--ease) forwards; }
.rise:nth-child(1) { animation-delay: .04s; }
.rise:nth-child(2) { animation-delay: .12s; }
.rise:nth-child(3) { animation-delay: .2s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ═══════════ الشاشات الصغيرة ═══════════ */
@media (max-width: 720px) {
  .top-in { height: 64px; }
  .brand-txt span { display: none; }
  .tabs a { padding: 0 13px; }
  main { padding: 30px 0 44px; }
  .card-in { padding: 26px 20px; }
  .stats { grid-template-columns: 1fr; }
  .stat { display: flex; align-items: center; justify-content: space-between; text-align: start; padding: 14px 18px; }
  .stat::before { inset-inline: auto 0; transform: none; width: 3px; height: 100%; top: 0; border-radius: 0; }
}
@media (max-width: 420px) {
  .brand-txt b { font-size: var(--fs-sm); }
  .tabs a span { display: none; }
  .tabs a { padding: 0 15px; }
}

/* اللي مقفّل الحركة من إعدادات جهازه */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .rise { opacity: 1; transform: none; }
  .tick path { stroke-dashoffset: 0; }
}

/* ═══════════ الطباعة ═══════════ */
@media print {
  .top, .tools, .foot, td.act, .btn, .done { display: none !important; }
  body::before { display: none; }
  .card { box-shadow: none; border: none; }
  .card::before { display: none; }
  main { padding: 0; }
}
