/* ============================================
   نظام إدارة العيادة - تصميم عربي حديث RTL
   ============================================ */

/* الخطوط تُحمَّل الآن من <link> في includes/layout.php — @import هنا كان يعطّل أول عرض للصفحة */

:root {
  /* الألوان الرئيسية - Teal/Emerald */
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-darker: #115e59;
  --primary-light: #14b8a6;
  --primary-lighter: #5eead4;
  --primary-50: #f0fdfa;
  --primary-100: #ccfbf1;

  /* ألوان داعمة */
  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;

  /* الرمادي */
  --bg: #f8fafc;
  --bg-secondary: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --muted-light: #94a3b8;

  /* الظلال */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 10px 10px -5px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 25px 50px -12px rgba(15, 23, 42, 0.15);
  --shadow-glow: 0 0 0 4px rgba(13, 148, 136, 0.15);

  /* الحدود */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* التدرجات */
  --gradient-primary: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-accent: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --gradient-info: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  --gradient-purple: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  --gradient-bg: linear-gradient(135deg, #f0fdfa 0%, #f8fafc 100%);
}

/* ============ Dark Mode - مُقوّى ============ */
body.dark-mode {
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --surface: #1e293b;
  --card-bg: #1e293b;
  --border: #334155;
  --border-light: #2d3a52;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --muted-light: #64748b;
  --primary-50: #134e4a;
  --primary-100: #115e59;
  --primary-darker: #5eead4;
  --success-light: #064e3b;
  --warning-light: #78350f;
  --danger-light: #7f1d1d;
  --info-light: #1e3a8a;
  --purple-light: #4c1d95;
  background: var(--bg) !important;
  color: var(--text) !important;
}

body.dark-mode .sidebar { background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important; }
body.dark-mode .sidebar-user { background: #1a2842 !important; }
body.dark-mode .sidebar-nav-item { color: var(--text-secondary) !important; }
body.dark-mode .sidebar-nav-item:hover { background: var(--primary-50) !important; color: var(--primary-lighter) !important; }

body.dark-mode .card,
body.dark-mode .stat-card,
body.dark-mode .modal,
body.dark-mode .login-card,
body.dark-mode .data-table { background: var(--surface) !important; color: var(--text) !important; }

body.dark-mode .form-control,
body.dark-mode .form-select,
body.dark-mode textarea.form-control,
body.dark-mode input { background: #0f172a !important; color: var(--text) !important; border-color: var(--border) !important; }

body.dark-mode .data-table thead { background: #0f172a !important; }
body.dark-mode .data-table th { color: var(--text) !important; border-color: var(--border) !important; }
body.dark-mode .data-table td { border-color: var(--border-light) !important; }
body.dark-mode .data-table tbody tr:hover { background: var(--primary-50) !important; }

body.dark-mode .btn-secondary { background: var(--bg-secondary) !important; color: var(--text) !important; border-color: var(--border) !important; }
body.dark-mode .modal-header,
body.dark-mode .modal-footer { background: var(--bg-secondary) !important; border-color: var(--border) !important; }
body.dark-mode .permission-item { background: var(--bg-secondary) !important; border-color: var(--border) !important; color: var(--text) !important; }
body.dark-mode code { background: #0f172a !important; color: var(--primary-lighter) !important; }
body.dark-mode .login-card h1,
body.dark-mode .login-card .subtitle,
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3,
body.dark-mode .form-label,
body.dark-mode .card-title,
body.dark-mode .modal-title,
body.dark-mode .stat-value,
body.dark-mode .stat-label,
body.dark-mode label,
body.dark-mode .page-header h1,
body.dark-mode .page-header p { color: var(--text) !important; }

body.dark-mode .toast { background: var(--surface) !important; color: var(--text) !important; }
body.dark-mode .pill { color: var(--text-secondary) !important; }
body.dark-mode .pill.active { background: var(--surface) !important; }
body.dark-mode .pill-group { background: var(--bg-secondary) !important; }

body.dark-mode .mobile-menu-btn,
body.dark-mode #notifBtn,
body.dark-mode #darkBtn { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }

body.dark-mode .alert-info { background: #1e3a8a !important; color: #dbeafe !important; }
body.dark-mode .alert-success { background: #064e3b !important; color: #d1fae5 !important; }
body.dark-mode .alert-warning { background: #78350f !important; color: #fef3c7 !important; }
body.dark-mode .alert-danger { background: #7f1d1d !important; color: #fee2e2 !important; }

body.dark-mode .ss-dropdown { background: var(--surface) !important; border-color: var(--border) !important; }
body.dark-mode .ss-option { color: var(--text) !important; border-color: var(--border-light) !important; }

body.dark-mode .badge-secondary { background: #334155 !important; color: #cbd5e1 !important; }

body.dark-mode #timeSlotsGrid { background: #0f172a !important; }
body.dark-mode #timeSlotsGrid button { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
body.dark-mode #selectedTimeDisplay { background: #134e4a !important; color: var(--primary-lighter) !important; }

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Cairo', 'Tajawal', Tahoma, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============ Login Page ============ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before,
.login-page::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  animation: float 20s infinite ease-in-out;
}
.login-page::before { width: 400px; height: 400px; top: -200px; left: -200px; }
.login-page::after { width: 500px; height: 500px; bottom: -250px; right: -250px; animation-delay: -10s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -30px) scale(1.1); }
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 460px;
  position: relative;
  z-index: 1;
  animation: slideUp 0.5s ease-out;
}

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

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

.login-logo-icon {
  width: 72px;
  height: 72px;
  background: var(--gradient-primary);
  border-radius: 20px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  font-size: 26px;
  color: var(--text);
  margin-bottom: 6px;
  text-align: center;
  font-weight: 800;
}

.login-card .subtitle {
  text-align: center;
  color: var(--muted);
  margin-bottom: 32px;
  font-size: 14px;
}

/* ============ Layout (Sidebar + Main) ============ */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-left: 1px solid var(--border);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 50;
  transition: transform 0.3s ease;
  box-shadow: -2px 0 8px rgba(0,0,0,0.02);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--gradient-primary);
  color: white;
}

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

.sidebar-logo-icon {
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.sidebar-logo-text { font-weight: 800; font-size: 16px; line-height: 1.3; }
.sidebar-logo-text small { display: block; font-weight: 400; font-size: 11px; opacity: 0.85; margin-top: 2px; }

.sidebar-user {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--primary-50);
}

.sidebar-user-avatar {
  width: 40px;
  height: 40px;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

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

.sidebar-user-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--primary);
  font-weight: 500;
}

.sidebar-nav {
  padding: 12px;
  list-style: none;
}

.sidebar-nav-section {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted-light);
  text-transform: uppercase;
  padding: 16px 12px 8px;
  letter-spacing: 0.5px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius);
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  position: relative;
}

.sidebar-nav-item:hover {
  background: var(--primary-50);
  color: var(--primary);
}

.sidebar-nav-item.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow);
}

.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: var(--primary-dark);
  border-radius: 4px 0 0 4px;
}

