@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --primary: #00a86b;
  --primary-light: #2ecf95;
  --primary-pale: #eafbf4;
  --primary-rgb: 0,168,107;
  --accent: #f0a500;
  --accent-light: #fff4d6;
  --danger: #e53e3e;
  --danger-light: #fff5f5;
  --info: #3182ce;
  --info-light: #ebf8ff;
  --success: #38a169;
  --warning: #d69e2e;
  --dark: #1a202c;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

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

html { overflow-x: hidden; max-width: 100vw; }

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--primary-pale);
  color: var(--dark);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
}

/* ===== AUTH PAGES ===== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eafbf4 0%, #d9f7eb 55%, #c9f2e2 100%);
  padding: 20px;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  width: 100%;
  box-sizing: border-box;
}
.auth-wrapper::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: rgba(var(--primary-rgb),0.10);
  top: -200px; right: -200px;
}
.auth-wrapper::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(var(--primary-rgb),0.08);
  bottom: -150px; left: -150px;
}
.auth-card {
  background: var(--white);
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.14);
  position: relative;
  z-index: 1;
  box-sizing: border-box;
}
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo .logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(var(--primary-rgb),0.25);
}
.auth-logo h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--dark);
}
.auth-logo p { color: var(--gray-500); font-size: 14px; margin-top: 4px; }
.auth-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--dark);
}
.auth-card .subtitle {
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 28px;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--dark);
  background: var(--gray-50);
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary-light);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb),0.12);
}
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { color: var(--danger); font-size: 12px; margin-top: 4px; }
.input-group { position: relative; }
.input-group .form-control { padding-left: 42px; }
.input-group .input-icon {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 16px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-text { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 4px 14px rgba(var(--primary-rgb),0.24);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(var(--primary-rgb),0.32); }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-pale); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-warning { background: var(--accent); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  box-shadow: 10px 0 40px rgba(0,0,0,0.06);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
}
.sidebar-brand {
  padding: 28px 20px 22px;
  border-bottom: 1px solid var(--gray-200);
  position: relative;
}
.sidebar-brand .brand-icon {
  width: 40px; height: 40px;
  background: var(--primary-pale);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--primary);
}
.sidebar-brand h2 { color: var(--dark); font-size: 16px; font-weight: 800; }
.sidebar-brand span { color: var(--gray-500); font-size: 12px; }

.sidebar-nav { padding: 16px 12px; flex: 1; overflow-y: auto; min-height: 0; }
.nav-section-label {
  color: var(--gray-500);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 8px 10px 6px;
}
.nav-item { margin-bottom: 2px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}
.nav-link:hover { background: var(--primary-pale); color: var(--primary); }
.nav-link.active { background: var(--primary-pale); color: var(--primary); border: 1px solid rgba(var(--primary-rgb),0.18); }
.nav-link .nav-icon { font-size: 18px; width: 22px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--gray-200);
}
.user-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}
.user-mini-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-pale);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); font-weight: 800; font-size: 14px;
  overflow: hidden;
}
.user-mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-mini-info h4 { color: var(--dark); font-size: 13px; font-weight: 700; }
.user-mini-info span { color: var(--gray-500); font-size: 11px; }
.logout-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  color: var(--gray-600);
  text-decoration: none;
  font-size: 13px;
  border-radius: 8px;
  transition: var(--transition);
  margin-top: 4px;
}
.logout-btn:hover { background: var(--gray-100); color: var(--dark); }

/* Main content */
.main-content {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}
.topbar {
  background: var(--white);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 50;
}
.topbar-left h1 { font-size: 20px; font-weight: 700; }
.topbar-left p { color: var(--gray-500); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.notif-btn {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--gray-100);
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.notif-btn:hover { background: var(--primary-pale); color: var(--primary); }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 9px; height: 9px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--white);
}
.page-content { padding: 28px; flex: 1; width: 100%; min-width: 0; box-sizing: border-box; overflow-x: hidden; }

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 700; }
.card-body { padding: 20px; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-info h3 { font-size: 26px; font-weight: 800; }
.stat-info p { color: var(--gray-500); font-size: 13px; font-weight: 500; }

/* ===== TABLES ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
}
tbody td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* Status badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-completed { background: #dbeafe; color: #1e40af; }
.badge-cancelled { background: var(--gray-100); color: var(--gray-600); }

/* ===== ALERTS ===== */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.alert-error { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }
.alert-info { background: #dbeafe; color: #1e40af; border-left: 4px solid #3b82f6; }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 4px solid #f59e0b; }

/* ===== MODALS ===== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--white);
  border-radius: 20px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from { opacity:0; transform: scale(0.95) translateY(10px); }
  to { opacity:1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.close-btn {
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); font-size: 20px; padding: 4px;
  transition: var(--transition);
  border-radius: 6px;
}
.close-btn:hover { background: var(--gray-100); color: var(--gray-700); }

/* ===== DOCTOR CARD ===== */
.doctor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.doctor-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}
.doctor-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--primary-light); }
.doctor-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--primary-pale);
  margin: 0 auto 16px;
  overflow: hidden;
  border: 3px solid var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: var(--primary);
  font-weight: 700;
}
.doctor-avatar img { width: 100%; height: 100%; object-fit: cover; }
.doctor-card h4 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.doctor-card .specialization {
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  background: var(--primary-pale);
  padding: 4px 12px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 12px;
}
.doctor-card .meta { color: var(--gray-500); font-size: 13px; }

