/* ============================================================
   Pack Peak — shared design system
   Reconstructed from the Adobe XD "Packpeak Product" prototype
   ============================================================ */

:root {
  /* Brand / surface */
  --navy:        #0c1c3c;   /* sidebar + logo */
  --navy-2:      #12264d;   /* sidebar hover */
  --ink:         #0c2340;   /* headings, big numbers */
  --text:        #3a4a5f;   /* body text */
  --muted:       #8a97a8;   /* secondary / labels */
  --line:        #e6eaf0;   /* borders / dividers */
  --bg:          #f4f6fa;   /* app background */
  --card:        #ffffff;

  /* Actions */
  --blue:        #2f6bed;   /* primary button / links */
  --blue-dark:   #2457c9;
  --blue-soft:   #eaf1ff;

  /* Accent icons / status */
  --c-blue:      #2b8fd9;
  --c-red:       #f0544f;
  --c-purple:    #7a4e9f;
  --c-orange:    #ee7a52;
  --c-yellow:    #f2c044;
  --c-green:     #37b26b;

  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 8px 24px rgba(16, 33, 66, .06);
  --shadow-lg:   0 12px 40px rgba(16, 33, 66, .12);

  --sidebar-w:   248px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Poppins", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--navy);
  color: #cfd8e6;
  display: flex;
  flex-direction: column;
  padding: 26px 18px 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  /* on short windows the 12-item nav is taller than the viewport —
     scroll inside the sidebar instead of spilling past the navy background */
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 26px;
}
.brand .logo-mark {
  width: 30px; height: 34px; flex: 0 0 auto;
}
.brand .logo-text { line-height: 1; }
.brand .logo-text b {
  display: block; color: #fff; font-weight: 700;
  letter-spacing: 3px; font-size: 15px;
}
.brand .logo-text span {
  display: block; color: #7f8db0; font-size: 6.5px;
  letter-spacing: 2.5px; margin-top: 3px;
}

/* flex:1 stretches the nav so .logout's margin-top:auto pins it to the
   sidebar foot, matching the XD layout */