.sidebar-nav-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logout {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.sidebar-logout .sidebar-nav-item:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.main-content {
  flex: 1;
  margin-right: 260px;
  padding: 24px 32px;
  min-height: 100vh;
  width: calc(100% - 260px);
  max-width: calc(100% - 260px);
  box-sizing: border-box;
  overflow-x: hidden;
}

/* ============ Header ============ */
.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.page-header h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header h1 .icon {
  width: 44px;
  height: 44px;
  background: var(--gradient-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  box-shadow: var(--shadow);
}

.page-header p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

.mobile-menu-btn {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  font-size: 22px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ============ Cards ============ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border-light);
  transition: box-shadow 0.2s;
}

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

.card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title .icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--primary-50);
  color: var(--primary);
}

/* ============ Stats ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: var(--gradient-primary);
  opacity: 0.08;
  border-radius: 50%;
  transform: translate(50%, -50%);
}

.stat-card.success::before { background: var(--gradient-success); }
.stat-card.warning::before { background: var(--gradient-accent); }
.stat-card.info::before { background: var(--gradient-info); }
.stat-card.purple::before { background: var(--gradient-purple); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.stat-card.success .stat-icon { background: var(--gradient-success); }
.stat-card.warning .stat-icon { background: var(--gradient-accent); }
.stat-card.info .stat-icon { background: var(--gradient-info); }
.stat-card.purple .stat-icon { background: var(--gradient-purple); }

.stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.stat-change {
  font-size: 12px;
  margin-top: 6px;
  color: var(--muted);
}

/* ============ Forms ============ */
.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

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

.form-label .required { color: var(--danger); }

.form-control,
.form-select,
textarea.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: all 0.2s;
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.form-control:disabled {
  background: var(--bg-secondary);
  color: var(--muted);
  cursor: not-allowed;
}

textarea.form-control {
  min-height: 90px;
  resize: vertical;
  font-family: inherit;
}

.form-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

/* Checkbox */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-50);
}

.btn-success { background: var(--gradient-success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--gradient-accent); color: white; }

.btn-danger:hover:not(:disabled),
.btn-success:hover:not(:disabled),
.btn-warning:hover:not(:disabled) {
  filter: brightness(0.95);
  box-shadow: var(--shadow-md);
}

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
}

/* ============ Tables ============ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 14px;
}

.data-table thead {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.data-table th {
  padding: 14px 12px;
  text-align: right;
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: var(--primary-50);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.table-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ============ Badges ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-info { background: var(--info-light); color: #1e40af; }
.badge-primary { background: var(--primary-100); color: var(--primary-darker); }
.badge-purple { background: var(--purple-light); color: #5b21b6; }
.badge-secondary { background: var(--bg-secondary); color: var(--text-secondary); }

/* ============ Alerts ============ */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  border: 1px solid;
}

.alert-icon { font-size: 20px; flex-shrink: 0; }
.alert-success { background: var(--success-light); color: #065f46; border-color: #a7f3d0; }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: #fde68a; }
.alert-danger { background: var(--danger-light); color: #991b1b; border-color: #fecaca; }
.alert-info { background: var(--info-light); color: #1e40af; border-color: #bfdbfe; }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s;
}

.modal-lg { max-width: 800px; }
.modal-sm { max-width: 420px; }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #f8fafc 0%, white 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 20px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover { background: var(--bg-secondary); color: var(--text); }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: var(--bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ============ Toast ============ */
.toast-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-xl);
  min-width: 280px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInLeft 0.3s ease-out;
  border-right: 4px solid var(--primary);
  font-size: 14px;
  font-weight: 500;
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-right-color: var(--success); }
.toast.error { border-right-color: var(--danger); }
.toast.warning { border-right-color: var(--warning); }
.toast.info { border-right-color: var(--info); }

