/* ========================================================================== 
   تعافي كلينك v2.0 — نظام التصميم العصري (Healthcare Modern UI System)
   ========================================================================== */

.doctor-files-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 2px 0;
}

.doctor-files-link:hover {
  text-decoration: underline;
}

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

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

:root {
  /* الألوان الرئيسية - Medical & Archive Theme */
  --navy:         #0A192F;
  --navy-surface: #112240;
  --navy-border:  rgba(255, 255, 255, 0.08);
  
  --primary:      #0284C7;  /* Cyan / Blue */
  --primary-hover:#0369A1;
  --primary-lt:   #E0F2FE;
  --primary-text: #0369A1;

  --accent:       #0D9488;  /* Teal */
  --accent-lt:    #CCFBF1;

  --gold:         #D97706;  /* Amber / Gold */
  --gold-lt:      #FEF3C7;

  --success:      #059669;
  --success-hover:#047857;
  --success-lt:   #D1FAE5;
  --success-text: #065F46;

  --danger:       #DC2626;
  --danger-hover: #B91C1C;
  --danger-lt:    #FEE2E2;
  --danger-text:  #991B1B;

  --warning:      #D97706;
  --warning-lt:   #FEF3C7;
  --warning-text: #92400E;

  /* تدرجات الرمادي والخلفيات - Light Mode */
  --bg-app:       #F1F5F9;
  --bg-card:      #FFFFFF;
  --bg-surface:   #FFFFFF;
  --bg-input:     #F8FAFC;
  --border:       #E2E8F0;
  --border-focus: #0284C7;

  --text-main:    #0F172A;
  --text-muted:   #64748B;
  --text-light:   #94A3B8;

  --shadow-sm:    0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:    0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg:    0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl:    0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --radius-xl:    20px;
  --radius-full:  9999px;

  --sidebar-w:    260px;
  --topbar-h:     68px;
  --drawer-w:     440px;
}

/* ── الوضع الداكن (Dark Mode) ── */
body.theme-dark {
  --bg-app:       #0B132B;
  --bg-card:      #1C2541;
  --bg-surface:   #1C2541;
  --bg-input:     #0F172A;
  --border:       #334155;
  --border-focus: #38BDF8;

  --text-main:    #F8FAFC;
  --text-muted:   #94A3B8;
  --text-light:   #64748B;

  --primary-lt:   rgba(2, 132, 199, 0.2);
  --primary-text: #38BDF8;
  --success-lt:   rgba(5, 150, 105, 0.2);
  --success-text: #34D399;
  --warning-lt:   rgba(217, 119, 6, 0.2);
  --warning-text: #FBBF24;
  --danger-lt:    rgba(220, 38, 38, 0.2);
  --danger-text:  #F87171;

  --shadow-sm:    0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md:    0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg:    0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

body {
  font-family: 'Cairo', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  direction: rtl;
  overflow-x: hidden;
  transition: background-color 0.2s, color 0.2s;
}

/* ── شاشة تسجيل الدخول (Modern Login) ── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top right, #1E3A8A 0%, var(--navy) 100%);
  position: relative;
  overflow: hidden;
}

#login-screen::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.15) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  border-radius: 50%;
  pointer-events: none;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 420px;
  max-width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 10;
  backdrop-filter: blur(8px);
}

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

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-lt);
  color: var(--primary-text);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 12px;
}

.login-brand h1 {
  font-size: 28px;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.login-brand h1 span {
  color: var(--primary);
}

.login-brand p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-error {
  background: var(--danger-lt);
  color: var(--danger-text);
  border: 1px solid rgba(220, 38, 38, 0.2);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── إطار التطبيق الرئيسي (App Shell) ── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ── الشريط الجانبي (Sidebar) ── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  z-index: 100;
  border-left: 1px solid var(--navy-border);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.sidebar-header {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--navy-border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, #0D9488 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.sidebar-logo h1 {
  font-size: 17px;
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1.2;
}

.sidebar-logo h1 span {
  color: #38BDF8;
}

.sidebar-logo small {
  display: block;
  font-size: 11px;
  color: #94A3B8;
}

.sidebar-menu {
  padding: 16px 12px;
  flex: 1;
}

.nav-label {
  padding: 10px 12px 6px;
  font-size: 10px;
  font-weight: 800;
  color: #64748B;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 3px;
  border-radius: var(--radius-md);
  color: #CBD5E1;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: right;
  font-family: inherit;
  transition: all 0.15s ease;
  position: relative;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #FFFFFF;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(2, 132, 199, 0.25) 0%, rgba(2, 132, 199, 0.1) 100%);
  color: #38BDF8;
  font-weight: 700;
  border-right: 3px solid #38BDF8;
}

.nav-icon {
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
}

.nav-badge {
  margin-right: auto;
  background: var(--danger);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  line-height: 1.2;
}

.nav-badge.pulse {
  animation: pulseBadge 1.5s infinite;
}

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

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--navy-border);
  background: rgba(0, 0, 0, 0.15);
}

.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: #1E3A8A;
  color: #38BDF8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #38BDF8;
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: #94A3B8;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-logout:hover {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.4);
  color: #F87171;
}

.admin-only {
  display: none !important;
}

body.is-admin .admin-only {
  display: flex !important;
}

body.is-admin .nav-label.admin-only {
  display: block !important;
}

/* ── المنطقة الرئيسية (Main Area) ── */
#main {
  margin-right: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  transition: margin-right 0.25s;
}

