/* ═══════════════════════════════════════════════════════════════
   North Peak Care Portal — Shared Stylesheet
   Brand identity & chrome styles used on every page.
   Page-specific layout (sidebar width, main area, cards) lives
   in each file's own <style> tag.
   ═══════════════════════════════════════════════════════════════ */

/* ── Brand colors (change once, updates everywhere) ── */
:root {
  --npc-blue:      #1C75BC;
  --npc-navy:      #262262;
  --npc-deep-blue: #2B3990;
  --npc-teal:      #0097B2;
  --npc-cyan:      #27AAE1;
  --npc-charcoal:  #231F20;

  --tint-blue:  #EAF4FB;
  --tint-teal:  #E8F9FB;
  --tint-cyan:  #EDF8FF;

  --npc-orange:      #E8922F;
  --npc-orange-hover:#d67d1a;

  --border-soft: #E3E7ED;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--npc-charcoal);
  visibility: hidden;   /* auth.js reveals body after auth check */
}

/* ── Header bar ── */
.top-bar {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-soft);
  background: #ffffff;
  z-index: 100;
  height: 64px;
}

/* Brand logo link */
.brand { display: flex; align-items: center; height: 100%; }
.brand a,
.brand-link {
  display: inline-flex;
  align-items: center;
  height: 100%;
  text-decoration: none;
  line-height: 0;
}
.brand-logo { height: 44px; width: auto; display: block; }

/* ── Top-right action cluster ── */
.top-actions { display: flex; align-items: center; gap: 16px; }

/* Role pill */
.pill {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  font-size: 12px;
  line-height: 1;
  color: #6C7280;
  background: #fff;
  white-space: nowrap;
  text-decoration: none;
}
.pill--admin {
  background: rgba(28, 117, 188, 0.07);
  border-color: rgba(28, 117, 188, 0.3);
  color: var(--npc-blue);
  font-weight: 600;
}
.pill--role-link { cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.pill--role-link:hover {
  background: rgba(28, 117, 188, 0.08);
  border-color: rgba(28, 117, 188, 0.35);
  color: var(--npc-blue);
}

/* Sign-out button */
.btn-signout {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border: 1px solid var(--border-soft);
  background: #fff;
  color: #4B5263;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
  user-select: none;
}
.btn-signout:hover {
  background: rgba(28, 117, 188, 0.06);
  border-color: rgba(28, 117, 188, 0.35);
  color: var(--npc-blue);
}
.btn-signout:active { transform: translateY(0.5px); }

/* Avatar circle */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--npc-blue), var(--npc-teal));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Sidebar unread badge ── */
.nav-badge {
  margin-left: auto;
  background: #EF4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  line-height: 1.4;
}

/* ── Toast notification ── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(14px);
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: white;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 400;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Primary button (used across pages) ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--npc-blue);
  color: white;
  border: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { background: #1560a0; }

/* ── More sheet / overlay: only used on mobile ── */
#moreSheet, #moreOverlay { display: none; }

/* ═══════════════════════════════════════════════════════════════
   App Shell Layout
   Grid shell, sidebar, nav items, main area, page header.
   Previously duplicated in every page's inline <style>.
   MUST come BEFORE responsive breakpoints so media queries can override.
   ═══════════════════════════════════════════════════════════════ */

/* ── App Shell grid ── */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas: "header header" "sidebar main";
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background-color: var(--bg-page, #FFFFFF);
}

/* ── Sidebar ── */
.sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--border-soft);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background-color: var(--bg-page, #FFFFFF);
}

.sidebar-section-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6B7280;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  border-radius: 999px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #4B5263;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
}
.nav-item:visited { color: #4B5263; }
.nav-item:hover   { background-color: rgba(28, 117, 188, 0.06); }

.nav-item-icon {
  width: 18px;
  height: 18px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #9AA1B2;
}

.nav-item.active {
  background-color: rgba(28, 117, 188, 0.08);
  color: var(--npc-blue);
  font-weight: 600;
}
.nav-item.active .nav-item-icon {
  border-color: var(--npc-blue);
  color: var(--npc-blue);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 12px;
  color: #9AA1B2;
}

/* ── Main content area ── */
.main {
  grid-area: main;
  padding: 20px 28px 40px;
  overflow-y: auto;
  background-color: var(--bg-page, #FFFFFF);
}

/* ── Page header row ── */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.main-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-title,
.main-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--npc-navy);
}

.subtitle,
.main-subtitle {
  font-size: 13px;
  color: #6C7280;
}

