/* ============================================================================
   PREMIER RX — PHARMACY OPERATIONS PORTAL
   Design tokens + component primitives
   Direction: clinical-operational · navy structure · royal interaction ·
              medical-green confirmation · compact, data-first density
   Light mode primary. Desktop dispatcher/admin.
   ----------------------------------------------------------------------------
   This file is the source of truth. Rebuild any portal screen using only
   these tokens and the .component classes below.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;1,14..32,400&family=Geist+Mono:wght@400;500;600&display=swap');

:root {
  /* ---- BRAND : PERIWINKLE (primary interactive) ----------------------- */
  --navy-900: #2d3a8c;
  --navy-800: #3a4aab;
  --navy-700: #4558c8;
  --navy-600: #7c3aed;
  --navy-100: #ede9fe;

  --sky-700: #6d28d9;
  --sky-600: #7c3aed;
  --sky-500: #a855f7;
  --sky-400: #c084fc;
  --sky-100: #ddd6fe;
  --sky-050: #f5f3ff;

  /* ---- APP SHELL -------------------------------------------------------- */
  --nav-dark:   #1a2533;   /* sidebar/topbar background                */
  --nav-accent: #e84545;   /* badge accent red                         */
  --nav-active-bg:   #eff6ff;  /* active nav item bg (light mode)     */
  --nav-active-text: #1a73e8;  /* active nav item text                 */

  /* ---- BRAND : MEDICAL GREEN (#10b981 · confirmation) ---------------- */
  --green-800: #065f46;
  --green-700: #047857;
  --green-600: #059669;
  --green-500: #10b981;
  --green-100: #d1fae5;

  /* ---- NEUTRALS : cool gray ------------------------------------------ */
  --ink:       #1a2533;
  --slate-700: #374151;
  --slate-600: #4b5563;
  --slate-500: #6b7280;
  --slate-400: #9ca3af;
  --slate-300: #d1d5db;
  --slate-200: #e5e7eb;
  --slate-150: #eaeef4;
  --slate-100: #f3f4f6;
  --slate-50:  #f5f7fa;
  --white:     #ffffff;
  --surface:   #ffffff;

  /* ---- SEMANTIC -------------------------------------------------------- */
  --success:   #047857;    --success-bg: #d1fae5;
  --info:      #7c3aed;    --info-bg:    #ede9fe;
  --warning:   #d97706;    --warning-bg: #fef3c7;
  --danger:    #ef4444;    --danger-bg:  #fee2e2;

  /* ---- STATUS PALETTE ------------------------------------------------- */
  --st-new:        #7c3aed;  --st-new-bg:        #ede9fe;
  --st-prep:       #d97706;  --st-prep-bg:       #fef3c7;
  --st-ready:      #0891b2;  --st-ready-bg:      #cffafe;
  --st-out:        #7c3aed;  --st-out-bg:        #ddd6fe;
  --st-delivered:  #047857;  --st-delivered-bg:  #d1fae5;
  --st-exception:  #ef4444;  --st-exception-bg:  #fee2e2;
  --st-hold:       #6b7280;  --st-hold-bg:       #f3f4f6;

  /* pharmacy flags */
  --flag-cold:    #0891b2;  --flag-cold-bg:    #cffafe;
  --flag-control: #7c3aed;  --flag-control-bg: #ede9fe;
  --flag-stat:    #ef4444;  --flag-stat-bg:    #fee2e2;

  /* ---- TYPE ------------------------------------------------------------ */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', monospace;

  --fs-display: 28px;  --lh-display: 34px;
  --fs-h1: 22px;       --lh-h1: 28px;
  --fs-h2: 18px;       --lh-h2: 24px;
  --fs-h3: 15px;       --lh-h3: 20px;
  --fs-body: 14px;     --lh-body: 20px;
  --fs-sm: 13px;       --lh-sm: 18px;
  --fs-xs: 12px;       --lh-xs: 16px;
  --fs-micro: 11px;    --lh-micro: 14px;

  /* ---- SPACE (4px base grid) ------------------------------------------ */
  --sp-1: 2px;  --sp-2: 4px;  --sp-3: 6px;  --sp-4: 8px;  --sp-5: 12px;
  --sp-6: 16px; --sp-7: 20px; --sp-8: 24px; --sp-9: 32px; --sp-10: 40px;
  --sp-11: 48px; --sp-12: 64px;

  /* ---- RADIUS ---------------------------------------------------------- */
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 12px; --r-2xl: 16px; --r-pill: 999px;

  /* ---- ELEVATION ------------------------------------------------------- */
  --sh-xs: 0 1px 2px 0 rgb(0 0 0 / .05);
  --sh-sm: 0 1px 3px 0 rgb(0 0 0 / .08), 0 1px 2px -1px rgb(0 0 0 / .08);
  --sh-md: 0 4px 6px -1px rgb(0 0 0 / .08), 0 2px 4px -2px rgb(0 0 0 / .08);
  --sh-lg: 0 8px 24px rgba(26, 37, 51, .12), 0 2px 6px rgba(26, 37, 51, .08);
  --sh-pop: 0 12px 32px rgba(26, 37, 51, .18);
  --ring: 0 0 0 3px rgba(124, 58, 237, .22);

  /* ---- LAYOUT ---------------------------------------------------------- */
  --sidebar-w: 232px;
  --topbar-h: 56px;
  --row-h: 44px;
}