/* ── الشريط العلوي (Topbar) ── */
#topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-heading {
  display: flex;
  flex-direction: column;
}

.page-heading h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.page-heading p {
  font-size: 11.5px;
  color: var(--text-muted);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.global-search-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.global-search-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.kbd-shortcut {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.theme-toggle-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
}

.theme-toggle-btn:hover {
  border-color: var(--primary);
  background: var(--primary-lt);
}

/* ── مساحة المحتوى (Content) ── */
#content {
  padding: 24px 28px;
  flex: 1;
}

/* ── الأزرار (Buttons System) ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.btn-success {
  background: var(--success);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.btn-success:hover {
  background: var(--success-hover);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-warning {
  background: var(--warning);
  color: #FFFFFF;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-main);
}

.btn-ghost:hover {
  background: var(--primary-lt);
  border-color: var(--primary);
  color: var(--primary-text);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  gap: 5px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
  border-radius: var(--radius-lg);
}

.btn-whatsapp {
  background: #25D366;
  color: #FFFFFF;
}

.btn-whatsapp:hover {
  background: #20BA5A;
}

/* ── البطاقات والحاويات (Cards & Grid) ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
}

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

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

.card-body {
  padding: 20px;
}

/* ── النماذج وحقول الإدخال (Forms & Inputs) ── */
.form-row {
  margin-bottom: 16px;
}

.form-row label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-main);
  background: var(--bg-input);
  transition: all 0.15s;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── محرك البحث الفوري (Super Search Bar) ── */
.super-search-wrapper {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 8px 12px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
  margin-bottom: 18px;
}

.super-search-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.2);
}

.super-search-icon {
  font-size: 24px;
  color: var(--primary);
  display: flex;
  align-items: center;
}

.super-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  outline: none;
}

.super-search-input::placeholder {
  color: var(--text-light);
  font-weight: 500;
}

.super-search-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
}

.super-search-clear:hover {
  background: var(--border);
  color: var(--text-main);
}

/* شريط الفلاتر السريع */
.quick-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

/* ── الجداول التفاعلية (Data Tables) ── */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: right;
}

.archive-table {
  /* عرض ثابت للأعمدة يمنع عمود الإدارة من الخروج يسار الجدول. */
  min-width: 1080px;
  table-layout: fixed;
}

.archive-table td {
  white-space: nowrap;
  padding: 10px 9px;
}

.archive-table th {
  padding: 13px 9px;
}