/* ── Date / time display ── */
.datetime-block {
  text-align: right;
  font-size: 12px;
  color: #6C7280;
  line-height: 1.4;
  margin-top: 2px;
}
.datetime-date {
  font-weight: 600;
  color: var(--npc-navy);
  font-size: 13px;
}
.datetime-time {
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════
   Responsive — Nurse portal (phone + iPad + laptop)
   Breakpoints:
     960px  tablet landscape  — sidebar collapses to icon-only rail
     720px  tablet portrait   — sidebar moves to bottom icon nav
     480px  phone             — further compression
   ══════════════════════════════════════════════════════════════ */

/* ── Tablet landscape: icon-only sidebar rail ── */
@media (max-width: 960px) {
  .top-bar { padding: 0 16px; }
  .app-shell { grid-template-columns: 72px 1fr; }
  .sidebar { padding-inline: 8px; }
  .nav-item { justify-content: center; padding-inline: 8px; }
  .nav-item .nav-text { display: none; }
  .sidebar-section-label { display: none; }
  .sidebar-footer { display: none; }
}

/* ── Tablet portrait / large phone: bottom nav ── */
@media (max-width: 720px) {
  /* Shell */
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 1fr 62px;
    grid-template-areas: "header" "main" "sidebar";
    height: 100dvh;
    overflow: hidden;
  }

  /* Header */
  .top-bar { height: 56px; padding: 0 14px; }
  .brand-logo { height: 36px; }
  .pill { display: none; } /* hide role pill — saves space on small screens */
  .btn-signout { font-size: 11px; padding: 6px 10px; gap: 5px; }

  /* Bottom nav */
  .sidebar {
    grid-area: sidebar;
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    height: 62px;
    border-right: none;
    border-top: 1px solid var(--border-soft);
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0;
    background: #fff;
    z-index: 50;
  }
  .sidebar-section { width: 100%; }
  .sidebar-section-label { display: none; }
  .sidebar-footer { display: none; }
  .nav-list {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    gap: 0;
    padding: 0;
    margin: 0;
  }
  .nav-item {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    border-radius: 10px;
    min-width: 0;
    min-height: 48px;
    flex: 1;
    overflow: hidden;
  }
  .nav-item .nav-text {
    display: block !important;
    font-size: 8px;
    font-weight: 500;
    color: inherit;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
  }
  .nav-item-icon { font-size: 20px; line-height: 1; }
  .nav-badge { font-size: 9px; padding: 1px 5px; }

  /* Main content scrolls */
  .main {
    grid-area: main;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
  }
  .main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .datetime-block { text-align: left; }

  /* Toast clears bottom nav */
  .toast { bottom: 76px; }

  /* ── 5-tab nav: bigger tap targets ── */
  .nav-item {
    padding: 8px 4px;
    min-height: 54px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }
  .nav-item .nav-text {
    font-size: 11px;
    white-space: nowrap;
    font-weight: 500;
    color: inherit;
  }
  .nav-item-icon { font-size: 22px; }

  /* ── Sidebar-only items hidden on mobile ── */
  .sidebar-only { display: none !important; }

  /* ── More button visible on mobile only ── */
  .mobile-only { display: flex !important; }

  /* ── More sheet / overlay: re-enable on mobile ── */
  #moreSheet, #moreOverlay { display: block; }

  /* ── More overlay (dims screen) ── */
  .more-overlay {
    position: fixed;
    inset: 0;
    bottom: 62px;
    background: rgba(0, 0, 0, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    z-index: 299;
  }
  .more-overlay.open { opacity: 1; pointer-events: auto; }

  /* ── More bottom sheet ── */
  .more-sheet {
    position: fixed;
    left: 0; right: 0;
    bottom: 62px;
    transform: translateY(100%);
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -6px 32px rgba(12, 32, 60, 0.18);
    z-index: 300;
    padding: 0 0 8px;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .more-sheet.open { transform: translateY(0); }

  .more-handle {
    width: 36px; height: 4px;
    background: #D1D5DB; border-radius: 999px;
    margin: 10px auto 14px;
  }
  .more-items { padding: 0 8px 4px; }
  .more-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--npc-charcoal);
    font-size: 15px;
    font-weight: 500;
    transition: background 0.12s;
  }
  .more-row:active { background: rgba(28, 117, 188, 0.06); }
  .more-row.active { color: var(--npc-blue); }
  .more-row-icon { font-size: 22px; width: 30px; text-align: center; }
  .more-row-label { flex: 1; }
  .more-row-chev { color: #C4CAD4; font-size: 20px; }

  /* Visits sub-tab segmented control */
  .visits-sub-tabs {
    display: flex;
    background: #F0F2F5;
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 16px;
  }
  .visits-sub-tab {
    flex: 1;
    text-align: center;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    color: #6C7280;
    transition: all 0.15s;
  }
  .visits-sub-tab.active {
    background: #fff;
    color: var(--npc-blue);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.10);
  }
}

/* ── More button hidden on desktop ── */
.mobile-only { display: none; }

/* ── Visits sub-tabs (desktop version — slimmer) ── */
.visits-sub-tabs {
  display: flex;
  background: #F0F2F5;
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 20px;
  width: fit-content;
}
.visits-sub-tab {
  padding: 7px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: #6C7280;
  transition: all 0.15s;
}
.visits-sub-tab.active {
  background: #fff;
  color: var(--npc-blue);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ── Small phone ── */
@media (max-width: 480px) {
  .top-bar { padding: 0 12px; }
  .brand-logo { height: 32px; }
  .btn-signout span:not(.signout-icon) { display: none; } /* icon only */
  .main { padding: 12px; }
}

/* ── Status badges (visit pipeline) ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-dot { width: 6px; height: 6px; border-radius: 999px; flex-shrink: 0; }
.status--open             { background: rgba(239,68,68,0.10);   color: #EF4444; }
.status--assigned_pending { background: rgba(217,119,6,0.10);   color: #D97706; }
.status--accepted         { background: rgba(28,117,188,0.10);  color: #1C75BC; }
.status--in_progress      { background: rgba(0,151,178,0.10);   color: #0097B2; }
.status--chart_submitted  { background: rgba(124,58,237,0.10);  color: #7C3AED; }
.status--chart_reviewed   { background: rgba(124,58,237,0.10);  color: #7C3AED; }
.status--pending_payment  { background: rgba(108,114,128,0.10); color: #6C7280; }
.status--paid             { background: rgba(22,163,74,0.10);   color: #16A34A; }

/* ── Loading spinner ── */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-soft);
  border-top-color: var(--npc-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #6B7280;
  font-size: 14px;
}
.empty-state-icon {
  font-size: 32px;
  margin-bottom: 8px;
}