/* ===== RESPONSIVE MOBILE CARDS (shared across admin pages) ===== */
.rm-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  box-sizing: border-box;
}
.rm-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.rm-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rm-card-info { flex: 1; min-width: 0; }
.rm-name {
  font-size: 15px; font-weight: 700; color: var(--dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rm-sub {
  font-size: 12px; color: var(--gray-500);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rm-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--gray-100);
}
.rm-meta-item { display: flex; flex-direction: column; gap: 2px; }
.rm-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--gray-400);
}
.rm-value { font-size: 13px; font-weight: 600; color: var(--dark); }

/* ===== FILE UPLOAD ===== */
.file-upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--gray-50);
}
.file-upload-area:hover { border-color: var(--primary-light); background: var(--primary-pale); }
.file-upload-area .upload-icon { font-size: 36px; margin-bottom: 8px; }
.file-upload-area p { color: var(--gray-500); font-size: 14px; }
.file-upload-area strong { color: var(--primary); }
input[type="file"] { display: none; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--gray-600); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); font-size: 13px; }
.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-center { align-items: center; }
.gap-2 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ===== RESPONSIVE ===== */

/* ── Book-page two-column layout ── */
.book-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}
.book-sticky {
  position: sticky;
  top: 80px;
}

/* ── Schedule two-column layout ── */
.schedule-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

/* ── Schedule row inside card ── */
.schedule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
  gap: 8px;
  flex-wrap: wrap;
}
.schedule-row-info { flex: 1; min-width: 0; }
.schedule-row-info strong { font-size: 14px; display: block; }
.schedule-row-info span  { display: block; font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.schedule-row-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.schedule-status { font-size: 12px; font-weight: 600; }

/* ── Inline detail tables ── */
.detail-table { width: 100%; font-size: 14px; border-collapse: collapse; }
.detail-table td { padding: 7px 4px; vertical-align: top; }
.detail-table td:first-child { color: var(--gray-500); white-space: nowrap; padding-right: 12px; width: 40%; }
.detail-table td:last-child  { font-weight: 500; }

/* ── Action button group ── */
.appt-actions { display: flex; gap: 8px; margin-top: 16px; }
.appt-actions form, .appt-actions .btn { flex: 1; }
.appt-actions .btn { width: 100%; justify-content: center; }

/* ── Filter tab row ── */
.filter-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }

/* ── Approval card grid ── */
.approval-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; padding: 14px; }
.approval-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--white);
}
.approval-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.approval-card-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; font-size: 13px; }
.approval-card-meta-item label { display: block; font-size: 11px; color: var(--gray-400); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.approval-card-actions { display: flex; gap: 8px; }
.approval-card-actions form, .approval-card-actions .btn { flex: 1; }
.approval-card-actions .btn { width: 100%; justify-content: center; }

/* ── Users search bar ── */
.users-search-bar { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.users-search-bar .form-control { flex: 1; min-width: 160px; height: 42px; padding: 0 14px; box-sizing: border-box; }
.users-search-bar .btn { height: 42px; padding: 0 18px; display: flex; align-items: center; justify-content: center; white-space: nowrap; flex-shrink: 0; }
.search-card-body { padding: 14px 20px; }
.search-select { max-width: 180px; flex-shrink: 0; }

/* ── Slots grid ── */
.slots-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-height: 48px; }
.slots-scroll {
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 10px;
  background: var(--gray-50);
  scrollbar-width: thin;
  scrollbar-color: var(--primary-light) var(--gray-100);
}
.slots-scroll::-webkit-scrollbar { width: 6px; }
.slots-scroll::-webkit-scrollbar-track { background: var(--gray-100); border-radius: 10px; }
.slots-scroll::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 10px; }

/* Hamburger toggle button — hidden on desktop */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(var(--primary-rgb),0.28);
  transition: opacity 0.2s, var(--transition);
}
.sidebar-toggle:hover { background: var(--primary-light); }
/* Hide hamburger when sidebar is open so it doesn't overlap brand */
.sidebar.open ~ * .sidebar-toggle,
body.sidebar-open .sidebar-toggle {
  opacity: 0;
  pointer-events: none;
}

/* Sidebar overlay backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}
.sidebar-backdrop.active { display: block; }

/* ============================================================
   MOBILE RESPONSIVE — max-width: 768px
   ============================================================ */
