/* ============================================================
   public/assets/css/app.css  —  v3 Premium Medical SaaS
   Design: Teal-Violet gradient identity, glassmorphism metrics,
           animated sidebar, rich micro-interactions
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

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

/* ══════════════════════════════════════════════════════════════
   DESIGN TOKENS
══════════════════════════════════════════════════════════════ */
:root {
  --font: 'Cairo', 'Segoe UI', sans-serif;

  /* ── Core Palette (زيارة · Zeyara — تدرّج شعار من الأزرق المخضر
     للبرتقالي المرجاني، فوق كحلي داكن) ─────────────────────────── */
  --teal-50:  #EAF3F4;
  --teal-100: #D3E6E9;
  --teal-400: #6FA3AE;
  --teal-500: #5C8E97;
  --teal-600: #4D7D85;
  --teal-700: #3D6870;
  --teal-800: #2E525A;
  --teal-900: #1F3A40;

  --violet-400: #EFA278;
  --violet-500: #E88A66;
  --violet-600: #E2725A;

  --blue-500: #5C8E97;
  --blue-600: #4D7D85;

  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;

  --amber-400:  #fbbf24;
  --amber-500:  #f59e0b;

  --rose-400: #fb7185;
  --rose-500: #f43f5e;
  --rose-600: #e11d48;

  /* ── Semantic Colors ──────────────────────────────────────── */
  --color-bg:         #FCF8F0;      /* كريمي دافئ يطابق خلفية الشعار */
  --color-surface:    #ffffff;
  --color-surface-2:  #FBF7EE;

  --color-text-1:  #16283A;
  --color-text-2:  #4a5568;
  --color-text-3:  #94a3b8;

  --color-border:  #e2e8f0;
  --color-border-2: #cbd5e1;

  /* ── Status Colors ─────────────────────────────────────────── */
  --c-info-bg:    #EAF3F4;  --c-info-txt:    #3D6870;  --c-info-brd:   #B8D4D9;
  --c-success-bg: #ecfdf5;  --c-success-txt: #059669;  --c-success-brd:#a7f3d0;
  --c-warn-bg:    #fffbeb;  --c-warn-txt:    #d97706;  --c-warn-brd:   #fde68a;
  --c-danger-bg:  #fff1f2;  --c-danger-txt:  #e11d48;  --c-danger-brd: #fecdd3;

  /* ── Sidebar ───────────────────────────────────────────────── */
  --sidebar-w: 240px;
  --sidebar-bg-from: #12283D;
  --sidebar-bg-to:   #1B3A54;

  /* ── Radius ────────────────────────────────────────────────── */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;
  --r-2xl: 24px;

  /* ── Shadows ───────────────────────────────────────────────── */
  --shadow-xs: 0 1px 2px rgba(22,40,58,.05);
  --shadow-sm: 0 2px 8px rgba(22,40,58,.06);
  --shadow-md: 0 4px 20px rgba(22,40,58,.09);
  --shadow-lg: 0 8px 40px rgba(22,40,58,.12);
  --shadow-xl: 0 20px 60px rgba(22,40,58,.16);

  /* ── Transitions ───────────────────────────────────────────── */
  --t-fast:   .12s ease;
  --t-normal: .2s ease;
  --t-slow:   .35s ease;

  /* ── Legacy aliases (backward compat with older pages) ──────── */
  --color-background-primary:   var(--color-surface);
  --color-background-secondary: var(--color-surface-2);
  --color-background-tertiary:  #e5e7eb;
  --color-background-info:      var(--c-info-bg);
  --color-background-success:   var(--c-success-bg);
  --color-background-warning:   var(--c-warn-bg);
  --color-background-danger:    var(--c-danger-bg);

  --color-text-primary:   var(--color-text-1);
  --color-text-secondary: var(--color-text-2);
  --color-text-info:      var(--c-info-txt);
  --color-text-success:   var(--c-success-txt);
  --color-text-warning:   var(--c-warn-txt);
  --color-text-danger:    var(--c-danger-txt);

  --color-border-secondary: var(--color-border);
  --color-border-tertiary:  var(--color-border-2);
  --color-border-info:      var(--c-info-brd);
  --color-border-success:   var(--c-success-brd);

  --border-radius-md: var(--r-md);
  --border-radius-lg: var(--r-lg);

  --font-sans: var(--font);
  --font-mono: 'Courier New', monospace;
}

/* ══════════════════════════════════════════════════════════════
   BASE
══════════════════════════════════════════════════════════════ */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  direction: rtl;
  background: var(--color-bg);
  color: var(--color-text-1);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ══════════════════════════════════════════════════════════════
   LAYOUT SHELL
══════════════════════════════════════════════════════════════ */
.layout { display: flex; min-height: 100vh; }

/* ══════════════════════════════════════════════════════════════
   SIDEBAR  —  الـ signature element الأول
══════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg-from) 0%, var(--sidebar-bg-to) 100%);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  /* subtle noise texture feel via shadow */
  box-shadow: -4px 0 24px rgba(0,0,0,.15) inset, 4px 0 16px rgba(0,0,0,.12);
}

/* scrollbar داخل السيدبار */
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 10px; }

/* ── Brand ──────────────────────────────────────────────────── */
.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

/* الـ glow الخفي خلف اللوجو */
.sidebar-brand::before {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, rgba(92,142,151,.25) 0%, transparent 70%);
  pointer-events: none;
}

.brand-logo {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--teal-600) 0%, var(--teal-800) 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(77,125,133,.4);
  position: relative;
  z-index: 1;
}
.brand-logo i { font-size: 22px; color: #fff; }

.brand-name {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.01em;
  line-height: 1.2;
}
.brand-sub {
  font-size: 11px;
  color: var(--teal-400);
  margin-top: 2px;
  font-weight: 500;
}

/* ── Nav ────────────────────────────────────────────────────── */
.sidebar-nav { flex: 1; padding: 12px 10px; }

.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding: 16px 10px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  font-size: 13px;
  color: rgba(255,255,255,.6);
  border-radius: var(--r-md);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  position: relative;
  margin-bottom: 2px;
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.92);
  transform: translateX(-2px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(77,125,133,.35) 0%, rgba(92,142,151,.2) 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(77,125,133,.2);
}

/* الخط الجانبي للـ active */
.nav-item.active::after {
  content: '';
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: linear-gradient(180deg, var(--teal-400), var(--teal-600));
  border-radius: 4px 0 0 4px;
}