.archive-table th:nth-child(1) { width: 86px; }
.archive-table th:nth-child(2) { width: 175px; }
.archive-table th:nth-child(3) { width: 165px; }
.archive-table th:nth-child(4) { width: 220px; }
.archive-table th:nth-child(5) { width: 175px; }
.archive-table th:nth-child(6) { width: 155px; }
.archive-table th:nth-child(7) { width: 82px; }

.archive-table .archive-doctor-cell {
  overflow: hidden;
  text-overflow: ellipsis;
}

.archive-table .status-pill,
.archive-table .btn,
.archive-table .phone-tag {
  white-space: nowrap;
}

thead th {
  background: var(--navy);
  color: #FFFFFF;
  padding: 13px 18px;
  font-weight: 700;
  font-size: 12.5px;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color 0.12s ease;
  cursor: pointer;
}

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

tbody tr:hover {
  background: var(--primary-lt);
}

tbody td {
  padding: 12px 18px;
  color: var(--text-main);
  vertical-align: middle;
}

.file-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: #F8FAFC;
  color: #0F172A;
  font-weight: 900;
  direction: ltr;
  unicode-bidi: isolate;
  min-width: 72px;
  font-size: 17px;
  letter-spacing: 0.4px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  box-shadow: none;
  font-family: 'Cairo', monospace, sans-serif;
  border: 2px solid #0F766E;
}

body.theme-dark .file-pill {
  background: #ECFEFF;
  color: #134E4A;
  border-color: #5EEAD4;
}

.patient-name-cell {
  font-weight: 800;
  font-size: 15px;
  color: var(--text-main);
}

.phone-tag {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px 12px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  direction: ltr;
  letter-spacing: 0.8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.15s;
}

.phone-tag:hover {
  border-color: var(--primary);
  background: var(--primary-lt);
}

.phone-num-text {
  font-family: monospace;
  font-size: 14.5px;
  font-weight: 800;
}

.phone-actions-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.phone-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  text-decoration: none;
  font-size: 14px;
  transition: transform 0.12s, background-color 0.12s;
}

.phone-action-btn:hover {
  transform: scale(1.15);
}

.phone-action-btn.wa {
  background: rgba(37, 211, 102, 0.15);
  color: #16A34A;
}

.phone-action-btn.call {
  background: rgba(2, 132, 199, 0.15);
  color: #0284C7;
}

/* ── القائمة المنسدلة الذكية للبحث في الأطباء (Searchable Doctor Combobox) ── */
.doc-combobox {
  position: relative;
  display: inline-block;
}

.doc-combobox-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  min-width: 210px;
  transition: all 0.15s;
}

.doc-combobox-trigger:hover,
.doc-combobox-trigger.open {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.doc-combobox-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 290px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 150;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: modalScale 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.doc-combobox-menu.show {
  display: flex;
}

.doc-combobox-search-box {
  padding: 10px 12px;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
}

.doc-combobox-search-input {
  width: 100%;
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 12.5px;
  background: var(--bg-card);
  color: var(--text-main);
  outline: none;
}

.doc-combobox-search-input:focus {
  border-color: var(--primary);
}

.doc-combobox-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
}

.doc-combobox-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}

.doc-combobox-option:hover {
  background: var(--primary-lt);
}

.doc-combobox-option.selected {
  background: var(--primary-lt);
  color: var(--primary);
  font-weight: 800;
}

.doc-opt-name {
  font-weight: 700;
}

.doc-opt-spec {
  font-size: 11px;
  color: var(--text-muted);
}

/* شارات الحالة (Status Badges) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 800;
}

.status-pill.in {
  background: var(--success-lt);
  color: var(--success-text);
}

.status-pill.out {
  background: var(--warning-lt);
  color: var(--warning-text);
}

.status-pill.overdue {
  background: var(--danger-lt);
  color: var(--danger-text);
  animation: pulseOverdue 1.5s infinite;
}

@keyframes pulseOverdue {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── الدرج الجانبي لبطاقة المريض (Patient Quick-Drawer) ── */
#patient-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 47, 0.5);
  backdrop-filter: blur(4px);
  z-index: 250;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

