/* mehjam - Formal Monochrome Design */

:root {
  --primary: #0a0a0a;
  --secondary: #1f1f1f;
  --border: #d0d0d0;
  --border-light: #e8e8e8;
  --bg: #f7f7f7;
  --bg-white: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --text-light: #9a9a9a;
  --hover-bg: #f0f0f0;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
  --sidebar-w: 260px;
  --header-h: 58px;
}

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

body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* RTL Support */
[dir="rtl"] { direction: rtl; text-align: right; }
[dir="ltr"] { direction: ltr; text-align: left; }

/* ─── AUTH PAGES ─────────────────────────── */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: #eef2f7;
}

/* Medical background image with subtle overlay */
.auth-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('/static/medical-bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.18;
  z-index: 0;
}

/* Soft gradient overlay on top of image */
.auth-container::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(10,30,60,0.55) 0%, rgba(0,80,140,0.3) 50%, rgba(10,30,60,0.55) 100%);
  z-index: 1;
}

.auth-card {
  position: relative;
  z-index: 2;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.7);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 420px;
  padding: 44px 40px;
  border-radius: 4px;
}

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; border: none; min-height: 100vh; max-width: 100%; border-radius: 0; backdrop-filter: none; background: var(--bg-white); }
  .auth-container { align-items: flex-start; }
  .auth-logo { margin-bottom: 24px; }
  .auth-logo h1 { font-size: 22px; }
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 20px;
}

.auth-logo h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--primary);
}

.auth-logo p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.2s;
}

[dir="rtl"] .sidebar { right: 0; left: auto; }
[dir="ltr"] .sidebar { left: 0; right: auto; }

.sidebar-logo {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.sidebar-logo h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.sidebar-logo p {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  text-decoration: none;
}

[dir="rtl"] .nav-item { border-left: none; border-right: 3px solid transparent; }

.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-left-color: #fff;
}

[dir="rtl"] .nav-item:hover, [dir="rtl"] .nav-item.active {
  border-left-color: transparent;
  border-right-color: #fff;
}

.nav-item i { width: 18px; text-align: center; font-size: 14px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
}

.sidebar-user {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  margin-bottom: 10px;
}

.sidebar-user strong { display: block; color: #fff; font-size: 13px; }

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

[dir="rtl"] .main-content { margin-right: var(--sidebar-w); margin-left: 0; }
[dir="ltr"] .main-content { margin-left: var(--sidebar-w); margin-right: 0; }

/* Header */
.top-header {
  height: var(--header-h);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-actions { display: flex; align-items: center; gap: 12px; }

.notif-btn {
  position: relative;
  background: none;
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
}

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

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--primary);
  color: #fff;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-switcher {
  background: none;
  border: 1px solid var(--border);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lang-switcher:hover { background: var(--hover-bg); }

/* Page Content */
.page-content { padding: 24px; flex: 1; }

/* ─── CARDS & PANELS ─────────────────────── */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

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

.card-header h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text);
}