.toast-icon { font-size: 22px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

/* ============ Filter Bar ============ */
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.filter-bar .btn { height: 42px; }

/* ============ Empty State ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 56px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 15px;
  color: var(--muted);
}

/* ============ Loading ============ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(13, 148, 136, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

.loading-overlay .spinner { width: 32px; height: 32px; }

/* ============ Pills/Tabs ============ */
.pill-group {
  display: inline-flex;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
}

.pill {
  padding: 8px 16px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.pill.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ============ Permission Grid ============ */
.permission-page-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.permission-page-title {
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--primary);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.permission-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.permission-item input[type="checkbox"] {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  appearance: auto;
  opacity: 1;
  visibility: visible;
  display: inline-block;
}

.permission-item:hover {
  background: var(--primary-50);
  border-color: var(--primary-lighter);
}

.permission-item:has(input:checked) {
  background: var(--primary-50);
  border-color: var(--primary);
  font-weight: 600;
}

.permission-item:has(input:checked) span {
  color: var(--primary-darker);
}

/* ============ Print ============ */
@media print {
  .sidebar, .mobile-menu-btn, .btn, .page-header > div:last-child {
    display: none !important;
  }
  .main-content { margin: 0 !important; padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  body { background: white !important; }
}

/* ============ Mobile Responsive - Strong Rules ============ */
@media (max-width: 768px) {
  html { -webkit-text-size-adjust: 100%; }
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
  }
  body { font-size: 14px; }

  /* Header button */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: fixed !important;
    top: 10px;
    right: 10px;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow);
  }

  /* Sidebar - مخفية افتراضياً */
  .sidebar {
    width: 80% !important;
    max-width: 300px !important;
    position: fixed !important;
    top: 0; right: 0; bottom: 0;
    transform: translateX(105%) !important;
    transition: transform 0.3s ease !important;
    z-index: 999 !important;
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: translateX(0) !important; }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 998;
  }
  .sidebar-backdrop.show { display: block; }

  /* Layout */
  .app-layout {
    display: block !important;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .main-content, main.main-content {
    margin: 0 !important;
    padding: 60px 10px 70px 10px !important;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    flex: none !important;
  }

  /* Page header */
  .page-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    margin-bottom: 14px !important;
  }
  .page-header > div { width: 100%; }
  .page-header h1 {
    font-size: 17px !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    line-height: 1.4;
  }
  .page-header h1 .icon { width: 32px !important; height: 32px !important; font-size: 16px !important; }
  .page-header p { font-size: 12px; }
  .page-header > div:last-child {
    display: flex !important;
    gap: 6px !important;
    flex-wrap: wrap !important;
  }
  .page-header > div:last-child .btn,
  .page-header > div:last-child a.btn {
    flex: 1 !important;
    min-width: 100px !important;
    padding: 10px !important;
    font-size: 12px !important;
  }

  /* Stats */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .stat-card { padding: 12px !important; }
  .stat-value { font-size: 20px !important; }
  .stat-icon { width: 36px !important; height: 36px !important; font-size: 16px !important; margin-bottom: 8px !important; }
  .stat-label { font-size: 11px !important; }
  .stat-change { font-size: 10px !important; }

  /* Cards */
  .card {
    padding: 12px !important;
    margin-bottom: 12px !important;
    border-radius: 12px !important;
    width: 100%;
    box-sizing: border-box;
  }
  .card-title { font-size: 14px !important; margin-bottom: 12px !important; flex-wrap: wrap; }
  .card-title .icon { width: 30px !important; height: 30px !important; font-size: 15px !important; }

  /* Filter bar - الأهم */
  .filter-bar {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .filter-bar > div { width: 100%; }
  .filter-bar .btn { width: 100% !important; }

  /* Forms */
  .form-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .form-group { margin-bottom: 12px !important; }
  .form-label { font-size: 12px !important; }
  .form-hint { font-size: 11px !important; }
  .form-control, .form-select, textarea.form-control,
  input[type="text"], input[type="password"], input[type="email"],
  input[type="number"], input[type="date"], input[type="time"], input[type="url"], input[type="color"] {
    font-size: 16px !important;
    padding: 10px 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Modal */
  .modal-backdrop { padding: 4px !important; }
  .modal {
    margin: 4px !important;
    max-height: 96vh !important;
    width: calc(100vw - 8px) !important;
    max-width: calc(100vw - 8px) !important;
  }
  .modal-body { padding: 14px !important; }
  .modal-header { padding: 12px 14px !important; }
  .modal-title { font-size: 15px !important; }
  .modal-footer {
    padding: 12px 14px !important;
    flex-direction: column-reverse !important;
    gap: 6px !important;
  }
  .modal-footer .btn { width: 100% !important; }

  /* Tables - scrollable */
  .table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    margin: 0 -10px;
    padding: 0 10px;
  }
  .data-table {
    font-size: 12px !important;
    min-width: 600px;
  }
  .data-table th, .data-table td {
    padding: 8px 6px !important;
    white-space: nowrap;
  }
  .table-actions { gap: 4px !important; flex-wrap: nowrap; }

  /* Buttons */
  .btn { padding: 9px 12px !important; font-size: 13px !important; }
  .btn-sm { padding: 6px 10px !important; font-size: 11px !important; }
  .btn-lg { padding: 12px 18px !important; font-size: 14px !important; }
  .btn-icon { width: 32px !important; height: 32px !important; font-size: 14px !important; padding: 0 !important; }

  /* Toast */
  .toast-container { left: 8px !important; right: 8px !important; top: 8px !important; }
  .toast { min-width: auto !important; max-width: 100% !important; width: 100% !important; }

  /* Calendar */
  .calendar-grid { gap: 2px !important; }
  .cal-header { padding: 6px 1px !important; font-size: 10px !important; }
  .cal-day { min-height: 44px !important; padding: 2px !important; }
  .cal-day-num { font-size: 11px !important; }
  .cal-events { display: none !important; }
  .cal-count { font-size: 9px !important; padding: 1px 4px !important; top: 2px !important; left: 2px !important; }

  /* Searchable Select */
  .ss-dropdown { max-height: 220px !important; }
  .ss-input { font-size: 16px !important; }

  /* Pills */
  .pill-group {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
  }
  .pill { white-space: nowrap; padding: 8px 12px !important; font-size: 12px !important; }

  /* Time slots */
  #timeSlotsGrid {
    grid-template-columns: repeat(3, 1fr) !important;
    max-height: 240px !important;
  }
  #timeSlotsGrid button { font-size: 11px !important; padding: 6px 2px !important; }

  /* Sidebar nav items */
  .sidebar-nav-item { padding: 12px 14px !important; font-size: 14px !important; }
  .sidebar-user-name { font-size: 12px !important; }
  .sidebar-user-role { font-size: 10px !important; }

  /* Login page */
  .login-card {
    padding: 28px 20px !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 8px;
  }
  .login-card h1 { font-size: 20px !important; }

  /* Directory cards */
  .card[style*="border-right"] { width: 100%; }
  [style*="grid-template-columns:repeat(auto-fill,minmax(300px,1fr))"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns:repeat(auto-fit,minmax(380px,1fr))"],
  [style*="grid-template-columns:repeat(auto-fit,minmax(360px,1fr))"],
  [style*="grid-template-columns:repeat(auto-fit,minmax(340px,1fr))"],
  [style*="grid-template-columns:repeat(auto-fit,minmax(280px,1fr))"] {
    grid-template-columns: 1fr !important;
  }

  /* FAB */
  #fabBooking {
    bottom: 16px !important;
    left: 16px !important;
    width: 50px !important;
    height: 50px !important;
    font-size: 22px !important;
  }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .page-header h1 { font-size: 15px !important; }
  .stat-value { font-size: 18px !important; }
  #timeSlotsGrid { grid-template-columns: repeat(2, 1fr) !important; }
  .data-table { min-width: 500px; }
  .main-content { padding: 58px 6px 70px 6px !important; }
}

/* ============ Mobile Pages Comprehensive ============ */
@media (max-width: 768px) {
  /* Calendar - شبكة مضغوطة */
  .cal-grid, .calendar-grid {
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 2px !important;
  }
  .cal-day {
    min-height: 38px !important;
    padding: 2px !important;
    font-size: 10px !important;
  }
  .cal-day-num { font-size: 11px !important; font-weight: 600; }
  .cal-events { display: none !important; }
  .cal-count {
    display: inline-block !important;
    position: absolute !important;
    bottom: 2px !important;
    right: 2px !important;
    background: var(--primary) !important;
    color: white !important;
    border-radius: 50% !important;
    width: 16px !important; height: 16px !important;
    font-size: 9px !important;
    line-height: 16px !important;
    text-align: center;
    padding: 0 !important;
    top: auto !important; left: auto !important;
  }
  .cal-header {
    padding: 4px 1px !important;
    font-size: 9px !important;
  }

  /* Users page - tabs + cards */
  #typeTabs.pill-group {
    flex-wrap: nowrap !important;
    overflow-x: auto;
  }

  /* Audit log table → cards */
  .audit-mobile-cards { display: block !important; }
  .audit-desktop-table { display: none !important; }

  /* Roles page - الصلاحيات */
  .roles-layout {
    grid-template-columns: 1fr !important;
  }
  .roles-sidebar {
    width: 100% !important;
    max-height: none !important;
    margin-bottom: 12px;
  }
  .permission-group {
    grid-template-columns: 1fr !important;
  }
  .permission-item {
    font-size: 13px !important;
    padding: 10px 12px !important;
  }

  /* All cards that should stack */
  .mobile-stack > * {
    width: 100% !important;
  }

  /* Settings forms grid */
  [style*="grid-template-columns:repeat(auto-fit,minmax(360px"],
  [style*="grid-template-columns:repeat(auto-fit,minmax(340px"],
  [style*="grid-template-columns:repeat(auto-fit,minmax(380px"] {
    grid-template-columns: 1fr !important;
  }
}