#patient-drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

#patient-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--drawer-w);
  max-width: 95vw;
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 260;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#patient-drawer-overlay.open #patient-drawer {
  transform: translateX(0);
}

.drawer-header {
  background: var(--navy);
  color: #FFFFFF;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header-info h3 {
  font-size: 16px;
  font-weight: 800;
}

.drawer-header-info p {
  font-size: 12px;
  color: #94A3B8;
}

.drawer-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #FFFFFF;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.drawer-close:hover {
  background: rgba(220, 38, 38, 0.8);
}

.drawer-body {
  padding: 22px;
  flex: 1;
  overflow-y: auto;
}

.drawer-status-banner {
  padding: 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-status-banner.in {
  background: var(--success-lt);
  border: 1.5px solid rgba(5, 150, 105, 0.3);
}

.drawer-status-banner.out {
  background: var(--warning-lt);
  border: 1.5px solid rgba(217, 119, 6, 0.3);
}

.banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.banner-icon {
  font-size: 28px;
}

.banner-title {
  font-size: 14px;
  font-weight: 800;
}

.banner-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* شبكة تفاصيل المريض في البطاقة */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.detail-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.detail-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.detail-value {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main);
}

/* جدول حركات المريض داخل البطاقة */
.drawer-history-section h4 {
  font-size: 13.5px;
  font-weight: 800;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--bg-input);
  border-right: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
}

.history-item.in {
  border-right-color: var(--success);
}

.history-item.out {
  border-right-color: var(--warning);
}

.history-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
}

.history-item-sub {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 3px;
}

/* ── النافذة المنبثقة (Modal System) ── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 47, 0.55);
  backdrop-filter: blur(4px);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

#modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 520px;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: modalScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes modalScale {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  background: var(--navy);
  color: #FFFFFF;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 800;
}

.modal-close {
  background: none;
  border: none;
  color: #94A3B8;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #FFFFFF;
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 22px;
  background: var(--bg-input);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── التنبيهات المنبثقة (Toast System) ── */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy);
  color: #FFFFFF;
  padding: 12px 22px;
  border-radius: var(--radius-full);
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: var(--shadow-xl);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

#toast.success { background: var(--success); }
#toast.error   { background: var(--danger); }
#toast.warning { background: var(--warning); }

/* ── لوحة التحكم (Dashboard Grid) ── */
.dashboard-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
}

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

.stat-box-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.stat-box-icon.blue   { background: var(--primary-lt); color: var(--primary); }
.stat-box-icon.green  { background: var(--success-lt); color: var(--success); }
.stat-box-icon.amber  { background: var(--warning-lt); color: var(--warning); }
.stat-box-icon.red    { background: var(--danger-lt);  color: var(--danger); }

.stat-box-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--text-main);
  line-height: 1;
}

.stat-box-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 4px;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ── مؤشرات التحميل والفراغ ── */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

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

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  color: var(--text-muted);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* تظليل النص المطابق للبحث */
mark {
  background: #FDE047;
  color: #000000;
  border-radius: 3px;
  padding: 0 3px;
  font-weight: 800;
}

/* تنبيه التكرار في إضافة مريض */
.duplicate-alert-box {
  background: var(--warning-lt);
  border: 1.5px solid var(--warning);
  color: var(--warning-text);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 12.5px;
  display: none;
}

/* التجاوب مع الشاشات الصغيرة (Responsive) */
@media (max-width: 1024px) {
  .dashboard-stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .dashboard-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  :root {
    --sidebar-w: 0px;
  }
  #sidebar {
    transform: translateX(100%);
    width: 260px;
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #main {
    margin-right: 0;
  }
  .dashboard-stats-grid {
    grid-template-columns: 1fr;
  }
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
  #patient-drawer {
    width: 100vw;
  }
}
