/* ============================================================
   Med Rep Pro — main.css
   Design: PharmaLink-inspired green glassmorphism
   ============================================================ */

:root {
  /* Brand palette */
  --green-dark:   #032221;
  --green-mid:    #03624C;
  --green-bright: #2CC295;
  --cyan:         #00DBF1;
  --white-soft:   #F1F7F6;
  --muted:        #AACBC4;
  --pine:         #08453A;
  --forest:       #095544;
  --frog:         #17876D;
  --mint:         #2FA98C;
  --amber:        #ffba40;
  --coral:        #ff6b6b;
  --indigo:       #6c7fe8;

  /* Semantic */
  --bg:           #021a14;
  --surface:      rgba(3,34,33,0.85);
  --card:         rgba(3,98,76,0.18);
  --card-border:  rgba(44,194,149,0.18);
  --card-hover:   rgba(44,194,149,0.08);
  --text-1:       #F1F7F6;
  --text-2:       #AACBC4;
  --text-3:       #5a8a7a;
  --accent:       #2CC295;
  --accent2:      #00DBF1;
  --glow:         rgba(44,194,149,0.25);

  --border:       rgba(44,194,149,0.15);
  --border-acc:   rgba(44,194,149,0.4);
  --bg-glass:     rgba(3,34,33,0.6);
  --teal:         #2CC295;
  --teal-glow:    rgba(44,194,149,0.15);
  --sage:         #2CC295;
  --teal-dim:     #1fa37a;

  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', 'Cairo', sans-serif;

  --sidebar-w:    260px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px;
}

/* ══ LIGHT THEME ════════════════════════════════════════════════════════════ */
.theme-light {
  --bg:           #f0f7f5;
  --surface:      rgba(255,255,255,0.95);
  --card:         rgba(255,255,255,0.9);
  --card-border:  rgba(3,98,76,0.2);
  --card-hover:   rgba(3,98,76,0.06);
  --text-1:       #0a2e24;
  --text-2:       #2d6e5a;
  --text-3:       #6aaa90;
  --bg-glass:     rgba(255,255,255,0.8);
  --glow:         rgba(44,194,149,0.15);
}

.theme-light body,
.theme-light html,
.theme-light #root {
  background: var(--bg);
  color: var(--text-1);
}

.theme-light .bg-orbs {
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(44,194,149,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 70%, rgba(0,219,241,0.05) 0%, transparent 55%),
    linear-gradient(160deg, #e8f5f0 0%, #f0f7f5 100%);
}

.theme-light .sidebar {
  background: rgba(240,247,245,0.95);
  border-right-color: rgba(3,98,76,0.2);
}

.theme-light .mobile-header,
.theme-light .page-header {
  background: rgba(240,247,245,0.9);
  border-color: rgba(3,98,76,0.15);
}

.theme-light .bottom-nav {
  background: rgba(240,247,245,0.97);
  border-top-color: rgba(3,98,76,0.2);
}

.theme-light .card,
.theme-light .kpi-card {
  background: rgba(255,255,255,0.9);
  border-color: rgba(3,98,76,0.2);
}

.theme-light .form-control {
  background: rgba(255,255,255,0.9);
  border-color: rgba(3,98,76,0.25);
  color: var(--text-1);
}

.theme-light select.form-control option {
  background-color: #ffffff;
  color: #0a2e24;
}

.theme-light .modal {
  background: rgba(240,247,245,0.98);
}

.theme-light .gps-bar { background: rgba(255,255,255,0.9); }
.theme-light .tabs { background: rgba(3,98,76,0.1); }
.theme-light .tab-btn.active { background: var(--green-mid); color: white; }
.theme-light th { color: var(--text-2); }
.theme-light td { border-bottom-color: rgba(3,98,76,0.08); }
.theme-light .nav-item:hover { background: rgba(3,98,76,0.08); }

/* ══ RTL SUPPORT ═════════════════════════════════════════════════════════════ */
[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--card-border); }
[dir="rtl"] .nav-item.active::before { left: auto; right: 0; border-radius: 2px 0 0 2px; }
[dir="rtl"] .page-body { direction: rtl; }
[dir="rtl"] .card-header { flex-direction: row-reverse; }
[dir="rtl"] .kpi-card { text-align: right; }
[dir="rtl"] .modal-header { flex-direction: row-reverse; }
[dir="rtl"] .modal-footer { flex-direction: row-reverse; }
[dir="rtl"] .form-label { text-align: right; }
[dir="rtl"] .sidebar-logo h1 { flex-direction: row-reverse; }
[dir="rtl"] select.form-control {
  background-position: left 12px center;
  padding-left: 36px;
  padding-right: 13px;
}

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