.nav-badge {
  margin-inline-start: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-item i {
  font-size: 18px;
  flex-shrink: 0;
  opacity: .8;
  transition: opacity var(--t-fast);
}
.nav-item.active i,
.nav-item:hover i { opacity: 1; }

/* ── User Footer ─────────────────────────────────────────────── */
.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,.15);
}

.user-av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-600), var(--violet-600));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(226,114,90,.3);
}

.user-info { flex: 1; overflow: hidden; }
.user-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: var(--teal-400); font-weight: 500; }

.sidebar-logout {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: rgba(255,255,255,.4);
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-logout:hover {
  background: rgba(244,63,94,.15);
  color: var(--rose-400);
}
.sidebar-logout i { font-size: 17px; }

/* ══════════════════════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════════════════════ */
.main-content {
  margin-right: var(--sidebar-w);
  padding: 28px 30px;
  flex: 1;
  min-height: 100vh;
  max-width: calc(100vw - var(--sidebar-w));
}

/* ── Top Bar ────────────────────────────────────────────────── */
.header-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 26px;
  gap: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--color-text-1);
  letter-spacing: -.02em;
  line-height: 1.2;
}

.page-sub {
  font-size: 12px;
  color: var(--color-text-3);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-sub::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal-500);
  flex-shrink: 0;
}

.hd-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════
   METRIC CARDS  —  الـ signature element الرئيسي
══════════════════════════════════════════════════════════════ */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-xl);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--t-normal), box-shadow var(--t-normal);
  cursor: default;
}

.metric:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* الـ glow الخلفي لكل card — ده الـ signature */
.metric::before {
  content: '';
  position: absolute;
  top: -30px;
  left: -30px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  opacity: .08;
  transition: opacity var(--t-slow);
}
.metric:hover::before { opacity: .14; }

.metric.info::before    { background: var(--blue-500); }
.metric.success::before { background: var(--emerald-500); }
.metric.warning::before { background: var(--amber-500); }
.metric.danger::before  { background: var(--rose-500); }
.metric.teal::before    { background: var(--teal-500); }
.metric.violet::before  { background: var(--violet-500); }

/* أيقونة في كل metric */
.metric-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  flex-shrink: 0;
}
.metric-icon i { font-size: 22px; }