/* ============================================================================
   BASE
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--slate-50);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.tnum { font-variant-numeric: tabular-nums; }

/* type helpers */
.t-display { font-size: var(--fs-display); line-height: var(--lh-display); font-weight: 800; letter-spacing: -.02em; }
.t-h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: 700; letter-spacing: -.01em; }
.t-h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 700; letter-spacing: -.01em; }
.t-h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 600; }
.t-body { font-size: var(--fs-body); line-height: var(--lh-body); }
.t-sm { font-size: var(--fs-sm); line-height: var(--lh-sm); }
.t-xs { font-size: var(--fs-xs); line-height: var(--lh-xs); }
.t-label {
  font-size: var(--fs-micro); line-height: var(--lh-micro);
  font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--slate-500);
}
.t-muted { color: var(--slate-500); }
.t-faint { color: var(--slate-400); }

/* ============================================================================
   BUTTONS
   ========================================================================== */
.btn {
  --btn-h: 32px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-3);
  height: var(--btn-h); padding: 0 var(--sp-5);
  font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: 600;
  line-height: 1; border-radius: var(--r-md); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease, color .12s ease;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--sky-600); color: #fff; }
.btn-primary:hover { background: var(--sky-700); }

.btn-secondary { background: var(--white); color: var(--navy-800); border-color: var(--slate-300); }
.btn-secondary:hover { background: var(--slate-100); border-color: var(--slate-400); }

.btn-ghost { background: transparent; color: var(--slate-600); }
.btn-ghost:hover { background: var(--slate-100); color: var(--navy-800); }