html, body, #root {
  height: 100%;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Prevent iOS rubber-band scroll on body while allowing content scroll */
body {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--teal-dim); }

/* ── Animated background ── */
.bg-orbs {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(44,194,149,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 70%, rgba(0,219,241,0.07) 0%, transparent 55%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(3,98,76,0.12) 0%, transparent 70%),
    linear-gradient(160deg, #032221 0%, #021a14 50%, #010d0a 100%);
}

/* ── App layout ── */
.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height — fixes iOS address bar issue */
  position: relative;
  z-index: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: rgba(2,26,20,0.8);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--card-border);
  display: flex; flex-direction: column;
  flex-shrink: 0; overflow-y: auto;
  position: relative; z-index: 10;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--card-border);
}

.sidebar-logo h1 {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 700;
  color: var(--accent); letter-spacing: -0.3px;
  display: flex; align-items: center; gap: 8px;
}

.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--green-mid), var(--green-bright));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  box-shadow: 0 0 14px var(--glow);
  flex-shrink: 0;
}

.sidebar-logo span { color: var(--text-2); font-size: 11px; margin-top: 2px; display: block; }

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

.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--frog), var(--mint));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: white; flex-shrink: 0;
}

.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.sidebar-user-role { font-size: 11px; color: var(--text-2); text-transform: capitalize; }

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.sidebar-section-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-3);
  padding: 14px 10px 5px;
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer; border: none; background: none;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  font-family: var(--font-body);
  transition: all 0.18s ease; text-align: left; width: 100%;
  position: relative;
}

.nav-item:hover { background: var(--card); color: var(--text-1); }

.nav-item.active {
  background: linear-gradient(135deg, rgba(44,194,149,0.18), rgba(0,219,241,0.08));
  color: var(--accent);
  border: 1px solid rgba(44,194,149,0.22);
}

.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--accent); border-radius: 0 2px 2px 0;
}

.nav-icon { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--accent); color: var(--green-dark);
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--card-border);
}

.btn-logout {
  width: 100%; padding: 10px 14px;
  background: rgba(255,107,107,0.1); border: 1px solid rgba(255,107,107,0.2);
  color: var(--coral); border-radius: var(--r-md);
  cursor: pointer; font-size: 13px; font-family: var(--font-body);
  font-weight: 600; transition: all 0.2s;
}

.btn-logout:hover { background: rgba(255,107,107,0.18); }

/* ── Mobile sidebar ── */
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 9; backdrop-filter: blur(4px);
}

.sidebar-close-btn { display: none !important; }

/* ── Main content ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  /* On mobile: allow the container to participate in scroll */
  -webkit-overflow-scrolling: touch;
}