.card-body { padding: 20px; }

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

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.stat-info { flex: 1; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

/* ─── FORMS ─────────────────────────────── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}

textarea { resize: vertical; min-height: 90px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ─── BUTTONS ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.15s;
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

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

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--border);
}

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

.btn-danger {
  background: #fff;
  color: #c0392b;
  border-color: #c0392b;
}

.btn-danger:hover { background: #c0392b; color: #fff; }

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

/* ─── TABLE ─────────────────────────────── */
.table-wrapper { overflow-x: auto; }

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

thead tr { border-bottom: 2px solid var(--primary); }

th {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: inherit;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tr:hover td { background: var(--hover-bg); }
tr:last-child td { border-bottom: none; }

/* ─── BADGES ─────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border: 1px solid;
}

.badge-active { color: #1a6b3a; background: #e8f5ed; border-color: #1a6b3a; }
.badge-inactive { color: #7a2020; background: #fdf0f0; border-color: #c0392b; }
.badge-improving { color: #1a5c8a; background: #e8f2fb; border-color: #1a5c8a; }
.badge-stable { color: #4a4a00; background: #fafae0; border-color: #8a8a00; }
.badge-worsening { color: #8a3300; background: #fff3e8; border-color: #c05c00; }
.badge-recovered { color: #1a6b3a; background: #e8f5ed; border-color: #1a6b3a; }
.badge-critical { color: #7a2020; background: #fdf0f0; border-color: #c0392b; }

/* ─── MODAL ─────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--bg-white);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-lg { max-width: 760px; }

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

.modal-header h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

/* ─── NOTIFICATIONS PANEL ─────────────────── */
.notif-panel {
  position: fixed;
  top: var(--header-h);
  width: 340px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  z-index: 150;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  display: none;
}

[dir="rtl"] .notif-panel { right: 20px; left: auto; }
[dir="ltr"] .notif-panel { right: 20px; left: auto; }

.notif-panel.open { display: block; }

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}

.notif-item:hover { background: var(--hover-bg); }
.notif-item.unread { border-right: 3px solid var(--primary); }
[dir="ltr"] .notif-item.unread { border-right: none; border-left: 3px solid var(--primary); }

.notif-item h4 { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.notif-item p { font-size: 12px; color: var(--text-muted); }
.notif-item time { font-size: 11px; color: var(--text-light); }

/* ─── SEARCH & FILTERS ─────────────────── */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrap i {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}

[dir="rtl"] .search-input-wrap i { right: 10px; left: auto; }
[dir="ltr"] .search-input-wrap i { left: 10px; right: auto; }

[dir="rtl"] .search-input { padding-right: 32px; }
[dir="ltr"] .search-input { padding-left: 32px; }

/* ─── IMAGE GRID ─────────────────────────── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.image-card {
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  background: #f0f0f0;
}

.image-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.image-card-footer {
  padding: 8px 10px;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
}

.image-card-footer span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.image-type-before { border-top: 3px solid #1a1a1a; }
.image-type-after { border-top: 3px solid #4a4a4a; }
.image-type-progress { border-top: 3px solid #7a7a7a; }

/* ─── PAGINATION ─────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
}

.page-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-white);
  cursor: pointer;
  font-size: 13px;
}

.page-btn:hover, .page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ─── ALERTS ─────────────────────────────── */
.alert {
  padding: 10px 16px;
  border: 1px solid;
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: #e8f5ed; border-color: #1a6b3a; color: #1a6b3a; }
.alert-error { background: #fdf0f0; border-color: #c0392b; color: #c0392b; }
.alert-info { background: #e8f2fb; border-color: #1a5c8a; color: #1a5c8a; }

/* ─── UPLOAD AREA ─────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  transition: all 0.2s;
}

.upload-area:hover { border-color: var(--primary); background: var(--hover-bg); }
.upload-area.dragover { border-color: var(--primary); background: #f0f0f0; }
.upload-area i { font-size: 32px; color: var(--text-muted); margin-bottom: 8px; }
.upload-area p { color: var(--text-muted); font-size: 13px; }

/* ─── PATIENT CARD ─────────────────────────── */
.patient-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-white);
}

.patient-avatar {
  width: 56px;
  height: 56px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
}

.patient-info h2 { font-size: 18px; font-weight: 700; }
.patient-info .code { font-size: 12px; color: var(--text-muted); font-family: monospace; }
.patient-info .diag { font-size: 13px; color: var(--text); margin-top: 4px; }

/* ─── TABS ─────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tab-btn.active, .tab-btn:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ─── EMPTY STATE ─────────────────────────── */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; }

/* ─── LOADING ─────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

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

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

/* ─── MULTI-UPLOAD ZONE ─────────────────── */
.multi-upload-zone {
  border: 1.5px dashed var(--border);
  padding: 14px;
  cursor: pointer;
  background: var(--bg);
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  transition: all 0.2s;
  position: relative;
}

.multi-upload-zone:hover {
  border-color: var(--primary);
  background: #f0f0f0;
}

.multi-upload-zone.dragover {
  border-color: var(--primary);
  background: #ececec;
  border-style: solid;
}

/* تحسين modal التقرير - اجعله أطول */
.modal-report {
  max-width: 680px;
  max-height: 92vh;
}

/* مؤشر نوع الصورة - شريط ملون */
.img-badge-before  { background: var(--primary); color: #fff; }
.img-badge-during  { background: #555;            color: #fff; }
.img-badge-after   { background: #aaa;            color: #fff; }

.img-type-badge {
  display: inline-block;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

/* ─── PRINT ─────────────────────────────── */
@media print {
  .sidebar, .top-header, .modal-overlay, .btn { display: none !important; }
  .main-content { margin: 0 !important; }
}

/* ══════════════════════════════════════════
   MOBILE — نظام متجاوب شامل
   ══════════════════════════════════════════ */

/* ─── عناصر مرئية/مخفية حسب الجهاز ─────── */
.mobile-bottom-nav  { display: none; }
.show-on-mobile-flex { display: none; }
.show-on-mobile      { display: none; }
.fab-add             { display: none; }

/* ─── Hamburger (مخفي على سطح المكتب) ───── */
.hamburger-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 17px;
  flex-shrink: 0;
  border-radius: 2px;
}

/* ─── Backdrop الـ sidebar ───────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
}
.sidebar-backdrop.show { display: block; }

/* ══════════════════════════════════════════
   TABLET  ≤ 1024px
   ══════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .page-content { padding: 18px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
}

/* ══════════════════════════════════════════
   MOBILE  ≤ 768px
   ══════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── متغيرات الجوال ─────────────────── */
  :root {
    --header-h: 54px;
    --bottom-nav-h: 62px;
  }

  /* ── body ────────────────────────────── */
  html, body {
    overflow-x: hidden;
    width: 100%;
  }
  body {
    padding-bottom: var(--bottom-nav-h);
    -webkit-text-size-adjust: 100%;
  }

  /* ══ SIDEBAR ══════════════════════════ */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(280px, 82vw);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }
  [dir="rtl"] .sidebar {
    right: 0;
    left: auto;
    transform: translateX(100%);
  }
  [dir="ltr"] .sidebar {
    left: 0;
    right: auto;
  }
  .sidebar.open {
    transform: translateX(0) !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }
  [dir="rtl"] .sidebar.open {
    box-shadow: -4px 0 24px rgba(0,0,0,0.3);
  }
  #sidebar-close-btn { display: flex !important; }

  /* ══ MAIN CONTENT ═══════════════════════ */
  [dir="rtl"] .main-content,
  [dir="ltr"] .main-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100%;
    min-width: 0;
  }

  /* ══ HEADER ══════════════════════════════ */
  .top-header {
    padding: 0 10px;
    height: var(--header-h);
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .hamburger-btn { display: flex; }
  .page-title {
    font-size: 13px;
    letter-spacing: 0.3px;
    max-width: calc(100vw - 140px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .header-actions { gap: 8px; }
  .lang-switcher { padding: 4px 8px; font-size: 11px; }
  .notif-btn { width: 34px; height: 34px; }

  /* ══ PAGE CONTENT ════════════════════════ */
  .page-content {
    padding: 10px;
    overflow-x: hidden;
  }

  /* ══ CARDS ═══════════════════════════════ */
  .card { margin-bottom: 12px; }

  .card-header {
    padding: 11px 12px;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 0;
  }
  .card-header h3 {
    font-size: 12px;
    flex: 1;
    min-width: 0;
  }
  .card-header > div,
  .card-header > button {
    flex-shrink: 0;
  }

  .card-body { padding: 12px; }

  /* ══ STATS ═══════════════════════════════ */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
  }
  .stat-card {
    padding: 12px 10px;
    gap: 8px;
    align-items: center;
  }
  .stat-icon {
    width: 34px;
    height: 34px;
    font-size: 14px;
    flex-shrink: 0;
  }
  .stat-value { font-size: 20px; line-height: 1; }
  .stat-label { font-size: 9px; margin-top: 3px; }

  /* ══ FORMS ═══════════════════════════════ */
  .form-row { grid-template-columns: 1fr; gap: 0; }
  input, select, textarea {
    font-size: 16px !important; /* منع iOS zoom */
    padding: 11px 12px;
    -webkit-appearance: none;
  }
  textarea { min-height: 80px; }
  label { font-size: 11px; margin-bottom: 5px; }
  .form-group { margin-bottom: 14px; }

  /* ══ BUTTONS ════════════════════════════ */
  .btn {
    padding: 9px 13px;
    font-size: 12px;
    gap: 5px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .btn-sm { padding: 6px 9px; font-size: 10px; }
  .btn-icon {
    padding: 7px;
    min-width: 34px;
    min-height: 34px;
    justify-content: center;
  }

  /* ══ TABLES ══════════════════════════════ */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 0 12px;
  }
  table {
    font-size: 12px;
    min-width: 480px;
    width: 100%;
  }
  th {
    padding: 8px 10px;
    font-size: 10px;
    white-space: nowrap;
  }
  td {
    padding: 9px 10px;
    vertical-align: middle;
  }
  td code { font-size: 11px; }

  /* ══ MODAL ═══════════════════════════════ */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
    z-index: 300;
  }
  .modal, .modal-lg, .modal-report {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 92vh;
    border-bottom: none;
    border-left: none;
    border-right: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-header {
    padding: 14px 14px;
    position: sticky;
    top: 0;
    background: var(--bg-white);
    z-index: 1;
  }
  .modal-header h3 { font-size: 12px; }
  .modal-body { padding: 14px; }
  .modal-footer {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
    position: sticky;
    bottom: 0;
    background: var(--bg-white);
    border-top: 1px solid var(--border);
  }
  .modal-footer .btn {
    flex: 1;
    justify-content: center;
    min-width: 100px;
  }

  /* ══ PATIENT DETAIL ══════════════════════ */
  .patient-header {
    flex-wrap: wrap;
    padding: 12px;
    gap: 10px;
    align-items: flex-start;
  }
  .patient-avatar {
    width: 44px;
    height: 44px;
    font-size: 17px;
    flex-shrink: 0;
  }
  .patient-info { flex: 1; min-width: 0; }
  .patient-info h2 { font-size: 15px; word-break: break-word; }
  .patient-info .code { font-size: 11px; }
  .patient-info .diag { font-size: 12px; }

  /* ── action buttons row داخل patient-header */
  .patient-header .show-on-mobile-flex {
    width: 100%;
    gap: 6px;
    flex-wrap: wrap;
  }
  .patient-header .show-on-mobile-flex .btn {
    flex: 1;
    justify-content: center;
    min-width: 70px;
    padding: 8px 6px;
    font-size: 11px;
  }

  /* ── patient info grid داخل card-body */
  .patient-info-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  /* ══ TABS ════════════════════════════════ */
  .tabs {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    gap: 0;
  }
  .tab-btn { padding: 10px 16px; font-size: 12px; }

  /* ══ REPORT CARDS (inside patient detail) ═ */
  .report-card-body-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .report-images-row {
    flex-wrap: wrap;
    gap: 6px !important;
  }
  .report-images-row img,
  .report-images-row div > img {
    width: 80px !important;
    height: 68px !important;
  }

  /* ══ IMAGE GRID ══════════════════════════ */
  .image-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .image-card img { height: 100px; }

  /* ══ UPLOAD ZONE ═════════════════════════ */
  .upload-area { padding: 20px 14px; }
  .upload-area i { font-size: 26px; }
  .multi-upload-zone { padding: 10px; min-height: 50px; }

  /* ══ SEARCH BAR ══════════════════════════ */
  .search-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .search-bar > * { width: 100% !important; min-width: 0 !important; }
  .search-input-wrap { min-width: 0; flex: none; }
  .search-bar select { padding: 10px 12px; }

  /* ══ NOTIFICATIONS PANEL ═════════════════ */
  .notif-panel {
    width: 100vw !important;
    right: 0 !important;
    left: 0 !important;
    top: var(--header-h) !important;
    max-height: calc(100vh - var(--header-h) - var(--bottom-nav-h)) !important;
    border-left: none !important;
    border-right: none !important;
  }

  /* ══ BOTTOM NAV ══════════════════════════ */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    background: var(--primary);
    z-index: 98;
    border-top: 2px solid rgba(255,255,255,0.1);
    align-items: stretch;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
  }
  .mob-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: rgba(255,255,255,0.55);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    border: none;
    background: none;
    font-family: inherit;
    padding: 6px 4px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    position: relative;
  }
  .mob-nav-item.active { color: #fff; }
  .mob-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    background: #fff;
    border-radius: 0 0 2px 2px;
  }
  .mob-nav-item:active { background: rgba(255,255,255,0.1); }
  .mob-nav-item i   { font-size: 19px; display: block; }
  .mob-nav-item span { font-size: 9px; text-transform: uppercase; letter-spacing: 0.3px; }

  /* ══ FAB ADD BUTTON ══════════════════════ */
  .fab-add {
    display: flex !important;
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 14px);
    width: 50px;
    height: 50px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(0,0,0,0.35);
    z-index: 97;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  [dir="rtl"] .fab-add { left: 16px; right: auto; }
  [dir="ltr"] .fab-add { right: 16px; left: auto; }

  /* ══ SHOW / HIDE HELPERS ═════════════════ */
  .show-on-mobile-flex { display: flex !important; }
  .show-on-mobile      { display: block !important; }
  .hide-on-mobile      { display: none !important; }

  /* ══ DASHBOARD GRIDS: force single col ═══ */
  .dashboard-grid,
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* ══ EMPTY STATE ════════════════════════ */
  .empty-state { padding: 30px 16px; }
  .empty-state i { font-size: 32px; }

  /* ══ ALERTS ════════════════════════════ */
  .alert { padding: 10px 12px; font-size: 12px; }

  /* ══ BADGES ════════════════════════════ */
  .badge { font-size: 10px; padding: 2px 6px; }

  /* ══ PAGINATION ════════════════════════ */
  .pagination { margin-top: 14px; gap: 3px; }
  .page-btn { width: 30px; height: 30px; font-size: 12px; }

  /* ══ AUTH PAGES ═════════════════════════ */
  .auth-container { align-items: flex-start; background: var(--bg-white); padding: 0; }
  .auth-card {
    padding: 32px 20px 24px;
    border: none;
    border-radius: 0;
    min-height: 100vh;
    max-width: 100%;
  }
  .auth-logo { margin-bottom: 24px; }
  .auth-logo h1 { font-size: 20px; }

  /* ══ PROFILE ════════════════════════════ */
  .profile-grid,
  [style*="grid-template-columns:1fr 1fr"][class*="profile"],
  div[style*="grid-template-columns:1fr 1fr"]:has(.card-header h3) {
    grid-template-columns: 1fr !important;
  }

  /* ══ MISC ════════════════════════════════ */
  code { font-size: 11px; }
  .tabs { margin-bottom: 12px; }
}

/* ══════════════════════════════════════════
   SMALL PHONES  ≤ 400px
   ══════════════════════════════════════════ */
@media (max-width: 400px) {
  :root { --header-h: 50px; --bottom-nav-h: 58px; }

  body { padding-bottom: var(--bottom-nav-h); }
  .page-content { padding: 8px; }
  .card-header  { padding: 10px; }
  .card-body    { padding: 10px; }

  .stats-grid { gap: 6px; }
  .stat-card  { padding: 10px 8px; gap: 6px; }
  .stat-value { font-size: 18px; }
  .stat-icon  { width: 30px; height: 30px; font-size: 13px; }

  .mob-nav-item span { font-size: 8px; letter-spacing: 0; }
  .mob-nav-item i    { font-size: 18px; }

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

  table { min-width: 420px; }
  th, td { padding: 7px 8px; }

  .patient-header { padding: 10px; gap: 8px; }
  .patient-avatar { width: 40px; height: 40px; font-size: 15px; }

  .fab-add {
    width: 46px;
    height: 46px;
    font-size: 18px;
    bottom: calc(var(--bottom-nav-h) + 12px);
  }

  .modal-body { padding: 12px; }
  .modal-header { padding: 12px; }
}

/* ══════════════════════════════════════════
   EXTRA SMALL  ≤ 320px
   ══════════════════════════════════════════ */
@media (max-width: 320px) {
  .mob-nav-item span { display: none; }
  .mob-nav-item i    { font-size: 20px; }
  .mobile-bottom-nav { height: 52px; }
  body { padding-bottom: 52px; }
  .stats-grid { grid-template-columns: repeat(2,1fr); gap: 5px; }
  .stat-value { font-size: 16px; }
}

/* ─── PROFILE PAGE ──────────────────────── */
.profile-page-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

.profile-main-card {}

@media (max-width: 900px) {
  .profile-page-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── SUPERVISOR PERMISSIONS GRID ────────── */
@media (max-width: 480px) {
  .profile-page-grid { grid-template-columns: 1fr; gap: 12px; }
}

/* ─── ACTIVITY FEED ─────────────────────── */
.activity-feed-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.activity-icon {
  width: 28px;
  height: 28px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
}

/* ─── TOAST NOTIFICATION ───────────────────── */
@keyframes slideInToast {
  from { opacity:0; transform: translateY(20px); }
  to   { opacity:1; transform: translateY(0); }
}

/* ─── AUTH BACKGROUND (Mobile override) ────── */
@media (max-width:480px) {
  .auth-container::before,
  .auth-container::after { display:none; }
}