/* ============ Utilities ============ */
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.font-bold { font-weight: 700; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

/* ============================================================
   دعم اللغة الإنجليزية (اتجاه LTR)
   ============================================================ */
[dir="ltr"] .sidebar { right: auto; left: 0; border-left: none; border-right: 1px solid var(--border); }
[dir="ltr"] .main-content { margin-right: 0; margin-left: 260px; }
[dir="ltr"] #fabBooking { left: auto !important; right: 24px !important; }
[dir="ltr"] .toast { border-right: none; border-left: 4px solid var(--border); }
[dir="ltr"] .toast.success { border-left-color: var(--success); }
[dir="ltr"] .toast.error   { border-left-color: var(--danger); }
[dir="ltr"] .toast.warning { border-left-color: var(--warning); }
[dir="ltr"] .toast.info    { border-left-color: var(--info); }
[dir="ltr"] .card[style*="border-right"] { border-right: none !important; border-left: 4px solid var(--primary) !important; }
[dir="ltr"] body { font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif; }

@media (max-width: 768px) {
  [dir="ltr"] .sidebar { right: auto; left: 0; transform: translateX(-105%) !important; }
  [dir="ltr"] .sidebar.open { transform: translateX(0) !important; }
  [dir="ltr"] .main-content { margin-left: 0 !important; }
}

/* ============================================================
   تحسينات بصرية عامة لكل الصفحات
   ============================================================ */
.card, .stat-card, .dash-stat {
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
.card:hover, .stat-card:hover, .dash-stat:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.btn { transition: transform .12s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary:hover { box-shadow: 0 8px 18px rgba(13,148,136,0.28); }
.form-control:focus, .form-select:focus, textarea.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.15);
}
.data-table tbody tr { transition: background .15s ease; }
.sidebar-nav-item { transition: background .15s ease, color .15s ease, padding .15s ease; }
.sidebar-nav-item.active {
  position: relative;
  font-weight: 700;
}
.badge { transition: background .15s ease; }
::selection { background: rgba(13,148,136,0.2); }

/* تمرير أنعم */
* { scroll-behavior: smooth; }

/* ============================================================
   إصلاح شامل للوضع الليلي: منع اختفاء النصوص والخلفيات البيضاء
   ============================================================ */
/* أي عنصر بخلفية بيضاء مضمّنة (inline) يتحوّل لسطح داكن ونص فاتح */
body.dark-mode [style*="background:white"],
body.dark-mode [style*="background: white"],
body.dark-mode [style*="background:#fff"],
body.dark-mode [style*="background: #fff"],
body.dark-mode [style*="background:#ffffff"],
body.dark-mode [style*="background: #ffffff"],
body.dark-mode [style*="background-color:white"],
body.dark-mode [style*="background-color:#fff"] {
  background: var(--surface) !important;
  color: var(--text) !important;
}

/* القوائم المنسدلة والخيارات */
body.dark-mode select,
body.dark-mode option,
body.dark-mode select.form-select,
body.dark-mode select option {
  background: #0f172a !important;
  color: var(--text) !important;
}

/* بطاقات لوحة التحكم الجديدة والصناديق */
body.dark-mode .dash-stat,
body.dark-mode .quick-box,
body.dark-mode .alert-row,
body.dark-mode .doc-bar,
body.dark-mode .doc-rank { background: var(--surface) !important; color: var(--text) !important; }
body.dark-mode .quick-box .qv,
body.dark-mode .ds-value,
body.dark-mode .ds-label,
body.dark-mode .ds-sub,
body.dark-mode .ql { color: var(--text) !important; }

/* التقويم المصغّر + تقويم الصفحة */
body.dark-mode .mini-cal .cell { color: var(--text) !important; }
body.dark-mode .mini-cal .has { background: var(--primary-100) !important; color: var(--primary-lighter) !important; }
body.dark-mode .cal-day,
body.dark-mode .cal-cell,
body.dark-mode .calendar-day { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
body.dark-mode .cal-day.empty,
body.dark-mode .cal-cell.empty { background: var(--bg) !important; }
body.dark-mode .cal-event { color: #fff !important; }

/* عناصر عامة قد تحمل نصاً بلون افتراضي غامق */
body.dark-mode strong,
body.dark-mode b,
body.dark-mode small,
body.dark-mode span,
body.dark-mode p,
body.dark-mode div,
body.dark-mode td,
body.dark-mode th,
body.dark-mode li,
body.dark-mode a:not(.btn) { color: inherit; }

/* استثناءات: الشارات والأزرار الملوّنة تحتفظ بنصها الأبيض */
body.dark-mode .btn-primary,
body.dark-mode .btn-success,
body.dark-mode .btn-danger,
body.dark-mode .btn-warning,
body.dark-mode .btn-info,
body.dark-mode .stat-icon,
body.dark-mode .ds-icon,
body.dark-mode .sidebar-logo-icon,
body.dark-mode .sidebar-user-avatar { color: #fff !important; }

/* شارات الوضع الليلي: خلفية داكنة ملوّنة + نص فاتح (إصلاح الأنواع والحالات) */
body.dark-mode .badge-success  { background:#064e3b !important; color:#6ee7b7 !important; }
body.dark-mode .badge-warning  { background:#78350f !important; color:#fcd34d !important; }
body.dark-mode .badge-danger   { background:#7f1d1d !important; color:#fca5a5 !important; }
body.dark-mode .badge-info     { background:#1e3a8a !important; color:#93c5fd !important; }
body.dark-mode .badge-primary  { background:#115e59 !important; color:#5eead4 !important; }
body.dark-mode .badge-purple   { background:#4c1d95 !important; color:#ddd6fe !important; }
body.dark-mode .badge-secondary{ background:#334155 !important; color:#cbd5e1 !important; }

/* الحقول النصية داخل النوافذ المنبثقة */
body.dark-mode .modal input,
body.dark-mode .modal textarea,
body.dark-mode .modal select { background: #0f172a !important; color: var(--text) !important; border-color: var(--border) !important; }
body.dark-mode .modal, body.dark-mode .modal-body { color: var(--text) !important; }

/* منتقي الوقت والعناصر المتعددة في الحجز */
body.dark-mode #itemsContainer > div,
body.dark-mode #itemsContainer select,
body.dark-mode #itemsContainer input { background: #0f172a !important; color: var(--text) !important; border-color: var(--border) !important; }

/* الفلاتر والصناديق ذات الخلفية الفاتحة */
body.dark-mode .filter-bar,
body.dark-mode .empty-state { background: transparent !important; color: var(--text) !important; }
body.dark-mode .empty-state-text { color: var(--muted) !important; }

/* ============================================================
   لمسات تصميم احترافية عامة (كل الصفحات)
   ============================================================ */
.page-header h1 { letter-spacing: -0.3px; }
.card { border-radius: var(--radius-lg); }
.stat-card { border-radius: var(--radius-lg); position: relative; overflow: hidden; }
.stat-card::after {
  content:''; position:absolute; inset-inline-start:0; top:0; bottom:0; width:4px;
  background: var(--gradient-primary); opacity:.9;
}
.stat-card.success::after { background: var(--success); }
.stat-card.info::after    { background: var(--info); }
.stat-card.warning::after { background: var(--warning); }
.stat-value { font-weight: 800; letter-spacing: -0.5px; }

.data-table thead th {
  text-transform: none; letter-spacing: .2px;
  position: sticky; top: 0; z-index: 1;
}
.data-table tbody tr:hover { background: var(--primary-50); }

.sidebar-nav-item.active::before {
  content:''; position:absolute; inset-inline-start:0; top:8px; bottom:8px;
  width:3px; border-radius:3px; background: var(--primary);
}
.sidebar-nav-item { position: relative; border-radius: 12px; }

.badge { border-radius: 999px; font-weight: 700; letter-spacing: .2px; }
.btn { border-radius: 12px; font-weight: 700; }
.btn-lg { border-radius: 14px; }

.modal { border-radius: var(--radius-lg); overflow: hidden; }
.form-control, .form-select, textarea.form-control { border-radius: 12px; }

/* أزرار عائمة أنعم */
#darkBtn, #langBtn { border-radius: 12px; }
#darkBtn:hover, #langBtn:hover { border-color: var(--primary); color: var(--primary); }

/* حركة ظهور خفيفة للبطاقات */
@keyframes cardIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform:none; } }
.card, .stat-card, .dash-stat { animation: cardIn .35s ease both; }

/* تحسين المخطط الفارغ */
.empty-state { padding: 40px 20px; }
.empty-state-icon { font-size: 42px; opacity:.65; }

/* ============================================================
   طبقة التصميم الاحترافي v7 — مطابقة لنماذج Femto Vision
   ============================================================ */
:root{
  --radius: 12px; --radius-md: 14px; --radius-lg: 18px; --radius-xl: 22px;
  --ring: 0 0 0 3px rgba(13,148,136,.14);
  --card-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px -12px rgba(15,23,42,.12);
}
body{ -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility; }
.main-content{ background: var(--bg); }

/* ---- البطاقات ---- */
.card{
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  padding: 22px;
}
.card-title{ font-weight:800; letter-spacing:-.2px; display:flex; align-items:center; gap:8px; }
.card-title .icon{ font-size:18px; }

/* ---- بطاقات الإحصائيات (نمط النماذج) ---- */
.stat-card{
  border-radius: var(--radius-lg);
  border:1px solid var(--border);
  box-shadow: var(--card-shadow);
  padding:20px 20px 18px;
  overflow:hidden;
}
.stat-card::before{ display:none !important; }
.stat-card::after{ width:0 !important; } /* إلغاء الشريط الجانبي من الطبقة السابقة */
.stat-card .stat-icon{
  position:absolute; top:18px; inset-inline-end:18px;
  width:52px; height:52px; border-radius:16px; margin:0;
  background: var(--primary-50); color: var(--primary);
  box-shadow:none; font-size:24px;
}
.stat-card.success .stat-icon{ background:#d1fae5; color:#059669; }
.stat-card.info .stat-icon{ background:#dbeafe; color:#2563eb; }
.stat-card.warning .stat-icon{ background:#ffedd5; color:#ea580c; }
.stat-card.purple .stat-icon{ background:#ede9fe; color:#7c3aed; }
.stat-card .stat-label{ font-size:13px; color:var(--muted); font-weight:600; margin-bottom:8px; padding-inline-end:60px; }
.stat-card .stat-value{ font-size:30px; font-weight:800; letter-spacing:-.5px; }
.stat-card .stat-change{ margin-top:10px; font-size:12px; font-weight:700; color:var(--muted); display:inline-flex; align-items:center; gap:4px; }

/* ---- الجداول ---- */
.data-table{ border-collapse:separate; border-spacing:0; }
.data-table thead th{
  background:var(--bg-secondary); color:var(--muted);
  font-size:12px; font-weight:700; letter-spacing:.3px; text-transform:none;
  padding:14px 16px; border-bottom:1px solid var(--border);
}
.data-table tbody td{ padding:14px 16px; border-bottom:1px solid var(--border-light); vertical-align:middle; }
.data-table tbody tr{ transition:background .15s ease; }
.data-table tbody tr:hover{ background:var(--primary-50); }
.data-table tbody tr:last-child td{ border-bottom:none; }
/* شريط حالة ملوّن على حافة الصف */
.data-table tbody tr td:first-child{ position:relative; }
.data-table tbody tr td:first-child::before{
  content:''; position:absolute; inset-inline-start:0; top:8px; bottom:8px; width:4px; border-radius:4px; background:transparent;
}
.data-table tbody tr.row-ok  td:first-child::before{ background:var(--success); }
.data-table tbody tr.row-wait td:first-child::before{ background:var(--warning); }
.data-table tbody tr.row-cancel td:first-child::before{ background:var(--danger); }
.data-table tbody tr.row-done td:first-child::before{ background:var(--info); }

/* ---- الشارات ---- */
.badge{ padding:5px 10px; border-radius:999px; font-weight:700; font-size:12px; }
.badge-purple{ background:#ede9fe; color:#6d28d9; }

/* ---- أزرار التصفية (Pills) مع العدّاد ---- */
.pill-group{ background:var(--bg-secondary); border-radius:999px; padding:5px; gap:4px; display:inline-flex; flex-wrap:wrap; }
.pill{ border-radius:999px; padding:8px 16px; font-weight:700; font-size:13px; color:var(--muted); border:none; background:transparent; transition:all .15s; }
.pill:hover{ color:var(--text); }
.pill.active{ background:var(--surface); color:var(--primary); box-shadow: var(--shadow-sm); }
.pill .count{ display:inline-block; margin-inline-start:6px; background:var(--primary-100); color:var(--primary-darker); border-radius:999px; padding:1px 8px; font-size:11px; }
.pill.active .count{ background:var(--primary); color:#fff; }

/* ---- الأزرار ---- */
.btn{ border-radius:12px; font-weight:700; padding:10px 18px; }
.btn-lg{ border-radius:14px; padding:14px 22px; }
.btn-primary{ background:var(--gradient-primary); border:none; box-shadow:0 6px 16px -6px rgba(13,148,136,.5); }
.btn-primary:hover{ filter:brightness(1.03); box-shadow:0 10px 22px -8px rgba(13,148,136,.55); }
.btn-secondary{ background:var(--surface); border:1px solid var(--border); color:var(--text); }
.btn-secondary:hover{ border-color:var(--primary); color:var(--primary); }
.btn-icon{ border-radius:12px; }

/* ---- الحقول ---- */
.form-control, .form-select, textarea.form-control{ border-radius:12px; border:1px solid var(--border); padding:11px 14px; transition:border .15s, box-shadow .15s; }
.form-control:focus, .form-select:focus, textarea.form-control:focus{ border-color:var(--primary); box-shadow:var(--ring); outline:none; }
.form-label{ font-weight:700; font-size:13px; color:var(--text-secondary); }

/* ---- القائمة الجانبية ---- */
.sidebar{ border-inline-start:none; box-shadow: 1px 0 0 var(--border); }
.sidebar-nav-item{ border-radius:12px; margin:2px 10px; padding:11px 14px; font-weight:600; color:var(--text-secondary); }
.sidebar-nav-item:hover{ background:var(--primary-50); color:var(--primary); }
.sidebar-nav-item.active{ background:var(--primary-50); color:var(--primary); font-weight:800; }
.sidebar-nav-item.active::before{ inset-inline-start:0; }
.sidebar-nav-icon{ width:26px; text-align:center; }
.sidebar-nav-section{ font-size:11px; letter-spacing:.6px; color:var(--muted-light); font-weight:800; padding:14px 20px 6px; text-transform:uppercase; }

/* ---- ترويسة الصفحة ---- */
.page-header{ margin-bottom:20px; }
.page-header h1{ font-size:24px; font-weight:800; letter-spacing:-.4px; }
.page-header p{ color:var(--muted); }

/* ---- بطاقات لوحة التحكم الجديدة (dash) ---- */
.dash-stat{ box-shadow: var(--card-shadow); border-radius: var(--radius-lg); }
.ds-icon{ border-radius:16px; }
.ds-value{ font-size:30px; letter-spacing:-.5px; }

/* ---- شبكة بطاقات الأطباء (دفتر الأطباء) ---- */
.doc-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr)); gap:16px; }
.doc-card{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); box-shadow:var(--card-shadow); padding:18px; text-align:center; transition:transform .2s, box-shadow .2s; }
.doc-card:hover{ transform:translateY(-3px); box-shadow:var(--shadow-lg); }
.doc-avatar{ width:72px; height:72px; border-radius:50%; margin:0 auto 12px; background:var(--gradient-primary); color:#fff; display:flex; align-items:center; justify-content:center; font-size:28px; font-weight:800; }
.doc-name{ font-weight:800; font-size:16px; }
.doc-spec{ color:var(--muted); font-size:13px; margin-top:2px; }
.doc-actions{ display:flex; justify-content:center; gap:8px; margin-top:14px; padding-top:14px; border-top:1px solid var(--border-light); }
.doc-actions a{ width:38px; height:38px; border-radius:10px; background:var(--bg-secondary); display:flex; align-items:center; justify-content:center; text-decoration:none; font-size:16px; transition:all .15s; }
.doc-actions a:hover{ background:var(--primary); color:#fff; }

/* ---- شريط البحث العلوي (اختياري) ---- */
.searchbar{ display:flex; align-items:center; gap:8px; background:var(--surface); border:1px solid var(--border); border-radius:999px; padding:10px 18px; box-shadow:var(--shadow-sm); }
.searchbar input{ border:none; outline:none; background:transparent; flex:1; font-size:14px; color:var(--text); }

body.dark-mode .stat-card .stat-icon{ filter:brightness(.9); }
body.dark-mode .pill.active{ background:var(--surface); }
body.dark-mode .doc-actions a{ background:#0f172a; }

/* ============================================================
   نافذة الحجز: ترويسة وتذييل ثابتان + جسم قابل للتمرير (v9)
   ============================================================ */
.modal{ display:flex; flex-direction:column; }
.modal form{ display:flex; flex-direction:column; min-height:0; flex:1; }
.modal-header{ position:sticky; top:0; z-index:5; flex-shrink:0; }
.modal-body{ overflow-y:auto; flex:1 1 auto; }
.modal-footer{ position:sticky; bottom:0; z-index:5; flex-shrink:0; box-shadow:0 -4px 12px -8px rgba(15,23,42,.2); }
body.dark-mode .modal-header{ background:var(--bg-secondary) !important; }
body.dark-mode .modal-footer{ background:var(--bg-secondary) !important; }

/* ============================================================
   شبكة أمان الوضع الليلي — ضمان ظهور كل النصوص (v11)
   ============================================================ */
body.dark-mode,
body.dark-mode .main-content,
body.dark-mode .card,
body.dark-mode .modal,
body.dark-mode .modal-body,
body.dark-mode .data-table,
body.dark-mode .cal-day,
body.dark-mode .stat-card,
body.dark-mode .dash-stat { color: var(--text); }

/* أي نص بلون داكن مضمّن (inline) يتحوّل لفاتح */
body.dark-mode [style*="color:#333"],
body.dark-mode [style*="color: #333"],
body.dark-mode [style*="color:#444"],
body.dark-mode [style*="color:#555"],
body.dark-mode [style*="color:#666"],
body.dark-mode [style*="color: #666"],
body.dark-mode [style*="color:#222"],
body.dark-mode [style*="color:#111"],
body.dark-mode [style*="color:#000"],
body.dark-mode [style*="color: #000"],
body.dark-mode [style*="color:#1e293b"],
body.dark-mode [style*="color:#0f172a"],
body.dark-mode [style*="color:#374151"],
body.dark-mode [style*="color:#475569"],
body.dark-mode [style*="color:#64748b"] { color: var(--text-secondary) !important; }

/* التقويم في الوضع الليلي */
body.dark-mode .cal-day-num { color: var(--text) !important; }
body.dark-mode .cal-day.today .cal-day-num { color: var(--primary-darker) !important; }
body.dark-mode .cal-day.other-month { background: var(--bg) !important; }
body.dark-mode .cal-day.friday { background: #2a2a12 !important; }
body.dark-mode .cal-event { background: var(--primary-100) !important; color: #d1faf5 !important; }
body.dark-mode .cal-more { color: var(--muted) !important; }
body.dark-mode #monthTitle { color: var(--primary-darker) !important; }

/* الاستعلامات / أي جدول أو صندوق داخل بطاقة */
body.dark-mode .card h1, body.dark-mode .card h2, body.dark-mode .card h3,
body.dark-mode .card h4, body.dark-mode .card strong, body.dark-mode .card b,
body.dark-mode .data-table td, body.dark-mode .data-table th { color: var(--text) !important; }
body.dark-mode .data-table th { color: var(--muted) !important; }

/* ============================================================
   الشريط العلوي الموحّد (Top Bar) — v13
   ============================================================ */
.topbar{
  position: fixed; top: 0; inset-inline-end: 260px; inset-inline-start: 0; height: 64px; z-index: 70;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: nowrap; align-items: center; gap: 12px; padding: 0 16px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.tb-menu{ display:none; flex:0 0 auto; background:transparent; border:none; font-size:24px; cursor:pointer; color:var(--text); width:40px; height:40px; border-radius:10px; }
.tb-menu:hover{ background:var(--bg-secondary); }
.tb-search{
  flex: 1 1 0; min-width: 0; max-width: 520px; display:flex; align-items:center; gap:10px;
  background: var(--bg-secondary); border:1px solid var(--border); border-radius: 999px; padding: 9px 16px; cursor:text;
}
.tb-search-ic{ flex:0 0 auto; color: var(--muted); font-size:15px; }
.tb-search input{ flex:1 1 0; min-width:0; border:none; outline:none; background:transparent; font-size:14px; color:var(--text); font-family:inherit; }
.tb-kbd{ flex:0 0 auto; background: var(--surface); border:1px solid var(--border); border-radius:6px; padding:2px 8px; font-size:11px; color:var(--muted); }
.tb-actions{ flex:0 0 auto; display:flex; align-items:center; gap:10px; margin-inline-start:auto; }
.tb-datetime{ flex:0 0 auto; text-align:center; line-height:1.3; padding-inline-end:8px; border-inline-end:1px solid var(--border); }
.tb-datetime #tbDate{ font-size:12px; color:var(--muted); font-weight:600; white-space:nowrap; }
.tb-time{ font-size:14px; font-weight:800; color:var(--text); white-space:nowrap; }
.tb-icon{
  flex:0 0 auto; position:relative; width:42px; height:42px; border-radius:12px; border:1px solid var(--border);
  background: var(--surface); font-size:19px; cursor:pointer; color:var(--text);
  display:flex; align-items:center; justify-content:center; transition:all .15s;
}
.tb-icon:hover{ border-color:var(--primary); color:var(--primary); }
.tb-badge{ position:absolute; top:-4px; inset-inline-end:-4px; background:var(--danger); color:#fff; font-size:10px; padding:2px 6px; border-radius:999px; min-width:18px; height:18px; line-height:14px; font-weight:bold; }
.tb-lang{ flex:0 0 auto; height:42px; padding:0 14px; border-radius:12px; border:1px solid var(--border); background:var(--surface); font-weight:800; font-size:13px; cursor:pointer; color:var(--text); }
.tb-lang:hover{ border-color:var(--primary); color:var(--primary); }
.tb-user{ flex:0 0 auto; display:flex; align-items:center; gap:10px; padding-inline-start:12px; border-inline-start:1px solid var(--border); }
.tb-user-av{ width:40px; height:40px; border-radius:50%; background:var(--gradient-primary); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:800; font-size:16px; }
.tb-user-name{ font-size:14px; font-weight:700; color:var(--text); white-space:nowrap; }
.tb-user-role{ font-size:12px; color:var(--muted); white-space:nowrap; }

/* دفع المحتوى للأسفل + إخفاء زر القائمة القديم */
.main-content{ padding-top: 84px; }
.mobile-menu-btn{ display:none !important; }

body.dark-mode .topbar{ background: var(--surface); border-color: var(--border); }
body.dark-mode .tb-search{ background:#0f172a; }

@media (max-width: 1024px){
  .tb-datetime{ display:none; }
  .tb-user-info{ display:none; }
  .tb-user{ padding-inline-start:0; border:none; }
}
@media (max-width: 768px){
  .topbar{ inset-inline-end: 0 !important; inset-inline-start: 0 !important; height:56px; padding:0 10px; gap:8px; z-index:60; }
  .tb-menu{ display:flex !important; align-items:center; justify-content:center; order:-1; font-size:24px; }
  .tb-kbd{ display:none; }
  .tb-search{ flex:1 1 0; min-width:0; padding:8px 12px; max-width:none; }
  .tb-search input{ font-size:13px; }
  .main-content, main.main-content{ padding-top: 66px !important; }
  .tb-actions{ gap:6px; }
  .tb-icon{ width:38px; height:38px; font-size:17px; }
  .tb-lang{ height:38px; padding:0 10px; font-size:12px; }
  .tb-user{ display:none; }
}
@media (max-width: 430px){
  .tb-search .tb-search-ic{ display:none; }
  .tb-search{ padding:8px 10px; }
  .tb-actions{ gap:5px; }
  .tb-icon{ width:36px; height:36px; font-size:16px; }
  .tb-lang{ height:36px; padding:0 9px; }
}
/* الشريط الجانبي فوق الشريط العلوي عند فتحه */
.sidebar{ z-index: 80; }

/* ============================================================
   الشريط الجانبي الداكن الاحترافي (نمط Femto) — v19
   يُطبَّق دائماً في الوضعين الفاتح والداكن
   ============================================================ */
.sidebar{
  background: linear-gradient(180deg, #0c2233 0%, #0a1c2b 55%, #081724 100%) !important;
  border-inline-start: none !important; border-inline-end: none !important;
  box-shadow: inset -1px 0 0 rgba(255,255,255,.05);
}
[dir=ltr] .sidebar{ box-shadow: inset 1px 0 0 rgba(255,255,255,.05); }

.sidebar-header{ border-bottom: 1px solid rgba(255,255,255,.07) !important; }
.sidebar-logo-text{ color:#f1f5f9 !important; }
.sidebar-logo-text small{ color:#7d93ad !important; }

.sidebar-user{ background: rgba(255,255,255,.05) !important; border-bottom:1px solid rgba(255,255,255,.06) !important; }
.sidebar-user-name{ color:#f1f5f9 !important; }
.sidebar-user-role{ color:#7d93ad !important; }

.sidebar-nav-section{ color:#5c748f !important; }
.sidebar-nav-item{ color:#aebfd2 !important; }
.sidebar-nav-item:hover{ background: rgba(45,212,191,.10) !important; color:#5eead4 !important; }
.sidebar-nav-item.active{
  background: linear-gradient(90deg, rgba(13,148,136,.95), rgba(13,148,136,.75)) !important;
  color:#ffffff !important; box-shadow: 0 6px 14px -6px rgba(13,148,136,.6);
}
.sidebar-nav-item.active::before{ background:#5eead4 !important; }
.sidebar-logout{ border-top:1px solid rgba(255,255,255,.07) !important; }

/* بطاقة ترويجية أسفل القائمة */
.sb-promo{
  margin:14px 12px; padding:16px; border-radius:16px; text-align:center;
  background: radial-gradient(120% 120% at 80% 0%, rgba(45,212,191,.25), rgba(13,148,136,.08) 55%, transparent), rgba(255,255,255,.04);
  border:1px solid rgba(94,234,212,.18);
}
.sb-promo .sbp-eye{ font-size:26px; margin-bottom:8px; }
.sb-promo .sbp-title{ color:#e2f6f3; font-weight:800; font-size:13px; }
.sb-promo .sbp-sub{ color:#7d93ad; font-size:11px; margin-top:2px; }

/* تمرير أنيق داخل الشريط */
.sidebar::-webkit-scrollbar{ width:6px; }
.sidebar::-webkit-scrollbar-thumb{ background:rgba(255,255,255,.12); border-radius:6px; }

/* في الوضع الداكن يبقى نفس الشكل (لا تغييرات إضافية) */
body.dark-mode .sidebar{ background: linear-gradient(180deg, #0c2233 0%, #081724 100%) !important; }
body.dark-mode .sidebar-user{ background: rgba(255,255,255,.05) !important; }

/* Sparkline داخل بطاقات لوحة التحكم */
.dash-stat{ position:relative; overflow:hidden; }
.ds-spark{ margin-top:10px; opacity:.95; }
.ds-change.ds-up{ color:#10b981; }
.ds-change.ds-down{ color:#ef4444; }
.ds-change.ds-flat{ color:var(--muted); }

/* قائمة الإعدادات المنسدلة في الشريط الجانبي — v33 */
.sb-group{ }
.sb-group > summary{ list-style:none; cursor:pointer; display:flex; align-items:center; gap:12px; position:relative; }
.sb-group > summary::-webkit-details-marker{ display:none; }
.sb-group .sb-caret{ margin-inline-start:auto; font-size:11px; transition:transform .2s; opacity:.7; }
.sb-group[open] .sb-caret{ transform:rotate(180deg); }
.sb-sub{ margin:2px 6px 6px; padding-inline-start:8px; border-inline-start:2px solid rgba(94,234,212,.25); display:flex; flex-direction:column; gap:2px; }
.sb-sub-item{ font-size:12.5px !important; padding:8px 12px !important; opacity:.92; }
.sb-sub-item .sidebar-nav-icon{ font-size:14px; }

/* أزرار المواعيد — مؤشر الازدحام (v46) */
.slot-btn:hover{ transform:translateY(-2px); box-shadow:0 4px 12px rgba(0,0,0,.10); border-color:var(--primary) !important; }
.slot-btn:active{ transform:translateY(0); }
.btn-new-booking:hover{ transform:translateY(-2px); box-shadow:0 10px 26px rgba(13,148,136,.45) !important; }
@media (max-width:600px){
  #timeSlotsGrid{ grid-template-columns:repeat(auto-fill,minmax(80px,1fr)) !important; }
  .btn-new-booking{ width:100%; }
}

/* زر «حجز جديد سريع» بحجم بطاقة إجمالي الحجوزات (v49) — أولوية أعلى من .btn */
.btn.quick-book-btn, a.quick-book-btn, .quick-book-btn{
  display:flex !important; align-items:center !important; justify-content:center !important;
  gap:12px !important; width:100% !important; box-sizing:border-box !important;
  min-height:118px !important;          /* = ارتفاع بطاقة الإحصائيات */
  height:auto !important;
  font-size:22px !important; font-weight:800 !important;
  border-radius:16px !important; padding:20px !important;
  box-shadow:0 8px 24px rgba(13,148,136,.30) !important;
  line-height:1.3 !important; text-align:center !important;
}
.btn.quick-book-btn:hover{ transform:translateY(-2px); box-shadow:0 12px 30px rgba(13,148,136,.42) !important; }
/* منع تجاوز الشاشة */
.page-header{ flex-wrap:wrap; gap:14px; }
.page-header > div:last-child{ flex:1 1 100%; min-width:0; max-width:100%; }
.dash-stats{ grid-template-columns:repeat(auto-fit,minmax(250px,1fr)); }
@media (max-width:600px){
  .btn.quick-book-btn, .quick-book-btn{ min-height:104px !important; font-size:20px !important; }
}

/* موجات صوتية حيّة للحجز الصوتي (v47) */
.vb-bar{ width:4px; height:6px; border-radius:3px; background:var(--primary); opacity:.85; transition:height .06s linear, opacity .06s linear; }
.vb-mic:hover{ transform:scale(1.05); }
.vb-mic.rec{ background:var(--danger) !important; color:#fff !important; }

/* ================= إصلاحات الوضع الليلي (v67) ================= */
/* أيقونات البطاقات: كانت خلفية فاتحة + نص أبيض = غير مرئية */
body.dark-mode .stat-card .stat-icon        { background: var(--primary-50) !important; color: #5eead4 !important; }
body.dark-mode .stat-card.success .stat-icon{ background: #064e3b !important; color: #6ee7b7 !important; }
body.dark-mode .stat-card.info    .stat-icon{ background: #1e3a8a !important; color: #93c5fd !important; }
body.dark-mode .stat-card.warning .stat-icon{ background: #78350f !important; color: #fcd34d !important; }
body.dark-mode .stat-card.purple  .stat-icon{ background: #4c1d95 !important; color: #ddd6fe !important; }
body.dark-mode .ds-icon                     { background: #0f172a !important; border: 1px solid var(--border) !important; }

/* نصوص ملوّنة مكتوبة inline: تفتيحها في الوضع الليلي (تُستثنى العناصر التي تحدّد خلفيتها بنفسها) */
body.dark-mode [style*="color:#0f172a"]:not([style*="background"]) { color: #e2e8f0 !important; }
body.dark-mode [style*="color:#1e293b"]:not([style*="background"]) { color: #e2e8f0 !important; }
body.dark-mode [style*="color:#334155"]:not([style*="background"]) { color: #cbd5e1 !important; }
body.dark-mode [style*="color:#64748b"]:not([style*="background"]) { color: #94a3b8 !important; }
body.dark-mode [style*="color:#dc2626"]:not([style*="background"]) { color: #fca5a5 !important; }
body.dark-mode [style*="color:#b91c1c"]:not([style*="background"]) { color: #fca5a5 !important; }
body.dark-mode [style*="color:#c2410c"]:not([style*="background"]) { color: #fdba74 !important; }
body.dark-mode [style*="color:#9a3412"]:not([style*="background"]) { color: #fdba74 !important; }
body.dark-mode [style*="color:#ea580c"]:not([style*="background"]) { color: #fdba74 !important; }
body.dark-mode [style*="color:#059669"]:not([style*="background"]) { color: #6ee7b7 !important; }
body.dark-mode [style*="color:#0f766e"]:not([style*="background"]) { color: #5eead4 !important; }
body.dark-mode [style*="color:#0d9488"]:not([style*="background"]) { color: #5eead4 !important; }
body.dark-mode [style*="color:#2563eb"]:not([style*="background"]) { color: #93c5fd !important; }
body.dark-mode [style*="color:#1e40af"]:not([style*="background"]) { color: #93c5fd !important; }
body.dark-mode [style*="color:#7c3aed"]:not([style*="background"]) { color: #c4b5fd !important; }
body.dark-mode [style*="color:#4338ca"]:not([style*="background"]) { color: #c4b5fd !important; }

/* جداول: صفوف الإجماليات الفاتحة */
body.dark-mode .data-table tfoot td,
body.dark-mode .data-table tfoot th { background: #0f172a !important; color: var(--text) !important; }

/* ================= توافق الموبايل (v70) ================= */
@media (max-width: 768px) {
  /* مساحة للزر العائم ➕ حتى لا يغطي آخر المحتوى */
  .main-content { padding-bottom: 96px !important; }
  /* الشبكات لا تتجاوز عرض الشاشة */
  .main-content [style*="grid-template-columns"] { max-width: 100%; }
  .main-content .card { max-width: 100%; min-width: 0; }
  /* الجداول تتمرّر أفقياً داخل بطاقتها بدل كسر الصفحة */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrapper .data-table th, .table-wrapper .data-table td { white-space: nowrap; }
  /* أزرار رأس الصفحة تلتف وتتسع */
  .page-header { flex-wrap: wrap; gap: 10px; }
  .page-header > div:last-child { width: 100%; }
  .page-header .btn { flex: 1 1 auto; justify-content: center; }
  /* النوافذ المنبثقة بعرض الشاشة */
  .modal { width: calc(100vw - 20px) !important; max-width: calc(100vw - 20px) !important; margin: 10px !important; }
  .modal-body { max-height: calc(100vh - 170px); overflow-y: auto; }
  /* الإدخالات بحجم 16px لمنع التكبير التلقائي في iPhone */
  input.form-control, select.form-control, textarea.form-control { font-size: 16px; }
  /* عناوين بطاقات المقارنة */
  .card-title { flex-wrap: wrap; }
  .dt-pager .btn { min-width: 40px; }
  /* صفوف ترجمة الأسماء */
  .tr-row { gap: 6px; }
}
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .stat-card .stat-value { font-size: 22px !important; }
  .stat-card .stat-icon { width: 38px !important; height: 38px !important; font-size: 18px !important; }
  .stat-card .stat-label { padding-inline-end: 44px !important; }
}