/* ── Mobile header ── */
.mobile-header {
  display: none;
  align-items: center; gap: 12px;
  padding: 14px 16px;
  background: rgba(2,26,20,0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
  position: sticky; top: 0; z-index: 8;
}

.hamburger {
  background: none; border: none; color: var(--text-1);
  font-size: 20px; cursor: pointer; padding: 4px; line-height: 1;
}

.mobile-header-logo {
  font-family: var(--font-display); font-size: 16px;
  font-weight: 700; color: var(--accent);
}

.mobile-header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ── Page scaffold ── */
.page-header {
  padding: 28px 32px 0;
  background: rgba(2,26,20,0.5);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 20px;
}

.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-title {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 800; line-height: 1.15;
  background: linear-gradient(90deg, var(--text-1) 60%, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.page-subtitle { color: var(--text-2); font-size: 13px; margin-top: 3px; }

.page-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* iOS momentum scrolling */
  overscroll-behavior-y: contain;    /* stop scroll chaining */
  padding: 24px 32px;
  display: flex; flex-direction: column; gap: 20px;
}

/* ── KPI grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi-card {
  background: rgba(3,34,33,0.72);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  padding: 22px 20px;
  position: relative; overflow: hidden;
  transition: all 0.28s ease;
  animation: fadeUp 0.5s ease both;
}

.kpi-card:hover {
  transform: translateY(-3px);
  border-color: rgba(44,194,149,0.4);
  box-shadow: 0 8px 32px rgba(44,194,149,0.1);
}

.kpi-card::after {
  content: ''; position: absolute; top: 0; right: 0;
  width: 80px; height: 80px; border-radius: 50%;
  filter: blur(28px); opacity: 0.35;
}

.kpi-card:nth-child(1)::after { background: var(--green-bright); }
.kpi-card:nth-child(2)::after { background: var(--cyan); }
.kpi-card:nth-child(3)::after { background: var(--frog); }
.kpi-card:nth-child(4)::after { background: var(--mint); }

.kpi-icon { font-size: 22px; margin-bottom: 10px; opacity: 0.85; }
.kpi-value {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 800; line-height: 1;
  margin-bottom: 6px;
}

.kpi-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.7px;
  text-transform: uppercase; color: var(--text-2);
}

.kpi-sub { font-size: 11px; color: var(--text-3); margin-top: 5px; }

/* ── Dash grid ── */
.dash-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}

/* ── Cards ── */
.card {
  background: rgba(3,34,33,0.72);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  animation: fadeUp 0.5s ease both;
}

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

.card-title {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 700; color: var(--text-1);
}

.card-body { padding: 18px 20px; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--text-2);
}

.form-control {
  background: rgba(3,98,76,0.15);
  border: 1px solid var(--card-border);
  border-radius: var(--r-sm);
  color: var(--text-1); font-family: var(--font-body); font-size: 13px;
  padding: 10px 13px; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  unicode-bidi: plaintext; /* auto-detect text direction — supports Arabic & RTL input */
}

.form-control:focus {
  border-color: rgba(44,194,149,0.5);
  box-shadow: 0 0 0 3px rgba(44,194,149,0.12);
}

textarea.form-control { resize: vertical; }

/* ── Select / dropdown — high-contrast option list ── */
select.form-control {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%232CC295' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Force option elements to have solid dark bg + bright text for contrast */
select.form-control option {
  background-color: #021a14;
  color: #F1F7F6;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  padding: 8px 12px;
}

select.form-control option:checked,
select.form-control option:hover {
  background-color: #03624C;
  color: #2CC295;
}

select.form-control option:disabled,
select.form-control option[value=""] {
  color: #5a8a7a;
}

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

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 600; font-family: var(--font-body);
  cursor: pointer; border: none; transition: all 0.2s; white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--green-mid), var(--green-bright));
  color: var(--green-dark);
  box-shadow: 0 4px 14px rgba(44,194,149,0.3);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(44,194,149,0.4); }

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

.btn-secondary:hover { background: rgba(44,194,149,0.12); border-color: rgba(44,194,149,0.3); }

.btn-ghost {
  background: none; color: var(--text-2); border: none;
}

.btn-ghost:hover { color: var(--text-1); background: var(--card); }

.btn-danger {
  background: rgba(255,107,107,0.15); border: 1px solid rgba(255,107,107,0.3);
  color: var(--coral);
}

.btn-danger:hover { background: rgba(255,107,107,0.25); }

.btn-warning {
  background: rgba(255,186,64,0.15); border: 1px solid rgba(255,186,64,0.3);
  color: var(--amber);
}

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ── Login ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; z-index: 1;
}

