﻿/*
  IMEDI.HEALTH — Shared Design System Stylesheet
  Imported by all pages via <link rel="stylesheet" href="/static/css/shared.css">
*/
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600;700&display=swap');

/* ══════════════════════════════════════════
   TOKENS
══════════════════════════════════════════ */
:root {
  --primary:      #2D6A4F;
  --primary-lt:   #40916C;
  --primary-pale: #E8F5EE;
  --bg:           #F7F5F0;
  --card:         #FFFFFF;
  --border:       #E8E4DC;
  --text:         #1A1A1A;
  --muted:        #6B7280;
  --muted-lt:     #9CA3AF;
  --danger:       #DC2626;
  --danger-pale:  #FEE2E2;
  --amber:        #92400E;
  --amber-pale:   #FEF3C7;
  --sidebar-w:    220px;
  --radius:       10px;
  --shadow:       0 1px 4px rgba(0,0,0,0.06);
}

/* ══════════════════════════════════════════
   BASE
══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0;
  height: 100vh; z-index: 200;
  transition: transform 0.25s;
}
.sidebar-logo { padding: 18px 20px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; cursor: pointer; text-decoration: none; }
.sidebar-logo img { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.sidebar-logo h1 { font-family: 'Poppins', sans-serif; font-weight: 700; color: var(--text); font-size: 1.1rem; line-height: 1; letter-spacing: 0; }
.nav { list-style: none; padding: 12px 0; flex: 1; overflow-y: auto; min-height: 0; }
.nav li a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: var(--muted);
  font-size: 0.86rem; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.nav li a:hover  { background: #F5F9F7; color: var(--primary); }
.nav li a.active { background: var(--primary-pale); color: var(--primary); font-weight: 600; border-left-color: var(--primary); }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; display: block; color: inherit; }
.nav-section { padding: 14px 20px 4px; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-lt); }

.sidebar-powered {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  padding: 11px 16px 13px;
  border-top: 1px solid var(--border);
  text-align: center;
  background: var(--card);
  z-index: 1;
}
.sidebar-powered small {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--muted-lt);
  margin-bottom: 3px;
}
.sidebar-powered strong {
  font-size: 0.73rem;
  font-weight: 700;
  color: #8A8278;
  letter-spacing: 0.015em;
}

/* ══════════════════════════════════════════
   MAIN
══════════════════════════════════════════ */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 15px 28px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 100;
}
.topbar-left h2 { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.2px; }
.topbar-left .breadcrumb { font-size: 0.75rem; color: var(--muted); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.content { padding: 24px 28px; flex: 1; }

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 7px;
  font-size: 0.84rem; font-weight: 600;
  border: none; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-lt); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger-pale); color: var(--danger); border: none; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 11px; font-size: 0.78rem; }

/* ══════════════════════════════════════════
   CARD
══════════════════════════════════════════ */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ══════════════════════════════════════════
   TABLE
══════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
thead th {
  text-align: left; padding: 11px 16px;
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); background: #FAFAF8;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #F3F0EA; transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FAFAF8; }
tbody td { padding: 12px 16px; vertical-align: middle; }

/* ══════════════════════════════════════════
   BADGES
══════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 0.73rem; font-weight: 600; white-space: nowrap;
}
.badge-green  { background: #D1FAE5; color: #065F46; }
.badge-gray   { background: #F3F4F6; color: #6B7280; }
.badge-amber  { background: var(--amber-pale); color: var(--amber); }
.badge-blue   { background: #DBEAFE; color: #1E40AF; }
.badge-teal   { background: #CCFBF1; color: #0F766E; }
.badge-red    { background: var(--danger-pale); color: var(--danger); }

/* ══════════════════════════════════════════
   TOOLBAR
══════════════════════════════════════════ */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.search-wrap .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted-lt); width: 16px; height: 16px; }
.search-input { width: 100%; padding: 8px 10px 8px 32px; border: 1px solid var(--border); border-radius: 7px; font-size: 0.85rem; background: var(--card); color: var(--text); outline: none; transition: border-color 0.15s; }
.search-input:focus { border-color: var(--primary); }
.filter-select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 0.85rem; background: var(--card); color: var(--text); outline: none; cursor: pointer; }
.filter-select:focus { border-color: var(--primary); }

/* ══════════════════════════════════════════
   FORM
══════════════════════════════════════════ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-full  { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 0.78rem; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: 0.04em; }
.field label span.req { color: var(--danger); margin-left: 2px; }
.field input, .field select, .field textarea {
  padding: 8px 11px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 0.86rem; color: var(--text); background: #FAFAF8; outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); background: #fff; }
.field textarea { resize: vertical; min-height: 72px; }
.field .hint { font-size: 0.75rem; color: var(--muted); }
.form-section-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* Toggle switch */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: #FAFAF8; border: 1px solid var(--border); border-radius: 7px; }
.toggle-row .toggle-label { font-size: 0.86rem; font-weight: 500; }
.toggle-row .toggle-sub { font-size: 0.75rem; color: var(--muted); margin-top: 1px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { display: none; }
.slider { position: absolute; inset: 0; background: #D1D5DB; border-radius: 22px; cursor: pointer; transition: background 0.2s; }
.slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ══════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════ */
.empty-state { padding: 56px 24px; text-align: center; color: var(--muted); }
.empty-state .empty-icon { font-size: 2.4rem; margin-bottom: 12px; }
.empty-state h4 { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: 0.83rem; }
.table-footer { padding: 10px 16px; border-top: 1px solid var(--border); font-size: 0.78rem; color: var(--muted); }

/* ══════════════════════════════════════════
   ACTION BUTTONS
══════════════════════════════════════════ */
.action-btns { display: flex; gap: 6px; }
.icon-btn { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 5px 9px; font-size: 0.8rem; color: var(--muted); cursor: pointer; transition: all 0.15s; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.edit:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-pale); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-pale); }