.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; flex: 1 1 auto; }
.nav a {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: #b8c4d8; font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; flex: 0 0 auto; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.active {
  background: #fff; color: var(--ink); font-weight: 600;
}
.nav a.active svg { color: var(--blue); }
.nav .spacer { flex: 1 1 auto; }
.nav .logout { margin-top: auto; color: #9fb0cc; }

/* ---------- Main column ---------- */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 22px 34px;
}
.topbar h1 { margin: 0; font-size: 26px; color: var(--ink); font-weight: 700; }
.topbar .tabs { display: flex; gap: 26px; }
.topbar .tabs a { color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.topbar .tabs a.active { color: var(--blue); border-bottom: 2px solid var(--blue); }
.topbar .user {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
}
.topbar .user img,
.topbar .user .avatar {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  background: linear-gradient(135deg, #6a8dd6, #2f6bed);
}
.topbar .user .name { font-weight: 600; color: var(--ink); font-size: 13px; }
.topbar .user .status { color: var(--c-green); font-size: 11px; }
.topbar .user .status::before {
  content: "•"; margin-right: 4px;
}

.content { padding: 0 34px 40px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; border-radius: var(--radius-sm);
  padding: 11px 20px; font-size: 14px; font-weight: 600;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn-block { width: 100%; justify-content: center; }

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

/* ---------- Breadcrumb ---------- */
.crumb { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; margin: 6px 0 14px; }
.crumb .sep { opacity: .5; }
.crumb .cur { color: var(--text); }

/* ---------- Form fields ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; }
.input, .select {
  width: 100%; padding: 12px 14px; font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); outline: none;
}
.input:focus { border-color: var(--blue); }
.input-error { border-color: var(--c-red); background: #fff6f6; }
.hint-error { color: var(--c-red); font-size: 11px; margin-top: 5px; }

/* ============================================================
   Sub-tab bar — Pickups / Returns module headers
   Active style follows the XD per page: light-blue on forms,
   navy-filled on report/calendar tabs.
   ============================================================ */
.subtabs { display: flex; }
.subtabs a {
  padding: 13px 24px; font-size: 13px; font-weight: 500;
  color: var(--muted); background: #f2f4f8;
}
.subtabs a.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.subtabs a.active-dark { background: var(--navy); color: #fff; font-weight: 600; }

/* ---------- Native controls ---------- */
input[type="checkbox"], input[type="radio"] { accent-color: var(--blue); width: 15px; height: 15px; }
.choice { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink); font-weight: 500; }

/* ---------- Signature pads ---------- */
.sig-card h3 { margin: 0 0 16px; font-size: 17px; color: var(--ink); }
.sig-pad {
  border: 1.5px dashed #cfd6e0; border-radius: 6px; min-height: 120px;
  position: relative; display: flex; align-items: center; justify-content: center;
}
.sig-pad .script { font-family: "Segoe Script", cursive; font-size: 26px; color: #2a3550; }
.sig-pad .clear {
  position: absolute; top: 8px; right: 8px; width: 20px; height: 20px;
  border: none; border-radius: 50%; background: var(--c-red); color: #fff;
  font-size: 11px; line-height: 1; display: flex; align-items: center; justify-content: center;
}

/* ---------- Modal (pure CSS via :target) ---------- */
.modal-ov {
  display: none; position: fixed; inset: 0; z-index: 50;
  background: rgba(18, 28, 50, .45);
}
.modal-ov:target { display: flex; align-items: flex-start; justify-content: center; padding-top: 14vh; }
.modal {
  background: #fff; border-radius: 10px; width: 420px; max-width: calc(100vw - 48px);
  padding: 20px 24px 24px; box-shadow: var(--shadow-lg); position: relative;
}
.modal h3 { margin: 0 0 14px; font-size: 16px; color: var(--ink); }
.modal p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.65; }
.modal .close {
  position: absolute; top: 16px; right: 18px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--c-red); color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}

/* ============================================================
   Month calendar — Pickup & Reminder calendar pages
   ============================================================ */
.mcal { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; min-width: 620px; }
.mcal-head { display: grid; grid-template-columns: repeat(7, 1fr); background: #f6f8fb; }
.mcal-head div { padding: 12px 10px; font-size: 12.5px; color: var(--text); }
.mcal-body { display: grid; grid-template-columns: repeat(7, 1fr); }
.mday { min-height: 76px; padding: 6px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.mday:nth-child(7n+1) { border-left: none; }
.mday .n { font-size: 12.5px; color: var(--ink); margin-bottom: 5px; }
.mday.out .n { color: var(--muted); }
.mchip {
  display: block; border-radius: 3px; border: 1px solid;
  font-size: 9.5px; font-weight: 600; padding: 2px 6px; margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mchip.blue   { background: #e7f0ff; color: #2f6bed; border-color: #bcd4ff; }
.mchip.yellow { background: #fff6dd; color: #c8971d; border-color: #f2dc9d; }
.mchip.red    { background: #ffe3e3; color: #e0403b; border-color: #ffb9b6; }

.cal-legend { display: flex; justify-content: center; gap: 20px; font-size: 11.5px; color: var(--muted); margin-top: 14px; }
.cal-legend .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* ---------- Toggle switch (All Day) ---------- */
.switch { position: relative; display: inline-block; width: 40px; height: 21px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0; border-radius: 21px; background: #d6dce6; transition: .15s;
}
.switch i::before {
  content: ""; position: absolute; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px; transition: .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i::before { transform: translateX(19px); }

/* ============================================================
   Admin module — stat cards, map/finder, status pills
   ============================================================ */
.astat { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 22px 12px; }
.astat .num { font-size: 26px; font-weight: 700; color: var(--ink); }
.astat .lbl { color: var(--muted); font-size: 12px; margin-top: 2px; }
.astat .more { display: inline-block; margin-top: 12px; color: var(--muted); font-size: 11.5px; text-decoration: underline; text-underline-offset: 3px; }
.astat .ic { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; flex: 0 0 auto; }

/* Map + pharmacy finder */
.map-panel { position: relative; border-radius: var(--radius); overflow: hidden; min-height: 420px; background: #eef0f3; }
.map-panel svg.streets { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-pin {
  position: absolute; width: 26px; height: 26px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700; box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.map-pin i { transform: rotate(45deg); font-style: normal; }
.map-pop {
  position: absolute; width: 240px; background: #fff; border-radius: 10px;
  box-shadow: var(--shadow-lg); font-size: 11px; overflow: hidden; z-index: 5;
}
.map-pop .head { background: var(--navy); color: #fff; padding: 10px 12px; }
.map-pop .head b { display: block; font-size: 12px; }
.map-pop .head small { color: #9fb0cc; font-size: 10px; }
.map-pop .rowl { display: flex; padding: 5px 12px; }
.map-pop .rowl span { flex: 0 0 92px; color: var(--muted); }
.map-pop .rowl b { color: var(--ink); font-weight: 500; }

.finder { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.finder .flist { margin-top: 12px; }
.finder .frow { display: flex; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.finder .frow:last-child { border-bottom: none; }
.finder .badge-dot { width: 30px; height: 30px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.finder .frow b { display: block; font-size: 12.5px; color: var(--ink); }
.finder .frow small { color: var(--muted); font-size: 10.5px; }
.finder .frow small a { color: var(--blue); }

/* Export dropdown + generic details-menu (XD: "Export Options") */
details.menu { position: relative; }
details.menu summary { list-style: none; cursor: pointer; }
details.menu summary::-webkit-details-marker { display: none; }
details.menu .menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow-lg); padding: 6px 0; min-width: 130px;
}
details.menu .menu-panel a { display: flex; gap: 9px; align-items: center; padding: 7px 14px; font-size: 12px; color: var(--text); }
details.menu .menu-panel a:hover { background: #f6f8fb; }
details.menu .menu-panel a.sel { color: var(--blue); }
details.menu .menu-panel a.sel::after { content: "✓"; margin-left: auto; }

/* Multi-select patient chips (XD: Edit Card – Double Patient) */
.chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.chip-tag { display: inline-flex; align-items: center; gap: 7px; background: var(--blue); color: #fff; font-size: 10px; font-weight: 500; border-radius: 4px; padding: 4px 8px; }
.chip-tag b { font-weight: 400; cursor: pointer; }
.chip-more { background: var(--ink); color: #fff; border-radius: 50%; width: 20px; height: 20px; font-size: 9.5px; display: inline-flex; align-items: center; justify-content: center; }

/* Status pills (All Logs) */
.pill-tag { font-size: 10.5px; font-weight: 600; padding: 3px 12px; border-radius: 4px; }
.pill-tag.login  { background: #e3f7ec; color: var(--c-green); }
.pill-tag.active   { background: #e0f4f4; color: #2aa5a0; }
.pill-tag.inactive { background: #ffe3e3; color: var(--c-red); }
.pill-tag.logout { background: #ffe3e3; color: var(--c-red); }
.pill-tag.create { background: #e7f0ff; color: var(--blue); }

/* ============================================================
   Data tables — shared by every report screen
   ============================================================ */
/* Tables are wide (9+ cols) and never collapse to cards, so the
   wrapper scrolls and the first two columns pin to the left edge. */
.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 940px; }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  background: #fff; white-space: nowrap;
}
tbody td { padding: 14px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--text); }
tbody tr:hover { background: #fafbfe; }

/* Pinned checkbox + Name columns */
.table-wrap th:nth-child(1), .table-wrap td:nth-child(1) { position: sticky; left: 0;    z-index: 2; background: inherit; }
.table-wrap th:nth-child(2), .table-wrap td:nth-child(2) { position: sticky; left: 34px; z-index: 2; background: inherit; }
.table-wrap tbody td:nth-child(1),
.table-wrap tbody td:nth-child(2) { background: #fff; }
.table-wrap tbody tr:hover td:nth-child(1),
.table-wrap tbody tr:hover td:nth-child(2) { background: #fafbfe; }
.table-wrap th:nth-child(2)::after,
.table-wrap td:nth-child(2)::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 1px; background: var(--line);
}

.chk { width: 16px; height: 16px; border: 1.5px solid var(--line); border-radius: 4px; display: inline-block; vertical-align: middle; }
.sign { font-family: "Segoe Script", cursive; color: #2a3550; font-size: 15px; white-space: nowrap; }

/* ============================================================
   Responsive — desktop + tablet only
   Phones are out of scope, so the app has a hard 768px floor
   and the sidebar collapses to an icon rail instead of a drawer.
   ============================================================ */
body { min-width: 768px; }

@media (max-width: 1279px) {
  :root { --sidebar-w: 76px; }

  /* Scoped to .sidebar — .brand/.nav are reused in content panels
     (e.g. the pharmacy finder), which must NOT collapse. */
  .sidebar { padding: 26px 12px 22px; }
  .sidebar .brand { justify-content: center; padding: 4px 0 22px; }
  .sidebar .brand .logo-text { display: none; }

  /* font-size:0 hides the labels without needing a wrapper element in
     every nav item — icons are sized in px so they are unaffected. */
  .sidebar .nav a { font-size: 0; gap: 0; justify-content: center; padding: 13px 0; }
  .sidebar .nav a svg { width: 20px; height: 20px; }
  /* submenu chevrons (admin nav) carry margin-left:auto, which would drag
     the icon off-center in the rail — drop them entirely at this width */
  .sidebar .nav a span { display: none; }

  .topbar { padding-left: 22px; padding-right: 22px; gap: 14px; }
  .content { padding-left: 22px; padding-right: 22px; }
  .topbar h1 { font-size: 22px; }
  .topbar .user .name,
  .topbar .user .status { display: none; }
}

/* ============================================================
   Utility helpers used across pages
   ============================================================ */
.row { display: flex; }
.gap-16 { gap: 16px; }
.between { justify-content: space-between; align-items: center; }
.center { align-items: center; }
.wrap { flex-wrap: wrap; }

/* The hamburger button and the drawer backdrop exist in the markup at all
   widths but only show on phones (see the ≤767px block). The toggle is the
   CSS checkbox hack (#pp-nav), so no JavaScript is needed — matching the
   JS-free sidebar/topbar. */
.pp-nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.pp-burger { display: none; }
.pp-nav-backdrop { display: none; }

/* ============================================================
   Phone (≤767px) — the ≤1279px rule already collapses the sidebar to a
   76px icon rail; here the main column tightens so content fits a phone and
   never forces a whole-page horizontal scroll, and the sidebar becomes an
   off-canvas drawer opened by a hamburger so the content gets the full width.
   ============================================================ */
@media (max-width: 767px) {
  .content { padding: 0 14px 30px; }
  .topbar { padding: 16px 14px; gap: 12px; }
  .topbar h1 { font-size: 20px; }
  .crumb { flex-wrap: wrap; }

  /* Show the hamburger (first item in the topbar). */
  .pp-burger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; flex: 0 0 auto;
    border: 1px solid var(--line); border-radius: 9px;
    background: #fff; color: var(--ink); cursor: pointer;
  }
  .pp-burger svg { width: 20px; height: 20px; }

  /* Sidebar off-canvas: position:fixed takes it out of the flex row, so .main
     fills the full phone width. It slides in when #pp-nav is checked. The
     ≤1279px rule collapsed it to a 76px icon rail — restore the full labelled
     drawer here. */
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 60;
    width: 250px; height: 100vh;
    padding: 26px 18px 22px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 2px 0 22px rgba(5, 12, 28, .28);
  }
  .sidebar .brand { justify-content: flex-start; padding: 4px 8px 26px; }
  .sidebar .brand .logo-text { display: block; }
  .sidebar .nav a { font-size: 14px; gap: 13px; justify-content: flex-start; padding: 11px 14px; }
  .sidebar .nav a span { display: inline; }
  .pp-nav-toggle:checked ~ .sidebar { transform: translateX(0); }

  /* Tap-anywhere backdrop (it is a <label for="pp-nav">, so a tap closes). */
  .pp-nav-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(5, 12, 28, .45); }
  .pp-nav-toggle:checked ~ .pp-nav-backdrop { display: block; }
}