.login-card {
  background: rgba(3,34,33,0.85);
  backdrop-filter: blur(24px);
  border: 1px solid var(--card-border);
  border-radius: var(--r-xl);
  padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4), 0 0 0 1px rgba(44,194,149,0.08);
}

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

.login-logo-icon {
  width: 58px; height: 58px; border-radius: 16px;
  background: linear-gradient(135deg, var(--green-mid), var(--green-bright));
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; margin: 0 auto 14px;
  box-shadow: 0 0 32px rgba(44,194,149,0.3);
}

.login-logo h1 {
  font-family: var(--font-display); font-size: 22px; font-weight: 800;
  background: linear-gradient(90deg, var(--text-1), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.login-logo p { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.login-error {
  background: rgba(255,107,107,0.12); border: 1px solid rgba(255,107,107,0.3);
  color: var(--coral); border-radius: var(--r-sm);
  padding: 10px 14px; font-size: 13px; margin-bottom: 16px;
}

.login-btn {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--green-mid), var(--green-bright));
  color: var(--green-dark); font-weight: 700; font-size: 15px;
  border: none; border-radius: var(--r-md); cursor: pointer;
  font-family: var(--font-display); letter-spacing: 0.2px;
  transition: all 0.2s; margin-top: 6px;
  box-shadow: 0 4px 16px rgba(44,194,149,0.3);
}

.login-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(44,194,149,0.4); }
.login-btn:disabled { opacity: 0.5; transform: none; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}

.modal {
  background: rgba(3,34,33,0.95);
  backdrop-filter: blur(24px);
  border: 1px solid var(--card-border);
  border-radius: var(--r-xl);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  animation: fadeUp 0.2s ease;
}

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

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

.modal-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-2);
  font-size: 20px; cursor: pointer; padding: 2px; line-height: 1;
}

.modal-close:hover { color: var(--text-1); }

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

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%; border-collapse: collapse;
}

th {
  text-align: left; padding: 10px 16px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-2);
  border-bottom: 1px solid var(--card-border);
}

td {
  padding: 12px 16px; font-size: 13px;
  border-bottom: 1px solid rgba(44,194,149,0.06);
  vertical-align: middle;
}

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

tr:hover td { background: rgba(44,194,149,0.04); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  text-transform: capitalize;
}

.badge-teal    { background: rgba(44,194,149,0.15); color: var(--accent); }
.badge-cyan    { background: rgba(0,219,241,0.12); color: var(--cyan); }
.badge-amber   { background: rgba(255,186,64,0.12); color: var(--amber); }
.badge-coral   { background: rgba(255,107,107,0.12); color: var(--coral); }
.badge-indigo  { background: rgba(108,127,232,0.12); color: var(--indigo); }
.badge-purple  { background: rgba(155,89,182,0.15); color: #b57edc; }
.badge-muted   { background: rgba(255,255,255,0.07); color: var(--text-2); }
.badge-sage    { background: rgba(44,194,149,0.15); color: var(--accent); }

/* ── GPS bars ── */
.gps-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 13px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600;
  background: var(--card); border: 1px solid var(--card-border);
  margin-bottom: 4px;
}

.gps-ok  { border-color: rgba(44,194,149,0.35); color: var(--accent); }
.gps-err { border-color: rgba(255,107,107,0.3); color: var(--coral); }

/* ── Location Capture UI ── */
.location-capture {
  padding: 12px;
  border-radius: var(--r-sm);
  border: 2px solid rgba(44,194,149,0.3);
  background: rgba(44,194,149,0.05);
}
.location-capture.gps-pending {
  border-color: rgba(255,193,7,0.3);
  background: rgba(255,193,7,0.05);
}
.location-capture.gps-waiting {
  border-color: rgba(255,107,107,0.3);
  background: rgba(255,107,107,0.05);
}
.location-capture.gps-ready {
  border-color: rgba(44,194,149,0.35);
  background: rgba(44,194,149,0.08);
}
.gps-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-1);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-weight: 500;
}
.gps-icon {
  font-size: 16px;
  min-width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.geofence-bar {
  padding: 8px 13px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600; margin-top: 4px;
}

.inside  { background: rgba(44,194,149,0.1); color: var(--accent); border: 1px solid rgba(44,194,149,0.3); }
.outside { background: rgba(255,107,107,0.1); color: var(--coral); border: 1px solid rgba(255,107,107,0.3); }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; background: rgba(0,0,0,0.3); border-radius: 9px; padding: 3px; width: fit-content; }
.tab-btn {
  padding: 6px 16px; border-radius: 7px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  border: none; background: none; color: var(--text-2);
  font-family: var(--font-body); transition: all 0.2s;
}