/* ══════════════════════════════════════════
   TOAST
══════════════════════════════════════════ */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 8px; font-size: 0.86rem; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,0.14); animation: slideUp 0.28s ease-out; pointer-events: auto; max-width: 340px; }
.toast-success { background: #065F46; color: #fff; }
.toast-error   { background: var(--danger); color: #fff; }
.toast-info    { background: #1E40AF; color: #fff; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ══════════════════════════════════════════
   DIALOG
══════════════════════════════════════════ */
.dialog-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 500; align-items: center; justify-content: center; }
.dialog-overlay.open { display: flex; }
.dialog { background: var(--card); border-radius: var(--radius); padding: 28px 28px 22px; width: 360px; box-shadow: 0 8px 32px rgba(0,0,0,0.18); }
.dialog h4 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.dialog p  { font-size: 0.86rem; color: var(--muted); margin-bottom: 22px; line-height: 1.5; }
.dialog-btns { display: flex; gap: 10px; justify-content: flex-end; }

/* ══════════════════════════════════════════
   ROLE-GATED VISIBILITY
   Hidden by default → no flash while auth resolves.
   applyRoleUI() adds body.role-* to reveal the right items.
══════════════════════════════════════════ */
/* Hidden by default — sidebar/UI gating only (NOT settings-section divs) */
body .dev-nav-section,
body .admin-nav-section,
body [data-role="developer"] { display: none !important; }

/* Developer sees everything */
body.role-developer .dev-nav-section,
body.role-developer .admin-nav-section      { display: block !important; }
body.role-developer [data-role="developer"] { display: block !important; }
/* settings-nav-item is a flex element — restore correctly */
body.role-developer .settings-nav-item[data-role="developer"] { display: flex !important; }

/* Admin sees User Management only */
body.role-admin .admin-nav-section { display: block !important; }

/* ══════════════════════════════════════════
   WHATSAPP FEATURE FLAG
   When developer disables WhatsApp, body.wa-disabled
   hides every element marked with [data-wa].
══════════════════════════════════════════ */
body.wa-disabled [data-wa] { display: none !important; }

/* ══════════════════════════════════════════
   AUTOCOMPLETE (name search)
══════════════════════════════════════════ */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 7px; box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  z-index: 400; max-height: 240px; overflow-y: auto;
}
.autocomplete-item {
  padding: 10px 14px; cursor: pointer; font-size: 0.85rem;
  border-bottom: 1px solid #F3F0EA; transition: background 0.1s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--primary-pale); }
.autocomplete-name { font-weight: 600; color: var(--text); }
.autocomplete-sub  { font-size: 0.74rem; color: var(--muted); margin-top: 2px; }
.autocomplete-empty { padding: 12px 14px; color: var(--muted); font-size: 0.82rem; text-align: center; }
.autocomplete-selected-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary-pale); color: var(--primary);
  border: 1px solid #b7dfc8; border-radius: 5px;
  padding: 3px 10px 3px 10px; font-size: 0.8rem; font-weight: 600;
  margin-top: 5px;
}
.autocomplete-selected-tag button {
  background: none; border: none; color: var(--primary);
  font-size: 0.9rem; line-height: 1; cursor: pointer; padding: 0;
}

/* ══════════════════════════════════════════
   PHONE VISIBILITY FEATURE FLAG
══════════════════════════════════════════ */
body.phone-hidden .ph-num {
  color: transparent !important;
  position: relative;
  pointer-events: none;
  user-select: none;
}
body.phone-hidden .ph-num::after {
  content: "••••••••••";
  position: absolute;
  left: 0;
  color: var(--muted-lt);
  letter-spacing: 0.12em;
}

/* Payments disabled — hides nav link; redirect handled in JS */
body.payments-hidden [data-payments] { display: none !important; }

/* ══════════════════════════════════════════
   PATIENT TABS
══════════════════════════════════════════ */
.pt-tab {
  background: none; border: none; border-bottom: 3px solid transparent;
  padding: 8px 16px; font-size: 0.88rem; font-weight: 500;
  color: var(--muted); cursor: pointer; display: inline-flex; align-items: center;
  gap: 6px; margin-bottom: -2px; transition: color 0.15s, border-color 0.15s;
}
.pt-tab:hover { color: var(--text); }
.pt-tab-active { color: var(--primary) !important; border-bottom-color: var(--primary) !important; font-weight: 600; }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
}