.btn-success { background: var(--green-700); color: #fff; }
.btn-success:hover { background: var(--green-800); }

.btn-danger { background: var(--white); color: var(--danger); border-color: #efc3bf; }
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { --btn-h: 26px; font-size: var(--fs-xs); padding: 0 var(--sp-4); }
.btn-lg { --btn-h: 38px; font-size: var(--fs-body); padding: 0 var(--sp-6); }
.btn-icon { width: var(--btn-h); padding: 0; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ============================================================================
   FIELDS
   ========================================================================== */
.field {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  height: 32px; padding: 0 var(--sp-4);
  background: var(--white); border: 1px solid var(--slate-300); border-radius: var(--r-md);
  font-size: var(--fs-sm); color: var(--ink); width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.field:focus-within { border-color: var(--sky-500); box-shadow: var(--ring); }
.field svg { width: 15px; height: 15px; color: var(--slate-400); flex: none; }
.field input, .field select {
  border: none; outline: none; background: transparent; width: 100%;
  font-family: var(--font-sans); font-size: var(--fs-sm); color: var(--ink);
}
.field input::placeholder { color: var(--slate-400); }
.field-label { display: block; margin-bottom: var(--sp-3); }

/* ============================================================================
   BADGES / STATUS PILLS
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 8px;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1;
  border-radius: var(--r-sm); white-space: nowrap;
  background: var(--slate-100); color: var(--slate-600);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge svg { width: 12px; height: 12px; }

/* status — solid dot + tinted bg */
.badge-new        { background: var(--st-new-bg);        color: var(--st-new); }
.badge-prep       { background: var(--st-prep-bg);       color: var(--st-prep); }
.badge-ready      { background: var(--st-ready-bg);      color: var(--st-ready); }
.badge-out        { background: var(--st-out-bg);        color: var(--st-out); }
.badge-delivered  { background: var(--st-delivered-bg);  color: var(--st-delivered); }
.badge-exception  { background: var(--st-exception-bg);  color: var(--st-exception); }
.badge-hold       { background: var(--st-hold-bg);       color: var(--st-hold); }

/* pharmacy flags — outlined chips */
.flag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px; border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1; border: 1px solid;
}
.flag svg { width: 12px; height: 12px; }
.flag-cold    { color: var(--flag-cold);    background: var(--flag-cold-bg);    border-color: #b8e2e6; }
.flag-control { color: var(--flag-control); background: var(--flag-control-bg); border-color: #e0c8f4; }
.flag-stat    { color: var(--flag-stat);    background: var(--flag-stat-bg);    border-color: #f3c3bf; }

/* priority dot */
.pri { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; }
.pri::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.pri-routine::before { background: var(--slate-400); }
.pri-urgent::before  { background: var(--warning); }
.pri-stat::before    { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }

/* ============================================================================
   CARDS / PANELS / STATS
   ========================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--slate-200);
  border-radius: var(--r-lg); box-shadow: var(--sh-xs);
}
.card-pad { padding: var(--sp-6); }

.stat {
  background: var(--surface); border: 1px solid var(--slate-200);
  border-radius: var(--r-lg); padding: var(--sp-5) var(--sp-6); box-shadow: var(--sh-xs);
}
.stat .stat-label { font-size: var(--fs-xs); font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: .05em; }
.stat .stat-value { font-family: var(--font-mono); font-size: 26px; line-height: 1.1; font-weight: 600; color: var(--navy-800); margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .stat-delta { font-size: var(--fs-xs); font-weight: 600; margin-top: 4px; display: inline-flex; align-items: center; gap: 3px; }
.delta-up { color: var(--green-700); }
.delta-down { color: var(--danger); }

/* ============================================================================
   TABLE (delivery queue)
   ========================================================================== */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tbl thead th {
  position: sticky; top: 0; background: var(--slate-50);
  text-align: left; font-size: var(--fs-micro); font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--slate-500);
  padding: 9px var(--sp-5); border-bottom: 1px solid var(--slate-200); white-space: nowrap;
}
.tbl tbody td { padding: 0 var(--sp-5); height: var(--row-h); border-bottom: 1px solid var(--slate-150); vertical-align: middle; }
.tbl tbody tr { transition: background .1s ease; }
.tbl tbody tr:hover { background: var(--sky-050); }
.tbl tbody tr.is-selected { background: var(--sky-100); box-shadow: inset 2px 0 0 var(--sky-600); }
.tbl .cell-id { font-family: var(--font-mono); font-weight: 500; color: var(--navy-700); }
.tbl .cell-strong { font-weight: 600; color: var(--ink); }

/* ============================================================================
   AVATAR / DRIVER CHIP
   ========================================================================== */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--navy-100); color: var(--navy-700);
  font-size: var(--fs-xs); font-weight: 700; flex: none;
}
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.is-online { box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--green-500); }

.driver-chip {
  display: inline-flex; align-items: center; gap: var(--sp-4);
  padding: 5px 10px 5px 5px; background: var(--white);
  border: 1px solid var(--slate-200); border-radius: var(--r-pill);
}

/* ============================================================================
   SEGMENTED CONTROL / TABS
   ========================================================================== */
.seg { display: inline-flex; padding: 3px; background: var(--slate-100); border-radius: var(--r-md); gap: 2px; }
.seg button {
  border: none; background: transparent; cursor: pointer;
  height: 26px; padding: 0 12px; border-radius: var(--r-sm);
  font-family: var(--font-sans); font-size: var(--fs-xs); font-weight: 600; color: var(--slate-500);
}
.seg button.is-active { background: var(--white); color: var(--navy-800); box-shadow: var(--sh-xs); }

.tabs { display: flex; gap: var(--sp-6); border-bottom: 1px solid var(--slate-200); }
.tabs a {
  padding: 10px 0; font-size: var(--fs-sm); font-weight: 600; color: var(--slate-500);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a.is-active { color: var(--sky-600); border-bottom-color: var(--sky-600); }

/* ============================================================================
   TOAST / NOTIFICATION
   ========================================================================== */
.toast {
  display: flex; gap: var(--sp-5); align-items: flex-start;
  width: 340px; padding: var(--sp-5); background: var(--white);
  border: 1px solid var(--slate-200); border-left: 3px solid var(--sky-600);
  border-radius: var(--r-md); box-shadow: var(--sh-lg);
}
.toast-success { border-left-color: var(--green-600); }
.toast-danger  { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-ico { width: 28px; height: 28px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; }
.toast-ico svg { width: 16px; height: 16px; }

.notif {
  display: flex; gap: var(--sp-5); padding: var(--sp-5);
  border-bottom: 1px solid var(--slate-150);
}
.notif.is-unread { background: var(--sky-050); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sky-600); margin-top: 6px; flex: none; }

/* ============================================================================
   CHAT
   ========================================================================== */
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 14px; font-size: var(--fs-sm); line-height: 18px; }
.bubble-in  { background: var(--slate-100); color: var(--ink); border-bottom-left-radius: 4px; align-self: flex-start; }
.bubble-out { background: var(--sky-600); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.bubble-time { font-size: 10px; color: var(--slate-400); margin-top: 3px; }

/* ============================================================================
   APP SHELL (sidebar + topbar)
   ========================================================================== */
.nav-item {
  display: flex; align-items: center; gap: var(--sp-5);
  height: 36px; padding: 0 var(--sp-5); border-radius: var(--r-md);
  color: rgba(255,255,255,.72); font-size: var(--fs-sm); font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.is-active { background: var(--sky-600); color: #fff; font-weight: 600; }
.nav-item .nav-badge {
  margin-left: auto; background: rgba(255,255,255,.16); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: var(--r-pill);
}
.nav-item.is-active .nav-badge { background: rgba(255,255,255,.22); }

/* ============================================================================
   MAP / ROUTE ITEM
   ========================================================================== */
.route-stop {
  display: flex; gap: var(--sp-5); align-items: flex-start;
  padding: var(--sp-4) 0; position: relative;
}
.route-stop .node {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--white); border: 2px solid var(--sky-600); color: var(--sky-600);
  z-index: 1;
}
.route-stop.done .node { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.route-line { position: absolute; left: 10px; top: 22px; bottom: -8px; width: 2px; background: var(--slate-200); }

/* generic helpers */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); } .gap-8 { gap: var(--sp-8); }
.grow { flex: 1; } .wrap { flex-wrap: wrap; }

/* ============================================================================
   HR APP SHELL — one shared nav across every HR page (coalesced SaaS shell)
   ========================================================================== */
.hrapp-top {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--white); border-bottom: 1px solid var(--slate-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-7); z-index: 60;
}
.hrapp-top img { height: 28px; width: auto; object-fit: contain; display: block; }
.hrapp-top .right { display: flex; align-items: center; gap: var(--sp-6); }
.hrapp-logout { background: transparent; border: 1px solid var(--slate-300); border-radius: var(--r-md);
  height: 32px; padding: 0 var(--sp-5); font-family: var(--font-sans); font-size: var(--fs-sm);
  font-weight: 600; color: var(--slate-600); cursor: pointer; }
.hrnav {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--nav-dark); overflow-y: auto; z-index: 50;
  display: flex; flex-direction: column; padding: var(--sp-5) var(--sp-4); gap: 2px;
}
.hrnav-item { display: flex; align-items: center; gap: var(--sp-5); height: 38px; padding: 0 var(--sp-5);
  border-radius: var(--r-md); color: rgba(255,255,255,.72); font-size: var(--fs-sm); font-weight: 500;
  text-decoration: none; cursor: pointer; }
.hrnav-item .ic { width: 18px; flex: none; display: flex; align-items: center; justify-content: center; }
/* Approved icon library (see templates/_icons.html) — align inline SVGs to text */
svg.lucide { vertical-align: -0.15em; flex: none; }
.hrnav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.hrnav-item.active { background: var(--sky-600); color: #fff; font-weight: 600; }
.hrnav-spacer { flex: 1 1 auto; }
.hrnav-label { font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .06em;
  color: rgba(255,255,255,.38); font-weight: 700; padding: var(--sp-5) var(--sp-5) var(--sp-3); }
.hrapp-main { margin-left: var(--sidebar-w); padding-top: var(--topbar-h); min-height: 100vh; }
.hrapp-body { max-width: 1000px; margin: 0 auto; padding: var(--sp-8); }
@media (max-width: 820px) { .hrnav { display: none; } .hrapp-main { margin-left: 0; } }