.tab-btn.active { background: var(--green-mid); color: var(--accent); }
.tab-btn:hover:not(.active) { color: var(--text-1); }

/* ── Progress bars ── */
.progress-bar {
  height: 4px; border-radius: 2px;
  background: rgba(44,194,149,0.12); overflow: hidden;
}

.progress-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--green-mid), var(--green-bright));
  transition: width 0.8s ease;
}

/* ── Notices ── */
.notice {
  padding: 11px 14px; border-radius: var(--r-sm);
  font-size: 13px; border: 1px solid;
}

.notice-ok   { background: rgba(44,194,149,0.1); border-color: rgba(44,194,149,0.3); color: var(--accent); }
.notice-info { background: rgba(0,219,241,0.08); border-color: rgba(0,219,241,0.25); color: var(--cyan); }
.notice-warn { background: rgba(255,186,64,0.1); border-color: rgba(255,186,64,0.3); color: var(--amber); }
.notice-err  { background: rgba(255,107,107,0.1); border-color: rgba(255,107,107,0.3); color: var(--coral); }

/* ── Spinner / loader ── */
.spinner { display: flex; align-items: center; justify-content: center; padding: 32px; }

.spinner-ring {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(44,194,149,0.15);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

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

.page-loader { flex: 1; display: flex; align-items: center; justify-content: center; }
.api-error { padding: 16px; color: var(--coral); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.api-error-icon { font-size: 18px; }

/* ── Notification FAB (floating bell) ── */
.notif-fab {
  position: fixed; top: 18px; right: 20px; z-index: 1200;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: transform 0.15s, box-shadow 0.15s;
}
.notif-fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.notif-fab-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--coral, #e74c3c); color: #fff;
  font-size: 9px; font-weight: 700; min-width: 16px; height: 16px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  padding: 0 3px; border: 2px solid var(--surface);
}
/* On desktop push the FAB left of the scrollbar, inside main content */
@media (min-width: 769px) {
  .notif-fab { top: 20px; right: 28px; }
}

/* ── Toast ── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}

.toast {
  padding: 12px 18px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 600;
  backdrop-filter: blur(12px);
  animation: fadeUp 0.3s ease;
  max-width: 320px;
}

.toast-success { background: rgba(44,194,149,0.2); border: 1px solid rgba(44,194,149,0.4); color: var(--accent); }
.toast-error   { background: rgba(255,107,107,0.2); border: 1px solid rgba(255,107,107,0.4); color: var(--coral); }
.toast-info    { background: rgba(0,219,241,0.15); border: 1px solid rgba(0,219,241,0.3); color: var(--cyan); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-2); }
.empty-icon { font-size: 40px; margin-bottom: 12px; }

/* ── Search bar ── */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--r-md); padding: 9px 13px;
}

.search-bar input {
  background: none; border: none; outline: none;
  color: var(--text-1); font-family: var(--font-body); font-size: 13px;
  flex: 1;
}

.search-bar input::placeholder { color: var(--text-3); }

/* ── Utility ── */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; }
.gap-4  { gap: 4px; }
.gap-8  { gap: 8px; }
.gap-16 { gap: 16px; }
.mb-16  { margin-bottom: 16px; }
.mt-4   { margin-top: 4px; }
.text-2 { color: var(--text-2); }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-2); }
.font-bold { font-weight: 700; }
.col-2 { grid-column: 1 / -1; }

/* ── Status badge ── */
.status-badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}