.metric.info    .metric-icon { background: #EAF3F4; color: var(--blue-600); }
.metric.success .metric-icon { background: #ecfdf5; color: var(--emerald-600); }
.metric.warning .metric-icon { background: #fffbeb; color: var(--amber-500); }
.metric.danger  .metric-icon { background: #fff1f2; color: var(--rose-600); }
.metric.teal    .metric-icon { background: #EAF3F4; color: var(--teal-600); }
.metric.violet  .metric-icon { background: #FBEAE4; color: var(--violet-600); }

.metric-label {
  font-size: 12px;
  color: var(--color-text-3);
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: .01em;
}

.metric-val {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--color-text-1);
  letter-spacing: -.02em;
  margin-bottom: 6px;
}

.metric.info    .metric-val { color: var(--blue-600); }
.metric.success .metric-val { color: var(--emerald-600); }
.metric.warning .metric-val { color: var(--amber-500); }
.metric.danger  .metric-val { color: var(--rose-600); }
.metric.teal    .metric-val { color: var(--teal-600); }
.metric.violet  .metric-val { color: var(--violet-600); }

.metric-sub {
  font-size: 11px;
  color: var(--color-text-3);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* الخط اللوني السفلي */
.metric::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  opacity: 0;
  transition: opacity var(--t-normal);
}
.metric:hover::after { opacity: 1; }
.metric.info::after    { background: linear-gradient(90deg, transparent, var(--blue-500)); }
.metric.success::after { background: linear-gradient(90deg, transparent, var(--emerald-500)); }
.metric.warning::after { background: linear-gradient(90deg, transparent, var(--amber-500)); }
.metric.danger::after  { background: linear-gradient(90deg, transparent, var(--rose-500)); }
.metric.teal::after    { background: linear-gradient(90deg, transparent, var(--teal-500)); }
.metric.violet::after  { background: linear-gradient(90deg, transparent, var(--violet-500)); }

/* ══════════════════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════════════════ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-xl);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t-normal);
}

.card:hover { box-shadow: var(--shadow-sm); }

.card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-1);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* الخط اللوني الجانبي للعنوان */
.card-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 16px;
  background: linear-gradient(180deg, var(--teal-500), var(--teal-700));
  border-radius: 2px;
  flex-shrink: 0;
}

/* Card Variants */
.card-info    { border-top: 3px solid var(--blue-500);    background: linear-gradient(180deg, #EAF3F4 0%, #fff 30%); }
.card-success { border-top: 3px solid var(--emerald-500); background: linear-gradient(180deg, #ecfdf5 0%, #fff 30%); }
.card-warning { border-top: 3px solid var(--amber-500);   background: linear-gradient(180deg, #fffbeb 0%, #fff 30%); }
.card-danger  { border-top: 3px solid var(--rose-500);    background: linear-gradient(180deg, #fff1f2 0%, #fff 30%); }
.card-teal    { border-top: 3px solid var(--teal-500);    background: linear-gradient(180deg, #EAF3F4 0%, #fff 30%); }

/* ══════════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--r-md);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 600;
  text-decoration: none;
  transition: all var(--t-fast);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  letter-spacing: .01em;
}

/* ripple effect */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.15);
  opacity: 0;
  transition: opacity var(--t-fast);
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--teal-600) 0%, var(--teal-700) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(77,125,133,.3);
}
.btn-primary:hover { box-shadow: 0 5px 16px rgba(77,125,133,.4); }

.btn-secondary {
  background: linear-gradient(135deg, var(--violet-500) 0%, var(--violet-600) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(226,114,90,.3);
}
.btn-secondary:hover { box-shadow: 0 5px 16px rgba(226,114,90,.4); }

.btn-success {
  background: linear-gradient(135deg, var(--emerald-500) 0%, var(--emerald-600) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(5,150,105,.3);
}

.btn-danger {
  background: linear-gradient(135deg, var(--rose-500) 0%, var(--rose-600) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(225,29,72,.25);
}

.btn-warning {
  background: linear-gradient(135deg, var(--amber-400) 0%, var(--amber-500) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(245,158,11,.25);
}

.btn-outline {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border-2);
  color: var(--color-text-2);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
  border-color: var(--teal-500);
  color: var(--teal-600);
  background: var(--teal-50);
}
.btn-outline::after { display: none; }

.btn-ghost {
  background: transparent;
  color: var(--color-text-2);
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text-1); }
.btn-ghost::after { display: none; }

/* Sizes */
.btn-sm { font-size: 12px; padding: 6px 12px; gap: 5px; }
.btn-lg { font-size: 15px; padding: 12px 24px; gap: 9px; border-radius: var(--r-lg); }
.btn-icon { padding: 9px; width: 38px; height: 38px; justify-content: center; }
.btn-icon.btn-sm { padding: 6px; width: 30px; height: 30px; }

.btn i { font-size: 16px; flex-shrink: 0; }
.btn-sm i { font-size: 14px; }
.btn-lg i { font-size: 18px; }

/* ══════════════════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════════════════ */
.table-wrap {
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead { background: var(--color-surface-2); }

th {
  padding: 12px 16px;
  text-align: right;
  font-weight: 700;
  font-size: 11px;
  color: var(--color-text-3);
  border-bottom: 1px solid var(--color-border);
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  padding: 13px 16px;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-1);
  vertical-align: middle;
  font-size: 13px;
}

tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background var(--t-fast);
}
tbody tr:hover td { background: #f8faff; }

/* ══════════════════════════════════════════════════════════════
   BADGES / STATUS PILLS
══════════════════════════════════════════════════════════════ */
.badge, .status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  letter-spacing: .01em;
}

.badge-info,    .s-inprog  { background: var(--c-info-bg);    color: var(--c-info-txt);    border: 1px solid var(--c-info-brd); }
.badge-success, .s-done    { background: var(--c-success-bg); color: var(--c-success-txt); border: 1px solid var(--c-success-brd); }
.badge-warning, .s-calling { background: var(--c-warn-bg);   color: var(--c-warn-txt);    border: 1px solid var(--c-warn-brd); }
.badge-danger               { background: var(--c-danger-bg); color: var(--c-danger-txt);  border: 1px solid var(--c-danger-brd); }
.badge-teal                 { background: #EAF3F4; color: var(--teal-700); border: 1px solid var(--teal-100); }
.badge-violet               { background: #FBEAE4; color: var(--violet-600); border: 1px solid #F3D4C8; }

.s-wait {
  background: #f8fafc;
  color: var(--color-text-2);
  border: 1px solid var(--color-border-2);
}

/* نقطة ملونة قبل النص */
.badge::before, .status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: currentColor;
}

/* ══════════════════════════════════════════════════════════════
   ALERTS
══════════════════════════════════════════════════════════════ */
.alert {
  padding: 13px 16px;
  border-radius: var(--r-lg);
  font-size: 13px;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid transparent;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

.alert::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.alert i { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--c-success-bg); color: var(--c-success-txt); border-color: var(--c-success-brd); }
.alert-success::before { background: var(--emerald-500); }

.alert-danger,
.alert-error { background: var(--c-danger-bg); color: var(--c-danger-txt); border-color: var(--c-danger-brd); }
.alert-danger::before,
.alert-error::before { background: var(--rose-500); }

.alert-warning { background: var(--c-warn-bg); color: var(--c-warn-txt); border-color: var(--c-warn-brd); }
.alert-warning::before { background: var(--amber-500); }

.alert-info { background: var(--c-info-bg); color: var(--c-info-txt); border-color: var(--c-info-brd); }
.alert-info::before { background: var(--blue-500); }

.alert-teal { background: var(--teal-50); color: var(--teal-700); border-color: var(--teal-100); }
.alert-teal::before { background: var(--teal-500); }

/* ══════════════════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 7px;
  color: var(--color-text-1);
}

.form-label .req { color: var(--rose-500); margin-right: 2px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 13px;
  color: var(--color-text-1);
  background: var(--color-surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  outline: none;
}

.form-control:hover { border-color: var(--color-border-2); }

.form-control:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(92,142,151,.12);
  background: #fff;
}

.form-control::placeholder { color: #c1cdd6; }
select.form-control { cursor: pointer; }

.form-hint {
  font-size: 11.5px;
  color: var(--color-text-3);
  margin-top: 5px;
}

/* Input with icon */
.input-wrap { position: relative; }
.input-wrap .input-icon {
  position: absolute;
  top: 50%;
  right: 13px;
  transform: translateY(-50%);
  font-size: 17px;
  color: var(--color-text-3);
  pointer-events: none;
  transition: color var(--t-fast);
}
.input-wrap .form-control:focus ~ .input-icon,
.input-wrap .form-control:focus + .input-icon { color: var(--teal-500); }
.input-wrap .form-control { padding-right: 40px; }

/* Grid helpers */
.form-row {
  display: grid;
  gap: 16px;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ══════════════════════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(22,40,58,.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .2s ease;
}

.modal-overlay.open { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-box {
  background: var(--color-surface);
  border-radius: var(--r-2xl);
  padding: 28px;
  width: 500px;
  max-width: 94vw;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xl);
  animation: slideUp .25s ease;
}

.modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--color-text-1);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  cursor: pointer;
  color: var(--color-text-2);
  transition: all var(--t-fast);
}
.modal-close:hover { background: var(--c-danger-bg); color: var(--rose-500); border-color: var(--c-danger-brd); }
.modal-close i { font-size: 17px; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* ══════════════════════════════════════════════════════════════
   QUEUE  —  صفحة الطابور
══════════════════════════════════════════════════════════════ */
.num-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}
.num-active {
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  color: #fff;
  box-shadow: 0 2px 8px rgba(77,125,133,.35);
}
.num-wait {
  background: var(--color-surface-2);
  color: var(--color-text-2);
  border: 1.5px solid var(--color-border-2);
}
.num-done {
  background: var(--c-success-bg);
  color: var(--c-success-txt);
  border: 1.5px solid var(--c-success-brd);
}

/* بطاقة الدور الحالي الكبيرة */
.curr-ticket {
  font-size: 72px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  text-align: center;
  letter-spacing: -.04em;
}

/* ══════════════════════════════════════════════════════════════
   APPOINTMENT DOTS
══════════════════════════════════════════════════════════════ */
.appt-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-exam    { background: var(--blue-500); }
.dot-follow  { background: var(--emerald-500); }
.dot-proc    { background: var(--amber-500); }

/* ══════════════════════════════════════════════════════════════
   EMPTY STATES
══════════════════════════════════════════════════════════════ */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-3);
}

.empty-state i {
  font-size: 52px;
  display: block;
  margin-bottom: 12px;
  opacity: .5;
}

.empty-state p {
  font-size: 14px;
  font-weight: 500;
}

.empty-state small {
  display: block;
  font-size: 12px;
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════════ */
.login-page {
  display: flex;
  min-height: 100vh;
  background: linear-gradient(135deg, #12283D 0%, #1F3A40 50%, #1B3A54 100%);
  position: relative;
  overflow: hidden;
}

/* Animated background circles */
.login-page::before,
.login-page::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  opacity: .06;
}
.login-page::before {
  width: 600px;
  height: 600px;
  background: var(--teal-500);
  top: -200px;
  left: -200px;
  animation: pulse 8s ease-in-out infinite;
}
.login-page::after {
  width: 400px;
  height: 400px;
  background: var(--violet-500);
  bottom: -100px;
  right: -100px;
  animation: pulse 6s ease-in-out infinite reverse;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.login-wrap {
  width: 100%;
  max-width: 440px;
  margin: auto;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login-logo { text-align: center; margin-bottom: 28px; }

.login-logo-icon {
  height: 76px;
  padding: 6px 16px;
  background: #FCF8F0;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(22,40,58,.4);
}
.login-logo-icon img { height: 100%; width: auto; display: block; }

.login-logo-name {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -.02em;
}
.login-logo-sub {
  font-size: 13px;
  color: rgba(255,255,255,.5);
  margin-top: 4px;
}

.login-card {
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--r-2xl);
  padding: 32px;
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(10px);
}

.login-card h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--color-text-1);
  margin-bottom: 6px;
}

.login-card .login-sub {
  font-size: 13px;
  color: var(--color-text-3);
  margin-bottom: 24px;
}

.btn-login {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  margin-top: 8px;
  border-radius: var(--r-lg);
}

/* ══════════════════════════════════════════════════════════════
   DIVIDERS / SECTION
══════════════════════════════════════════════════════════════ */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 18px 0;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-text-3);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ══════════════════════════════════════════════════════════════
   PAGE-LEVEL HELPERS
══════════════════════════════════════════════════════════════ */
.text-primary   { color: var(--color-text-1); }
.text-secondary { color: var(--color-text-2); }
.text-muted     { color: var(--color-text-3); }
.text-teal      { color: var(--teal-600); }
.text-success   { color: var(--c-success-txt); }
.text-warning   { color: var(--c-warn-txt); }
.text-danger    { color: var(--c-danger-txt); }
.text-info      { color: var(--c-info-txt); }

.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

.fs-11 { font-size: 11px; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.fs-14 { font-size: 14px; }
.fs-16 { font-size: 16px; }
.fs-18 { font-size: 18px; }
.fs-20 { font-size: 20px; }

.d-flex    { display: flex; }
.d-grid    { display: grid; }
.align-center { align-items: center; }
.gap-6  { gap: 6px; }
.gap-8  { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-14 { gap: 14px; }
.gap-16 { gap: 16px; }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* ══════════════════════════════════════════════════════════════
   SCROLLBAR
══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

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

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE  —  الموبايل والتابلت
   ─────────────────────────────────────────────────────────────
   ملاحظات مهمة:
   • أغلب الصفحات فيها grid/flex مكتوب inline (style="...") أو داخل
     <style> فى الصفحة نفسها، وده بيتحمّل بعد app.css — عشان كده
     قواعد الموبايل هنا بتستخدم !important وبتستهدف الـ inline styles
     بـ attribute selectors ([style*="..."]). لو كتبت grid جديد inline
     بنفس الصيغة (بدون مسافة بعد النقطتين) هيتظبط لوحده.
     تنبيه: الـ attribute selectors بتشتغل على الـ style الأصلي بس؛ لو JS عدّل
     style العنصر (زي style.display='flex') المتصفح بيعيد كتابته بمسافات وبيبوّظ
     المطابقة — عشان كده النوافذ اللى بتتفتح بـ JS لازم تاخد class (.modal-overlay
     أو .sheet-overlay) مش تعتمد على الـ attribute selector.
   • الجداول بتتلف تلقائيًا بـ .table-scroll من app.js (لو الصفحة مش بتحمّل app.js
     لفّ الجدول بنفسك: <div class="table-scroll"><table>…</table></div>).
   • Breakpoints:  ≤1100px تابلت أفقي/لاب توب صغير · ≤900px تابلت/موبايل (القائمة
     الجانبية بتتحوّل لدُرج) · ≤600px موبايل · ≤480px/≤380px شاشات صغيرة.
══════════════════════════════════════════════════════════════ */

/* ── أساسيات تنفع على كل الشاشات ─────────────────────────────── */
.main-content { min-width: 0; }                 /* يمنع تمدّد الـ flex child بسبب جدول/نص طويل */
img, video, canvas, svg, iframe { max-width: 100%; }
img, video { height: auto; }
.mobile-topbar, .sidebar-backdrop { display: none; }

/* غلاف الجداول (بيتضاف تلقائيًا من app.js حوالين أي <table>) */
.table-scroll { max-width: 100%; }
.table-wrap   { overflow-x: auto; -webkit-overflow-scrolling: touch; }

a, button, .btn, label, select, summary { touch-action: manipulation; }

/* ── تابلت أفقي / لاب توب صغير ───────────────────────────────── */
@media (max-width: 1100px) {
  :root { --sidebar-w: 216px; }
  .main-content { padding: 24px 22px; }
  .metrics { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 14px; }

  /* الـ layouts المقسومة (محتوى + عمود جانبي 280-340px) بتضيق قوي مع القائمة الظاهرة —
     بنكدّسها من هنا بدل ما العمود الجانبي يتزاح برا الشاشة (لاحظنا ده على 1024px) */
  [style*="1fr 300px"], [style*="1fr 340px"], [style*="1fr 320px"], [style*="1fr 280px"],
  [style*="1.4fr 1fr"],
  .exam-grid, .pc-wrap {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  [style*="display:grid"] > *, .exam-grid > *, .pc-wrap > * { min-width: 0; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ══════════════════════════════════════════════════════════════
   ≤ 900px  —  القائمة الجانبية تبقى دُرج + كل الـ layouts بتتكدّس
══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  :root {
    --topbar-h: 56px;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
  }

  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
  body.sidebar-open { overflow: hidden; }

  /* ── الـ layout ───────────────────────────────────────────── */
  .layout { display: block; min-height: 100vh; }

  .main-content {
    margin-right: 0;
    max-width: 100%;
    min-height: 100vh;
    padding: calc(var(--topbar-h) + var(--safe-t) + 16px)
             max(14px, var(--safe-l))
             calc(28px + var(--safe-b))
             max(14px, var(--safe-r));
  }

  /* ── شريط الموبايل العلوي (زر القائمة) ────────────────────── */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    top: 0; right: 0; left: 0;
    z-index: 150;            /* أقل من المودالات (200+) وأعلى من المحتوى */
    height: calc(var(--topbar-h) + var(--safe-t));
    padding: var(--safe-t) max(10px, var(--safe-r)) 0 max(10px, var(--safe-l));
    background: linear-gradient(90deg, var(--sidebar-bg-from), var(--sidebar-bg-to));
    box-shadow: 0 2px 14px rgba(0,0,0,.22);
  }
  .mobile-menu-btn {
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    /* حدّ خفيف دايمًا ظاهر — حتى لو أي CSS تاني ما اتحمّلش، برضو واضح إنه زرار */
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 12px; cursor: pointer;
    background: rgba(255,255,255,.09);
    color: #fff;
    flex-shrink: 0;
    transition: background var(--t-fast), transform var(--t-fast);
  }
  .mobile-menu-btn:active { background: rgba(255,255,255,.18); transform: scale(.95); }
  .mobile-menu-btn i { font-size: 24px; }
  .mobile-menu-btn svg { display: block; }
  .mobile-topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .brand-logo-sm { width: 32px; height: 32px; border-radius: 9px; }
  .brand-logo-sm i { font-size: 17px; }
  .mobile-topbar-name {
    font-size: 15px; font-weight: 800; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* ── القائمة الجانبية كدُرج ───────────────────────────────── */
  .sidebar {
    width: min(84vw, 300px);
    height: 100vh;
    height: 100dvh;
    z-index: 400;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .28s cubic-bezier(.4,0,.2,1), visibility 0s linear .28s;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-top: var(--safe-t);
  }
  body.sidebar-open .sidebar {
    transform: none;
    visibility: visible;
    transition-delay: 0s;
    box-shadow: -14px 0 44px rgba(0,0,0,.4);
  }
  .sidebar-nav { padding: 10px 12px; }
  .nav-item { padding: 12px 14px; font-size: 14px; min-height: 46px; }
  .nav-item.active::after { right: -12px; }
  .sidebar-user { padding: 14px 16px calc(14px + var(--safe-b)); }
  .sidebar-logout { width: 40px; height: 40px; }

  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    z-index: 390;
    background: rgba(10,22,34,.55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  /* ── ترويسة الصفحة ─────────────────────────────────────────── */
  .header-bar { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 18px; }
  .page-title { font-size: 20px; }
  .hd-actions { flex-wrap: wrap; width: 100%; }
  .hd-actions > .btn, .hd-actions > a.btn, .hd-actions > form { flex: 1 1 auto; justify-content: center; }

  /* ── كروت ومتريكس ──────────────────────────────────────────── */
  .metrics { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)) !important; gap: 10px; margin-bottom: 18px; }
  .metric  { padding: 14px; border-radius: var(--r-lg); }
  .metric-icon { width: 36px; height: 36px; margin-bottom: 10px; }
  .metric-icon i { font-size: 19px; }
  .metric-val { font-size: 24px; }
  .card { padding: 16px; border-radius: var(--r-lg); }
  .card-hd { flex-wrap: wrap; margin-bottom: 14px; }

  /* ── الـ layouts المقسومة (محتوى + عمود جانبي) → عمود واحد ──── */
  [style*="1fr 300px"], [style*="1fr 340px"], [style*="1fr 320px"], [style*="1fr 280px"],
  [style*="1.4fr 1fr"],
  .exam-grid, .pc-wrap {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* الأطفال داخل الـ grid لازم يقدروا يضيقوا (وإلا الجدول بيفرد الصفحة) */
  [style*="display:grid"] > *, .exam-grid > *, .pc-wrap > * { min-width: 0; }

  /* شبكات الكروت المتكررة */
  .board-grid, .clinics-board { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)) !important; }
  .session-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .session-status-card { flex-wrap: wrap; padding: 18px; gap: 14px; }

  /* ── الجداول: سكرول أفقي بدل ما تكسر الصفحة ─────────────────── */
  .main-content table,
  .table-scroll > table { max-width: none; }
  .table-scroll,
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    /* ظلال خفيفة على الأطراف بتظهر بس لو فى محتوى مخفي */
    background:
      linear-gradient(to right, #fff 30%, rgba(255,255,255,0)) 0 0 / 28px 100% no-repeat local,
      linear-gradient(to left,  #fff 30%, rgba(255,255,255,0)) 100% 0 / 28px 100% no-repeat local,
      linear-gradient(to right, rgba(22,40,58,.16), rgba(22,40,58,0)) 0 0 / 12px 100% no-repeat scroll,
      linear-gradient(to left,  rgba(22,40,58,.16), rgba(22,40,58,0)) 100% 0 / 12px 100% no-repeat scroll;
  }
  .table-scroll > table { min-width: calc(var(--cols, 4) * 108px); }
  /* احتياطي لحد ما app.js يلف الجدول (يمنع أي وميض/تمدد للصفحة) */
  .main-content table:not(.table-scroll > table) { display: block; overflow-x: auto; max-width: 100%; }
  th, td { padding: 11px 12px; }

  /* ── نوافذ الحوار → Bottom Sheet ────────────────────────────── */
  /* .sheet-overlay = المودالات المكتوبة inline (بنستخدم class مش attribute selector
     لأن المتصفح بيعيد كتابة style="" بعد ما JS يعمل style.display='flex') */
  .modal-overlay,
  .sheet-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .modal-overlay > *,
  .sheet-overlay > * {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 20px 20px 0 0 !important;
    padding-bottom: calc(24px + var(--safe-b)) !important;
    animation: sheetUp .28s cubic-bezier(.2,.8,.2,1);
  }
  .modal-box { padding: 20px 18px; }
  .modal-close, .modal-hd .modal-close { width: 38px; height: 38px; }

  /* ── نماذج ولمس ─────────────────────────────────────────────── */
  /* iOS بيعمل zoom تلقائي لو الـ input أصغر من 16px */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select, textarea, .form-control { font-size: 16px !important; }
  .form-control { padding: 11px 14px; min-height: 44px; }
  textarea.form-control { min-height: 88px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .btn-icon { width: 42px; height: 42px; }
  .btn-icon.btn-sm { width: 36px; height: 36px; }
  .act-btn { width: 36px !important; height: 36px !important; }

  /* الـ 4 خانات المتجاورة (شريط إحصائيات) → 2×2 */
  [style*="grid-template-columns:1fr 1fr 1fr 1fr"] { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  [style*="grid-template-columns:1fr 1fr 1fr 1fr"] > div:nth-child(2n) { border-left: none !important; }
  [style*="grid-template-columns:1fr 1fr 1fr 1fr"] > div:nth-child(-n+2) { border-bottom: 0.5px solid var(--color-border-tertiary); }

  /* الدور الحالى الكبير */
  .curr-ticket { font-size: 60px; }
}

@keyframes sheetUp {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════
   ≤ 600px  —  موبايل
══════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .main-content { padding-right: max(12px, var(--safe-r)); padding-left: max(12px, var(--safe-l)); }
  .page-title { font-size: 18px; }
  .card { padding: 14px; margin-bottom: 14px; }
  .card-title { font-size: 14px; }

  /* الأعمدة المزدوجة (حقول النماذج) → عمود واحد */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  .form-row-2, .form-row-3 {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* ...لكن شريط الإحصائيات 4 خانات يفضل 2×2 (أخصّ من القاعدة اللى فوق) */
  [style*="grid-template-columns:1fr 1fr 1fr 1fr"] { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }

  /* أزرار طريقة الدفع (5 خيارات) → 3 فى الصف */
  [style*="repeat(5,1fr)"]:not(.metrics),
  [style*="repeat(3, 1fr)"] { grid-template-columns: repeat(3, minmax(0,1fr)) !important; }

  /* متريكس: دايمًا عمودين على الموبايل، والكارت الفردي الأخير ياخد العرض كله */
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .metrics > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .metric-val { font-size: 22px; }
  .metric-label { font-size: 11.5px; }

  /* صفوف الأزرار جوه الكروت */
  .card .btn-lg { width: 100%; justify-content: center; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1 1 auto; justify-content: center; }

  .login-page { min-height: 100vh; min-height: 100dvh; }
  .login-wrap { padding: 16px; }
  .login-card { padding: 24px 20px; }
  .login-logo-icon { height: 64px; }
  .empty-state { padding: 34px 14px; }
  .empty-state i { font-size: 44px; }
}

/* ══════════════════════════════════════════════════════════════
   ≤ 380px  —  شاشات صغيرة جدًا
══════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  .metrics { gap: 8px; }
  .metric  { padding: 12px; }
  .metric-val { font-size: 20px; }
  .mobile-topbar-name { font-size: 14px; }
  .btn { padding-left: 14px; padding-right: 14px; }
}

/* ── أجهزة اللمس: منع الـ hover اللاصق ─────────────────────────── */
@media (hover: none) {
  .metric:hover { transform: none; box-shadow: none; }
  .metric:hover::before { opacity: .08; }
  .card:hover { box-shadow: var(--shadow-xs); }
  .nav-item:hover { transform: none; }
  .btn:hover::after { opacity: 0; }
}

/* ── وضع أفقي على الموبايل (ارتفاع قليل) ─────────────────────────── */
@media (max-width: 900px) and (max-height: 480px) {
  .mobile-topbar { height: calc(48px + var(--safe-t)); }
  .main-content { padding-top: calc(48px + var(--safe-t) + 12px); }
  .modal-overlay > *, .sheet-overlay > * { max-height: 96vh; max-height: 96dvh; }
}

/* ── Toast على الموبايل ──────────────────────────────────────── */
@media (max-width: 600px) {
  #toast-container {
    left: 12px !important; right: 12px !important;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
    max-width: none !important;
  }
  #toast-container .alert { min-width: 0 !important; }
}

/* ── شبكة أمان للشاشات الصغيرة: صفوف الـ flex المكتوبة inline تلتف بدل ما تفرد الصفحة ── */
@media (max-width: 480px) {
  [style*="display:flex"][style*="gap"]:not([style*="flex-wrap"]):not([style*="flex-direction:column"]):not([style*="flex:1"]) {
    flex-wrap: wrap;
  }
  .filters { flex-wrap: wrap; }
}


/* ── مبدّل نوع الحساب (إداري / طبيب) للحساب المزدوج ── */
.mode-switch {
  display: flex;
  gap: 4px;
  margin: 10px 12px 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .08);
}
.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, .88);
  opacity: .75;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, opacity .15s;
}
.mode-btn:hover { opacity: 1; }
.mode-btn.active {
  opacity: 1;
  background: rgba(255, 255, 255, .95);
  color: #16283A;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}

/* ═══════════════════════════════════════════════════════════
   لوحة المركز (center dashboard)
   ═══════════════════════════════════════════════════════════ */
.ctr-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.ctr-stat { position: relative; background: var(--color-background-primary, #fff); border: 1px solid var(--color-border-tertiary, #e5e7eb);
  border-radius: 16px; padding: 14px 16px; overflow: hidden; }
.ctr-stat > i { position: absolute; left: 12px; top: 12px; font-size: 26px; opacity: .18; }
.ctr-stat-n { font-size: 30px; font-weight: 800; line-height: 1.1; }
.ctr-stat-l { font-size: 12px; color: var(--color-text-secondary, #6b7280); margin-top: 4px; }
.ctr-stat.c-blue   { border-top: 3px solid #2f6fed; } .ctr-stat.c-blue   .ctr-stat-n { color: #2f6fed; }
.ctr-stat.c-amber  { border-top: 3px solid #e59a00; } .ctr-stat.c-amber  .ctr-stat-n { color: #c77f00; }
.ctr-stat.c-violet { border-top: 3px solid #7c4dff; } .ctr-stat.c-violet .ctr-stat-n { color: #6d3df0; }
.ctr-stat.c-green  { border-top: 3px solid #1f9d63; } .ctr-stat.c-green  .ctr-stat-n { color: #1a8a56; }
.ctr-stat.c-red    { border-top: 3px solid #e5484d; } .ctr-stat.c-red    .ctr-stat-n { color: #d23b40; }

.ctr-card { margin-bottom: 16px; }
.ctr-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ctr-title { font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.ctr-title i { color: var(--color-text-info, #2f6fed); }
.ctr-date { font-size: 20px; font-weight: 800; margin-top: 4px; }
.ctr-total { font-size: 12px; font-weight: 700; background: #fff4da; color: #8a5a00; padding: 4px 10px; border-radius: 20px; }
.ctr-empty { text-align: center; color: var(--color-text-secondary, #6b7280); padding: 18px 8px; font-size: 13px; }
.ctr-empty i { display: block; font-size: 26px; opacity: .45; margin-bottom: 4px; }
.ctr-empty-sm { padding: 8px; font-size: 12px; }

.ctr-row { display: grid; grid-template-columns: minmax(150px, 1.3fr) minmax(150px, 1.4fr) auto auto; align-items: center; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--color-border-tertiary, #eceff3); }
.ctr-clinic { font-weight: 700; font-size: 14px; }
.ctr-doc { font-size: 12px; color: var(--color-text-secondary, #6b7280); margin-top: 2px; }
.ctr-times { display: flex; gap: 6px; flex-wrap: wrap; }
.ctr-time { display: inline-flex; align-items: center; gap: 4px; background: #eaf1ff; color: #2452b3; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.ctr-time-off { background: #f3f4f6; color: #6b7280; }
.ctr-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.ctr-b { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; background: #f3f4f6; color: #4b5563; white-space: nowrap; }
.ctr-b-open { background: #dcfce7; color: #166534; } .ctr-b-wait { background: #fef3c7; color: #92400e; }
.ctr-ctl { white-space: nowrap; }
.ctr-day-h { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 2px; padding: 8px 12px;
  background: var(--color-background-secondary, #f6f7f9); border-radius: 10px; font-weight: 800; font-size: 13px; }
.ctr-day-c { font-size: 11px; font-weight: 600; color: var(--color-text-secondary, #6b7280); }
.ctr-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.ctr-nav-sp { flex: 1; }
.ctr-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--color-border-tertiary, #eceff3); }
.ctr-all { width: 100%; justify-content: center; margin-top: 14px; padding: 12px; font-size: 14px; }

/* التقويم */
.ctr-cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-wd { text-align: center; font-size: 11px; font-weight: 700; color: var(--color-text-secondary, #6b7280); padding: 4px 0; }
.cal-blank { min-height: 54px; }
.cal-day { position: relative; min-height: 54px; border-radius: 12px; border: 2px solid transparent; background: var(--color-background-secondary, #f6f7f9);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: inherit;
  transition: transform .12s, box-shadow .12s; }
.cal-day:hover, .cal-day:focus-visible { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(20, 40, 80, .14); outline: 0; }
.cal-n { font-weight: 700; font-size: 14px; }
.cal-day.has-sched { border-color: #2f6fed; background: #f5f9ff; }          /* إطار أزرق: مواعيد عيادات */
.cal-day.is-today .cal-n { background: #16283a; color: #fff; border-radius: 50%; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; }
.cal-dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: #e5484d; box-shadow: 0 0 0 2px #fff; } /* نقطة حمراء: حجوزات */
.cal-cnt { font-size: 10px; font-weight: 700; color: #b42328; }
.cal-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--color-text-secondary, #6b7280); margin-top: 12px; }
.cal-lg { display: inline-block; vertical-align: middle; margin-inline-end: 4px; }
.cal-lg-dot { width: 10px; height: 10px; border-radius: 50%; background: #e5484d; }
.cal-lg-box { width: 14px; height: 14px; border: 2px solid #2f6fed; border-radius: 4px; }
.cal-lg-today { width: 14px; height: 14px; border-radius: 50%; background: #16283a; }
.cal-pop { position: absolute; z-index: 60; width: 270px; max-width: calc(100vw - 16px); background: #fff; border: 1px solid #dbe2ec; border-radius: 14px;
  box-shadow: 0 12px 34px rgba(20, 40, 80, .22); padding: 12px 14px; font-size: 12px; pointer-events: none; }
.cal-pop[hidden] { display: none; }
.pop-h { font-weight: 800; font-size: 13px; margin-bottom: 4px; } .pop-sum { margin-bottom: 8px; } .pop-pend { color: #b45309; font-weight: 700; }
.pop-none { color: #6b7280; } .pop-c { padding: 7px 0; border-top: 1px solid #eef1f5; } .pop-cn { font-weight: 700; } .pop-cd, .pop-ct { color: #4b5563; margin-top: 1px; }
.pop-cb { color: #b42328; font-weight: 700; margin-top: 2px; } .pop-f { margin-top: 8px; padding-top: 6px; border-top: 1px dashed #dbe2ec; color: #2f6fed; font-weight: 700; }

/* طابور الانتظار العام */
.q-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.q-card { display: block; text-decoration: none; color: inherit; border: 1px solid var(--color-border-tertiary, #e5e7eb); border-radius: 14px; padding: 14px;
  background: var(--color-background-primary, #fff); transition: box-shadow .15s, transform .15s; }
.q-card:hover { box-shadow: 0 6px 20px rgba(20, 40, 80, .12); transform: translateY(-2px); }
.q-card.is-open { border-color: #86d9ac; background: linear-gradient(180deg, #f3fcf7, #fff 60%); }
.q-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.q-count { text-align: center; font-size: 26px; font-weight: 800; color: #c77f00; line-height: 1; } .q-count small { display: block; font-size: 10px; font-weight: 600; color: #6b7280; margin-top: 3px; }
.q-now { margin-top: 10px; font-size: 12px; background: #efe9ff; color: #5b2fd6; padding: 6px 10px; border-radius: 10px; }
.q-list { margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; } .q-list li { padding: 4px 0; display: flex; gap: 8px; align-items: center; }
.q-list em { font-style: normal; font-size: 10px; background: #fef3c7; color: #92400e; padding: 1px 6px; border-radius: 10px; }
.q-no { display: inline-flex; min-width: 22px; height: 22px; padding: 0 6px; align-items: center; justify-content: center; border-radius: 11px; background: #16283a; color: #fff; font-size: 11px; font-weight: 700; }
.q-more, .q-none { font-size: 12px; color: #6b7280; margin-top: 8px; }

@media (max-width: 900px) {
  .ctr-stats { grid-template-columns: repeat(3, 1fr); }
  .ctr-row { grid-template-columns: 1fr auto; }
  .ctr-row .ctr-times, .ctr-row .ctr-badges { grid-column: 1 / -1; }
  .ctr-row .ctr-ctl { grid-row: 1; grid-column: 2; }
}
@media (max-width: 560px) {
  .ctr-stats { grid-template-columns: repeat(2, 1fr); }
  .ctr-stat:first-child { grid-column: 1 / -1; }
  .cal-grid { gap: 4px; } .cal-day { min-height: 46px; border-radius: 10px; } .cal-n { font-size: 13px; }
  .ctr-date { font-size: 17px; }
}

/* ═══ القائمة الجانبية المنسدلة (لوحة القسم + فروعها) ═══ */
.nav-group { margin: 2px 0; }
.nav-row { display: flex; align-items: center; gap: 2px; }
.nav-row .nav-item { flex: 1; min-width: 0; }
.nav-toggle { flex: 0 0 auto; width: 30px; height: 34px; border: 0; background: transparent; color: rgba(255,255,255,.7); cursor: pointer; border-radius: 8px; }
.nav-toggle:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-toggle i { transition: transform .2s; display: inline-block; }
.nav-group.open .nav-toggle i { transform: rotate(180deg); }
.nav-children { display: none; margin: 2px 14px 6px 0; padding-right: 10px; border-right: 2px solid rgba(255,255,255,.14); }
.nav-group.open .nav-children { display: block; }
.nav-sub { display: flex; align-items: center; gap: 8px; padding: 7px 10px; margin: 1px 0; border-radius: 9px; font-size: 12.5px;
  color: rgba(255,255,255,.72); text-decoration: none; transition: background .15s, color .15s; }
.nav-sub i { font-size: 15px; opacity: .85; }
.nav-sub:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-sub.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 700; }
.nav-sub .nav-badge { margin-inline-start: auto; }

/* ═══ فتات التنقل + صفحات الأقسام (hubs) ═══ */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--color-text-secondary, #6b7280); margin-bottom: 8px; }
.crumbs a { color: var(--color-text-info, #2f6fed); text-decoration: none; font-weight: 600; } .crumbs a:hover { text-decoration: underline; }
.crumbs span { font-weight: 700; color: var(--color-text-primary, #1f2937); } .crumbs i { font-size: 12px; opacity: .6; }

.hub-strip { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 14px;
  background: #ecf7f0; border: 1px solid #b9e3c9; border-radius: 14px; font-size: 13px; }
.hub-strip.is-warn { background: #fff4e0; border-color: #f3cf8e; } .hub-strip-sub { color: #6b7280; font-size: 12px; }
.hub-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.hub-search { position: relative; flex: 1; min-width: 220px; } .hub-search i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); opacity: .5; }
.hub-search input { width: 100%; padding: 11px 38px 11px 12px; border: 1.5px solid var(--color-border-secondary, #d6dbe3); border-radius: 12px; font: inherit; background: #fff; }
.hub-search input:focus { outline: 0; border-color: #2f6fed; box-shadow: 0 0 0 3px rgba(47, 111, 237, .15); }
.hub-group { background: var(--color-background-primary, #fff); border: 1px solid var(--color-border-tertiary, #e5e7eb); border-radius: 16px; margin-bottom: 12px; overflow: hidden; }
.hub-group > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 14px 16px; font-weight: 800; font-size: 14px; }
.hub-group > summary::-webkit-details-marker { display: none; }
.hub-group > summary > i:first-child { color: #2f6fed; font-size: 18px; }
.hub-count { font-size: 11px; font-weight: 700; background: #eef2f7; color: #4b5563; padding: 1px 8px; border-radius: 10px; }
.hub-chev { margin-inline-start: auto; transition: transform .2s; opacity: .55; } .hub-group[open] .hub-chev { transform: rotate(180deg); }
.hub-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; padding: 0 14px 14px; }
.hub-tile { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--color-border-tertiary, #e5e7eb);
  border-radius: 14px; text-decoration: none; color: inherit; background: var(--color-background-secondary, #f8fafc); transition: transform .12s, box-shadow .12s, border-color .12s; }
.hub-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(20, 40, 80, .12); border-color: #9bb8f5; background: #fff; }
.hub-ic { flex: 0 0 auto; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: #e6eeff; color: #2452b3; font-size: 20px; }
.hub-tx { display: flex; flex-direction: column; min-width: 0; } .hub-tx b { font-size: 13.5px; } .hub-tx small { font-size: 11.5px; color: var(--color-text-secondary, #6b7280); margin-top: 2px; }
.hub-go { margin-inline-start: auto; opacity: .35; } .hub-badge { position: absolute; top: 8px; left: 10px; }

.nav-sub-h { font-size: 10.5px; font-weight: 700; letter-spacing: .3px; color: rgba(255,255,255,.45); padding: 9px 10px 3px; }
.nav-sub-h:first-child { padding-top: 4px; }

/* ═════ هوية زيارة الجديدة (بترولي · تيل · نعناعي · لافندر · مشمشي) — تُطبَّق على كل لوحات النظام ═════ */
:root{
  --teal-50:#EAF4F2; --teal-100:#D3E8E4; --teal-400:#5FA3A8; --teal-500:#2A8089; --teal-600:#237078; --teal-700:#1D5F68; --teal-800:#164A52; --teal-900:#0F2F3A;
  --violet-400:#F5B57A; --violet-500:#F0A35E; --violet-600:#D9853A;
  --color-bg:#EEF3F1; --color-surface-2:#F6F9F8; --color-text-1:#12303B;
  --c-info-bg:#E7EAF6; --c-info-txt:#2E2A57; --c-info-brd:#C9CEE8;
  --sidebar-bg-from:#0F2F3A; --sidebar-bg-to:#12384A;
}
.brand-logo{background:var(--teal-500);box-shadow:none}
.user-av{background:#2E2A57}
.btn-primary{background:var(--teal-600);box-shadow:none}
.btn-primary:hover{background:var(--teal-700);box-shadow:none}
.btn-secondary{background:var(--violet-500);color:#0F2F3A;box-shadow:none}
.btn-secondary:hover{background:var(--violet-400);box-shadow:none}
.card-teal{background:#fff;border-top:3px solid var(--teal-500)}
.metric.violet::after{background:var(--violet-500)}


/* صف جدول قابل للضغط بالكامل (مثل سجل الجلسات) */
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--color-background-secondary, #f1f5f8); }
tr.row-link:focus-visible { outline: 2px solid var(--color-text-info, #3D6870); outline-offset: -2px; }
tr.row-link .row-chev { color: var(--color-text-secondary); opacity: .5; font-size: 14px; }
tr.row-link:hover .row-chev { opacity: 1; }

/* شارة العلامة (أيقونة زيارة) فى الشريط الجانبى والهيدر المحمول */
.brand-logo.brand-logo-img{background:transparent;box-shadow:none;padding:0;overflow:hidden}
.brand-logo.brand-logo-img img{width:100%;height:100%;display:block;object-fit:contain}