@media (max-width: 768px) {

  /* ── Sidebar ── */
  .sidebar-toggle { display: flex; }
  .sidebar {
    transform: translateX(-280px);
    width: 260px;
    z-index: 150;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  .sidebar-brand { padding-top: 32px; }

  /* ── Layout ── */
  .main-content { margin-left: 0; }
  .page-content { padding: 14px 12px; }

  /* ── Topbar ── */
  .topbar {
    padding: 10px 12px 10px 64px;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 60px;
    align-items: center;
  }
  .topbar-left { flex: 1; min-width: 0; }
  .topbar-left h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-left p { display: none; }
  .topbar-right { gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
  .topbar-right .btn { padding: 6px 10px; font-size: 12px; }

  /* ── Cards ── */
  .card { border-radius: 10px; }
  .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
  .card-header h3 { font-size: 14px; }
  .card-body { padding: 12px; }
  .mb-3 { margin-bottom: 12px !important; }
  .mb-2 { margin-bottom: 10px !important; }

  /* ── Buttons ── */
  .btn    { padding: 9px 14px; font-size: 13px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; }
  .action-btns { flex-wrap: wrap; gap: 4px; }
  .action-btn  { padding: 5px 8px; font-size: 11px; }

  /* ── Forms ── */
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .grid-2   { grid-template-columns: 1fr; gap: 14px; }
  .form-group { margin-bottom: 14px; }
  .form-group label { font-size: 12px; }
  .form-control { font-size: 14px; padding: 10px 12px; }

  /* ── Search / filter bars ── */
  .search-card-body { padding: 12px !important; }
  .users-search-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .users-search-bar .form-control,
  .users-search-bar select.form-control {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 48px !important;
    padding: 12px 16px !important;
    font-size: 15px !important;
    border-radius: 10px !important;
    box-sizing: border-box !important;
    display: block !important;
  }
  .users-search-bar .btn,
  .users-search-bar .btn.btn-sm,
  .users-search-bar a.btn,
  .users-search-bar button[type="submit"],
  .users-search-bar a[class*="btn"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 48px !important;
    padding: 0 16px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border-radius: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }
  .search-select { max-width: 100% !important; width: 100% !important; flex-shrink: unset; }

  /* ── Stats grid ── */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
  .stats-grid[style*="grid-template-columns"] { grid-template-columns: repeat(2, 1fr) !important; }
  .stat-card  { padding: 12px 10px; gap: 10px; min-width: 0; box-sizing: border-box; }
  .stat-icon  { width: 38px; height: 38px; font-size: 17px; border-radius: 10px; flex-shrink: 0; }
  .stat-info  { min-width: 0; overflow: hidden; }
  .stat-info h3 { font-size: 20px; }
  .stat-info p  { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* ── Tables ── */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -1px; }
  .card .table-wrapper { border-radius: 0; }
  table { min-width: 500px; }
  thead th { padding: 10px 10px; font-size: 11px; }
  tbody td  { padding: 10px 10px; font-size: 12px; }
  .badge { padding: 3px 8px; font-size: 11px; }

  /* ── Filter / role tabs ── */
  .filter-tabs { gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
  .filter-tabs .btn { padding: 5px 10px; font-size: 12px; }
  .role-tab { gap: 6px; flex-wrap: wrap; }
  .role-tab a { padding: 5px 10px; font-size: 12px; }

  /* ── Doctor grid ── */
  .doctor-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .doctor-card { padding: 14px 10px; }
  .doctor-avatar { width: 56px; height: 56px; font-size: 20px; margin-bottom: 10px; }
  .doctor-card h4 { font-size: 13px; }
  .doctor-card .specialization { font-size: 11px; padding: 3px 8px; }
  .doctor-card .meta { font-size: 12px; }

  /* ── Approval cards ── */
  .approval-cards { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .approval-card-meta { grid-template-columns: 1fr 1fr; gap: 6px; }
  .approval-card-actions { flex-direction: column; gap: 6px; }
  .approval-card-actions form, .approval-card-actions .btn { width: 100%; }

  /* ── Appointment actions ── */
  .appt-actions { flex-direction: column; gap: 8px; margin-top: 12px; }
  .appt-actions form, .appt-actions .btn { flex: unset; width: 100%; }

  /* ── Book page ── */
  .book-layout { grid-template-columns: 1fr; gap: 14px; }
  .book-sticky { position: static; top: auto; }

  /* ── Slots ── */
  .slots-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .slots-scroll { max-height: 180px; }

  /* ── Schedule ── */
  .schedule-layout { grid-template-columns: 1fr; gap: 14px; }
  .schedule-row { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 14px; }
  .schedule-row-actions { width: 100%; justify-content: flex-end; }

  /* ── Detail table ── */
  .detail-table td { padding: 6px 4px; font-size: 13px; }
  .detail-table td:first-child { width: auto; white-space: normal; }

  /* ── Profile ── */
  .profile-single-col { max-width: 100%; gap: 14px; }
  .profile-photo-lg { width: 80px !important; height: 80px !important; }
  img[style*="width:120px"], img[style*="width: 120px"] { width: 80px !important; height: 80px !important; }

  /* ── Modals ── */
  .modal-overlay { padding: 8px; align-items: flex-end; }
  .modal {
    border-radius: 20px 20px 14px 14px;
    max-height: 92vh;
    max-width: 100% !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-header { padding: 14px 16px; }
  .modal-header h3 { font-size: 16px; }
  .modal-body  { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .modal-footer .btn { flex: 1; min-width: 0; justify-content: center; }

  /* ── Auth ── */
  .auth-wrapper {
    padding: 16px;
    align-items: center;
    width: 100vw;
    max-width: 100vw;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .auth-wrapper::before,
  .auth-wrapper::after { display: none; }
  .auth-card {
    padding: 28px 20px;
    border-radius: 18px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .auth-card h2 { font-size: 20px; }
  .auth-card[style*="max-width:600px"] { max-width: 100% !important; }
  .btn-block {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* ── Misc ── */
  .alert { font-size: 13px; padding: 10px 12px; }
  .empty-state { padding: 36px 16px; }
  .empty-state .empty-icon { font-size: 38px; }
  .empty-state h3 { font-size: 15px; }
  .info-box { font-size: 13px; padding: 9px 12px; }
  .file-upload-area { padding: 20px 16px; }
  #toast-container { left: 10px; right: 10px; bottom: 14px; }
  .toast { min-width: unset; max-width: 100%; }
}

/* ============================================================
   EXTRA SMALL — max-width: 480px
   ============================================================ */
@media (max-width: 480px) {
  .topbar { padding: 8px 8px 8px 58px; min-height: 54px; }
  .topbar-left h1 { font-size: 14px; }
  .page-content { padding: 10px 8px; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 10px 8px; gap: 8px; }
  .stat-icon { width: 32px; height: 32px; font-size: 15px; }
  .stat-info h3 { font-size: 17px; }
  .stat-info p { font-size: 10px; }

  .card-header { padding: 10px 12px; }
  .card-body { padding: 10px; }

  table { min-width: 440px; }
  thead th { padding: 8px 8px; font-size: 10px; }
  tbody td { padding: 8px 8px; font-size: 11px; }

  .doctor-grid { grid-template-columns: 1fr; }
  .doctor-card { padding: 14px; text-align: left; display: flex; align-items: center; gap: 14px; }
  .doctor-avatar { margin: 0; flex-shrink: 0; width: 52px; height: 52px; font-size: 18px; }

  .role-tab a { padding: 4px 8px; font-size: 11px; }
  .filter-tabs .btn { padding: 4px 8px; font-size: 11px; }

  .btn { padding: 8px 12px; font-size: 12px; }
  .btn-sm { padding: 5px 9px; font-size: 11px; }

  .auth-card { padding: 22px 16px; border-radius: 14px; width: 100%; box-sizing: border-box; }
  .btn-block { width: 100% !important; max-width: 100% !important; box-sizing: border-box !important; }
  .auth-logo .logo-icon { width: 52px; height: 52px; font-size: 22px; }
  .auth-logo h1 { font-size: 18px; }

  .slots-grid { grid-template-columns: 1fr 1fr; gap: 5px; }

  .modal-header h3 { font-size: 15px; }
  .modal-body { padding: 12px; }
  .modal-footer .btn { font-size: 12px; padding: 8px 10px; }

  .sidebar-brand { padding-top: 28px; }
  .sidebar-brand h2 { font-size: 14px; }
}

/* ===== INFO BOX ===== */
.info-box {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
}
.info-box-primary { background: var(--primary-pale); color: var(--primary); }
.info-box-warning  { background: #fef3c7; color: #92400e; }
.info-box-danger   { background: #fee2e2; color: #991b1b; }
.profile-single-col { display: flex; flex-direction: column; gap: 24px; max-width: 540px; }
.superuser-tag {
  background: #fef3c7; color: #92400e;
  padding: 2px 9px; border-radius: 12px;
  font-size: 12px; font-weight: 700;
  display: inline-block; margin-left: 6px;
}

/* Checkbox label */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
  cursor: pointer;
  font-size: 14px;
}

/* File preview */
.file-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--primary-pale);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  font-size: 13px; color: var(--primary); font-weight: 600;
}

/* Avatar initials */
.avatar-initials {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-weight: 700; color: var(--white);
  background: var(--primary);
}

/* Divider */
.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0;
  color: var(--gray-400); font-size: 13px;
}
.divider::before, .divider::after {
  content: ''; flex: 1;
  height: 1px; background: var(--gray-200);
}

/* ===== FLOAT TOAST NOTIFICATIONS ===== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: all;
  min-width: 300px;
  max-width: 360px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
  border-left: 5px solid var(--primary);
  padding: 14px 16px 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: toastIn 0.4s cubic-bezier(.21,1.02,.73,1) forwards;
  position: relative;
  overflow: hidden;
}
.toast.toast-success { border-left-color: #10b981; }
.toast.toast-error   { border-left-color: #ef4444; }
.toast.toast-info    { border-left-color: #3b82f6; }
.toast.toast-warning { border-left-color: #f59e0b; }
.toast.hide {
  animation: toastOut 0.35s ease forwards;
}
.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}
.toast-body { flex: 1; min-width: 0; }
.toast-title {
  font-size: 13px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast-msg {
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.toast-time {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}
.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 16px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  margin-top: -2px;
  transition: color 0.2s;
}
.toast-close:hover { color: #1a1a2e; }
.toast-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 0 14px;
  animation: toastProgress linear forwards;
  opacity: 0.4;
}
.toast.toast-success .toast-progress { background: #10b981; }
.toast.toast-error   .toast-progress { background: #ef4444; }
.toast.toast-info    .toast-progress { background: #3b82f6; }
.toast.toast-warning .toast-progress { background: #f59e0b; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(60px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(60px) scale(0.95); }
}
@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}
/* ===== NOTIF BELL BADGE ===== */
.notif-count {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--white);
  padding: 0 3px;
}

/* ============================================================
   MOBILE RESPONSIVENESS ENHANCEMENTS v2
   Full phone compatibility for all user roles
   ============================================================ */

/* ── Touch target minimum size (WCAG AA) ── */
@media (max-width: 768px) {
  a, button, .btn, .nav-link, input[type="submit"], input[type="button"],
  input[type="checkbox"], input[type="radio"], select {
    -webkit-tap-highlight-color: rgba(var(--primary-rgb),0.12);
  }

  /* Ensure all tappable elements have minimum 44px touch area */
  .btn, .nav-link, .notif-btn, .close-btn, .logout-btn {
    min-height: 44px;
  }

  /* ── Prevent horizontal overflow everywhere ── */
  *, *::before, *::after {
    max-width: 100%;
    box-sizing: border-box;
  }
  img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
  }

  /* ── Safe area support for notched phones (iPhone X+, Android) ── */
  .topbar {
    padding-left: max(64px, env(safe-area-inset-left, 64px));
    padding-right: max(12px, env(safe-area-inset-right, 12px));
  }
  .sidebar {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .page-content {
    padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
  }
  #toast-container {
    bottom: max(14px, env(safe-area-inset-bottom, 14px));
  }

  /* ── Input zoom prevention (prevents iOS zoom on focus) ── */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="date"],
  input[type="time"],
  input[type="search"],
  select, textarea {
    font-size: 16px !important;
  }

  /* ── Scrollable tables with momentum scrolling ── */
  .table-wrapper {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  /* ── Topbar title fix for long names ── */
  .topbar-left h1 {
    max-width: calc(100vw - 130px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ── Card actions horizontal scroll on small screens ── */
  .action-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  /* ── Fix table action buttons wrapping ── */
  tbody td:last-child {
    white-space: nowrap;
  }

  /* ── Auth page fixes ── */
  .auth-card .form-row {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  /* ── Divider spacing in auth ── */
  .divider { margin: 16px 0; }

  /* ── Auth link line ── */
  .auth-card p.text-center {
    font-size: 13px;
    line-height: 1.6;
  }

  /* ── Modal bottom sheet: full width ── */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    border-radius: 20px 20px 0 0 !important;
    max-height: 95vh !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* ── Profile page stacked layout ── */
  .profile-single-col {
    max-width: 100% !important;
    width: 100%;
    gap: 12px;
  }

  /* ── Slot radio buttons — bigger tap area ── */
  .slot-radio-label {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Doctor card in patient view: compact list on small phones ── */
  .doctor-card {
    text-align: left !important;
  }

  /* ── Approval card full width actions ── */
  .approval-card-actions {
    flex-direction: column;
  }
  .approval-card-actions form,
  .approval-card-actions .btn {
    width: 100%;
    flex: unset;
  }

  /* ── Schedule add form full width ── */
  .schedule-layout .card { width: 100%; }

  /* ── Book page: sticky summary on mobile becomes normal flow ── */
  .book-sticky {
    position: static !important;
    top: auto !important;
  }

  /* ── Overflow fix for stat cards ── */
  .stats-grid {
    overflow: hidden;
  }

  /* ── Fix inline styles that can cause overflow ── */
  [style*="width:600px"],
  [style*="width: 600px"],
  [style*="max-width:600px"],
  [style*="max-width: 600px"] {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* ── Better scrollbar for slots ── */
  .slots-scroll {
    scroll-snap-type: y mandatory;
  }

  /* ── Notification button on topbar ── */
  .notif-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }

  /* ── Long words wrap correctly ── */
  .rm-name, .rm-value, .toast-title, .toast-msg {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  /* ── Filter tabs: make them full-scroll row ── */
  .filter-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    gap: 8px;
    scrollbar-width: none;
  }
  .filter-tabs::-webkit-scrollbar { display: none; }
  .filter-tabs .btn {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* ── Print receipt / consultation full width ── */
  .print-area {
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px !important;
  }

}

/* ── Doctor grid 1-col on very small phones ── */
@media (max-width: 360px) {
  .doctor-grid { grid-template-columns: 1fr !important; }
  .stats-grid  { grid-template-columns: 1fr 1fr !important; }
}

/* ============================================================
   EXTRA SMALL PHONE — max-width: 375px (iPhone SE, Galaxy A series)
   ============================================================ */
@media (max-width: 375px) {
  .topbar { padding-left: 56px; }
  .sidebar-toggle { width: 36px; height: 36px; font-size: 17px; left: 10px; top: 12px; }

  .stat-info h3 { font-size: 16px; }
  .stat-info p { font-size: 10px; }

  .btn { font-size: 12px; padding: 8px 10px; }
  .btn-sm { font-size: 11px; padding: 5px 8px; }

  .auth-card { padding: 20px 14px; }
  .auth-logo h1 { font-size: 17px; }
  .auth-logo .logo-icon { width: 48px; height: 48px; font-size: 20px; }

  table { min-width: 400px; }
  thead th { font-size: 10px; padding: 7px 7px; }
  tbody td { font-size: 11px; padding: 7px 7px; }

  .modal-header h3 { font-size: 14px; }
  .modal-body { padding: 10px 12px; }
}

/* ============================================================
   LANDSCAPE PHONE — handles landscape orientation
   ============================================================ */
@media (max-height: 500px) and (orientation: landscape) {
  .auth-wrapper {
    align-items: flex-start;
    padding: 12px 16px;
  }
  .auth-card {
    padding: 20px 24px;
    margin: 0 auto;
  }
  .auth-logo { margin-bottom: 16px; }
  .auth-logo .logo-icon { width: 44px; height: 44px; }

  .sidebar {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal {
    max-height: 88vh !important;
    overflow-y: auto;
  }
}

/* ============================================================
   LARGE MOBILE / SMALL TABLET — 769px to 1024px
   ============================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar { width: 220px; }
  .main-content { margin-left: 220px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .doctor-grid { grid-template-columns: repeat(2, 1fr); }
  .approval-cards { grid-template-columns: repeat(2, 1fr); }

  .book-layout {
    grid-template-columns: 1fr 320px;
    gap: 18px;
  }

  .page-content { padding: 20px; }
  .topbar { padding: 14px 20px; }
}

/* ============================================================
   PRINT STYLES — for print_receipt and print_consultation
   ============================================================ */
@media print {
  .sidebar, .sidebar-toggle, .sidebar-backdrop,
  .topbar, #toast-container, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: white !important; }
}