/* ── Bottom nav (mobile) ── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(2,26,20,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--card-border);
  z-index: 20;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  touch-action: none;
  /* Scroll-hide animation */
  transform: translateY(0);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.bottom-nav.bnav-hidden {
  transform: translateY(110%);
}

.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  flex: 1; background: none; border: none; color: var(--text-3);
  font-size: 10px; font-weight: 600; cursor: pointer; padding: 6px 4px;
  font-family: var(--font-body); transition: color 0.15s; position: relative;
}

.bottom-nav-item.active { color: var(--accent); }
.bnav-icon { font-size: 20px; }
.bnav-badge {
  position: absolute; top: 2px; right: 50%; transform: translateX(14px);
  background: var(--accent); color: var(--green-dark);
  font-size: 9px; font-weight: 700; min-width: 14px; height: 14px;
  border-radius: 7px; display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

/* ── Sidebar overlay mode (mobile) ── */
.sidebar-overlay-mode .sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  transform: translateX(-100%);
  z-index: 40;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.sidebar-overlay-mode .sidebar.open { transform: translateX(0); }
.sidebar-overlay-mode .sidebar-backdrop.visible { display: block; }
.sidebar-overlay-mode .sidebar-close-btn { display: block !important; }

/* ── Visit history colours ── */
.visit-row-doctor   { border-left: 4px solid var(--indigo); background: rgba(108,127,232,0.06); }
.visit-row-pharmacy { border-left: 4px solid var(--accent); background: rgba(44,194,149,0.05); }

/* ── Choice chips ── */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 13px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--card-border);
  background: var(--card); color: var(--text-2);
  font-size: 12.5px; font-weight: 600; font-family: var(--font-body);
  transition: all 0.15s; user-select: none;
}

.chip.selected {
  border-color: rgba(44,194,149,0.45);
  background: rgba(44,194,149,0.15);
  color: var(--accent);
}

/* ── Plan day card ── */
.plan-day-card { min-height: 100px; }

/* ── Notif ── */
.notif-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--card-border);
}

.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: rgba(44,194,149,0.04); }
.notif-body { flex: 1; }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-msg   { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.notif-time  { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.notif-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive breakpoints ── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .app-layout { flex-direction: column; }
  /* On mobile, main-content must be scrollable — not overflow: hidden */
  .main-content { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .page-header { padding: 20px 16px 16px; }
  .page-body { padding: 16px; }
  .mobile-header { display: flex; }
  .bottom-nav { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .dash-grid { grid-template-columns: 1fr; gap: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  /* Clear fixed bottom nav — use padding + safe area */
  .main-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
  .sidebar-overlay-mode .main-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
  .page-title { font-size: 18px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 22px; }
  .modal { max-width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .modal-overlay { align-items: flex-end; }
  .login-card { padding: 28px 20px; }
  .toast-container { left: 12px; right: 12px; bottom: 80px; }
}

/* ══════════════════════════════════════════════════════
   MOBILE SCROLL — ADDITIONAL BEST PRACTICES
   ══════════════════════════════════════════════════════ */

/* Prevent double-tap zoom on interactive elements */
button, .btn, .nav-item, .chip, .bottom-nav-item,
.kpi-card, .card, a {
  touch-action: manipulation;
}

/* Table horizontal scroll on mobile */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Prevent table from breaking mobile layout */
  max-width: 100%;
}

/* Modal scroll on mobile — contain scroll within modal */
.modal {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Modal body scroll */
.modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 60vh;
}

/* Sidebar scroll on mobile overlay */
.sidebar {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Prevent the page-body from overflowing horizontally on mobile */
.page-body > * {
  min-width: 0;
  max-width: 100%;
}

/* Fix for iOS where position:fixed bottom nav can be covered by keyboard */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}

/* ── DROPDOWN OPTION CONTRAST — force solid bg in all browsers ── */
/* Webkit/Blink force-style for option dropdowns */
@media screen {
  select option {
    background: #021a14 !important;
    color: #F1F7F6 !important;
  }
  select option:checked {
    background: #03624C !important;
    color: #2CC295 !important;
  }
}
