/* ═══════════════════════════════════════════
   POS DESIGN TOKENS — Biz Research Hub
   Design Bible: github.com/Abhishek-POSdesign/design-bible
   Do not add hardcoded hex or px values outside of this :root block.
═══════════════════════════════════════════ */
:root {
  /* Canvas & surface */
  --canvas: #f5f4f1;
  --card:   #ffffff;

  /* Borders */
  --border:   #e2e0d8;
  --border-s: #cbd5e1;

  /* Text hierarchy */
  --text:  #121110;
  --text2: #4b5563;
  --text3: #6b7280;

  /* Buttons */
  --btn-bg: #1a1a1a;
  --btn-fg: #f5f4f1;
  --m-bg:   #ede9e3;
  --m-fg:   #1a1a1a;

  /* Semantic states */
  --ok-bg:   #e2f4e8;
  --ok-fg:   #1b5232;
  --err-bg:  #fbeceb;
  --err-fg:  #7f231c;
  --warn-bg: #fdf0cd;
  --warn-fg: #7a4800;
  --info-bg: #e3f2fd;
  --info-fg: #0d47a1;

  /* Geometry */
  --r:  12px;
  --rs: 8px;
  --rx: 6px;

  /* Shadow — Class A card (flat, premium; design bible §06.2) */
  --sh: 0 2px 8px -2px rgba(0,0,0,.06), inset 0 1px 0 0 rgba(255,255,255,.75);

  /* Motion — snappy, non-bouncy (design bible §10.2) */
  --ease: 150ms cubic-bezier(.16,1,.3,1);

  /* Layout */
  --sw: 240px;  /* sidebar width — fixed, never fluid */

  /* Spacing scale (design bible §03) */
  --sp1: 4px;
  --sp2: 8px;
  --sp3: 12px;
  --sp4: 16px;
  --sp5: 20px;
  --sp6: 24px;
  --sp7: 32px;
  --sp8: 40px;
  --sp9: 48px;
}

/* ═══ RESET ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Instrument Sans', -apple-system, sans-serif;
  font-size: 15px;
  background: var(--canvas);
  display: flex;
  height: 100vh;
  overflow: hidden;
  color: var(--text);
  line-height: 1.5;
}

/* ═══════════════════════════════════════════
   SIDEBAR — design bible §12 (navigation)
   240px fixed · canvas background · no shadow
   Active = white card surface + 2px left accent
═══════════════════════════════════════════ */
#sidebar {
  width: var(--sw);
  background: var(--canvas);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-top { padding: var(--sp4) var(--sp4) 10px; }
.sidebar-logo-row { display: flex; align-items: center; justify-content: space-between; }
.sidebar-logo {
  font-family: 'Inter', sans-serif;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: -.02em;
  color: var(--text);
}
.sidebar-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.biz-list { overflow-y: auto; flex: 1; padding-bottom: var(--sp2); }
.sidebar-footer {
  padding: var(--sp2) var(--sp4);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text3);
}

/* Sidebar items — 40px height per design bible §12.6 */
.biz-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--sp3);
  height: 40px;
  cursor: pointer;
  border-radius: var(--rs);
  margin: 1px var(--sp2);
  transition: background var(--ease);
  border-left: 2px solid transparent;
  user-select: none;
}
.biz-item:hover { background: rgba(18,17,16,.06); }
/* Active = white card + 2px left accent (design bible §12.6) */
.biz-item.active {
  background: var(--card);
  border-left-color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.biz-name {
  font-size: 13px;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.biz-item.active .biz-name { color: var(--text); font-weight: 600; }
.biz-stage { font-size: 10px; color: var(--text3); line-height: 1.3; margin-top: 1px; }

/* ═══════════════════════════════════════════
   MAIN CONTENT SHELL
═══════════════════════════════════════════ */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#hdr {
  background: var(--card);
  padding: 13px var(--sp5);
  display: flex;
  align-items: center;
  gap: var(--sp3);
  border-bottom: 1px solid var(--border);
}
.hdr-emoji { font-size: 24px; }
.hdr-title-block { flex: 1; min-width: 0; }
.hdr-name {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hdr-stats { font-size: 12px; color: var(--text3); margin-top: 1px; }
.hdr-badge {
  padding: 4px 12px;
  border-radius: var(--rx);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

#top-bar {
  display: flex;
  gap: var(--sp2);
  padding: var(--sp2) var(--sp5);
  background: var(--canvas);
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.save-status { font-size: 12px; color: var(--text3); margin-left: auto; }

#content { flex: 1; overflow: auto; padding: var(--sp4) var(--sp5); }

/* ═══════════════════════════════════════════
   CARDS — Class A: flat, neutral data surface
   design bible §06.2 — no colored fills, no glow
   Radius: 12px · Padding: 18px 20px
═══════════════════════════════════════════ */
.card {
  background: var(--card);
  border-radius: var(--r);
  padding: 18px var(--sp5);
  box-shadow: var(--sh);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.panel {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--sh);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ═══════════════════════════════════════════
   TABS — quiet idle, clear active
═══════════════════════════════════════════ */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  background: rgba(18,17,16,.05);
  border-radius: var(--r);
  padding: 3px;
}
.tab-btn {
  flex: 1;
  padding: var(--sp2) 6px;
  border: none;
  border-radius: var(--rs);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  color: var(--text3);
  font-family: inherit;
  transition: all 120ms ease;
  user-select: none;
}
.tab-btn.active {
  font-weight: 700;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
}

/* ═══════════════════════════════════════════
   BUTTONS — design bible §10
   Hierarchy: primary → muted → confirm → destructive
   Physics: translateY(-1px) hover, scale(.99) press
   Radius: 12px (--r) — no exceptions
   No bounce · no glow · no gradient
═══════════════════════════════════════════ */
.btn {
  padding: var(--sp2) var(--sp4);
  border-radius: var(--r);
  border: none;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  /* Snappy timing profile — design bible §10.2 */
  transition: transform var(--ease), opacity 120ms ease, background-color 120ms ease;
  user-select: none;
}
/* Tactile micro-scaling — design bible §10.2 */
.btn:hover  { transform: translateY(-1px) scale(1.008); }
.btn:active { transform: translateY(0)    scale(.99); }

.btn.p { background: var(--btn-bg); color: var(--btn-fg); }
.btn.m { background: var(--m-bg);   color: var(--m-fg); }
.btn.s { background: var(--ok-bg);  color: var(--ok-fg); }
.btn.e { background: var(--err-bg); color: var(--err-fg); }
.btn.i { background: var(--info-bg); color: var(--info-fg); }

/* Small buttons — same hierarchy, more compact */
.btn-sm {
  padding: 5px var(--sp3);
  border-radius: var(--r);
  border: none;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  transition: transform var(--ease), opacity 120ms ease;
  user-select: none;
}
.btn-sm:hover  { transform: translateY(-1px) scale(1.008); }
.btn-sm:active { transform: translateY(0)    scale(.99); }
.btn-sm.p { background: var(--btn-bg); color: var(--btn-fg); }
.btn-sm.m { background: var(--m-bg);   color: var(--m-fg); }
.btn-sm.s { background: var(--ok-bg);  color: var(--ok-fg); }
.btn-sm.e { background: var(--err-bg); color: var(--err-fg); }
.btn-sm.i { background: var(--info-bg); color: var(--info-fg); }

/* ═══════════════════════════════════════════
   FORMS — design bible §13
   Clean borders, clear focus ring, no decoration
═══════════════════════════════════════════ */
input, select, textarea {
  width: 100%;
  padding: 9px var(--sp3);
  border: 1px solid var(--border);
  border-radius: var(--rs);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #faf9f7;
  color: var(--text);
  transition: border-color 120ms;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-s);
  background: var(--card);
}
textarea { resize: vertical; }

/* Section label — uppercase, tracked, muted */
.lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 5px;
  display: block;
}

/* ═══════════════════════════════════════════
   RICH TEXT EDITOR
═══════════════════════════════════════════ */
.rte-wrap { border: 1px solid var(--border); border-radius: var(--rs); overflow: hidden; background: #faf9f7; }
.rte-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px var(--sp2);
  border-bottom: 1px solid var(--border);
  background: rgba(18,17,16,.03);
  flex-wrap: wrap;
}
.rte-btn {
  border: none;
  background: transparent;
  border-radius: var(--rx);
  padding: 5px 9px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: background 120ms;
}
.rte-btn:hover { background: var(--m-bg); }
.rte-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; }
.rte-heading {
  width: auto;
  padding: 5px var(--sp2);
  font-size: 12px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: var(--rx);
  font-family: inherit;
}
.rte-status { margin-left: auto; font-size: 11px; color: var(--text3); white-space: nowrap; padding-left: var(--sp2); }
.rte-editor {
  min-height: 36vh;
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--sp3) 14px;
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  background: var(--card);
}
.rte-editor h2 { font-size: 17px; font-weight: 700; margin: 10px 0 6px; font-family: 'Source Serif 4', serif; }
.rte-editor h3 { font-size: 14px; font-weight: 600; margin: 8px 0 5px; }
.rte-editor ul, .rte-editor ol { padding-left: 22px; margin: 6px 0; }
.rte-editor:empty:before { content: attr(data-placeholder); color: var(--text3); }

/* ═══════════════════════════════════════════
   CONTACT CARDS — compact, scannable rows
   design bible §05 — flat, row-rhythm, no shadow stacks
═══════════════════════════════════════════ */
.contact-card {
  border-radius: var(--rs);
  padding: 12px 14px;
  margin-bottom: 8px;
  background: rgba(18,17,16,.02);
  border: 1px solid var(--border);
  transition: border-color var(--ease);
}
.contact-card:hover { border-color: var(--border-s); }
.contact-card.overdue { background: var(--warn-bg); border-left: 3px solid var(--warn-fg); }

/* ═══════════════════════════════════════════
   DATA ROWS — design bible §05 (tables/lists)
   For library items, comm history rows
   Compact · scannable · hover feedback
═══════════════════════════════════════════ */
.data-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.data-row:last-child { border-bottom: none; }

/* ═══════════════════════════════════════════
   BADGE SYSTEM — unified status pills
   design bible §05 — flat, accessible, compact
   Use: <span class="badge ok">Agreed ✓</span>
═══════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp2);
  border-radius: var(--rx);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}
.badge.ok   { background: var(--ok-bg);   color: var(--ok-fg);   }
.badge.err  { background: var(--err-bg);  color: var(--err-fg);  }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.info { background: var(--info-bg); color: var(--info-fg); }
.badge.neu  { background: rgba(18,17,16,.07); color: var(--text2); }

/* ═══════════════════════════════════════════
   EMPTY STATES — design bible ch.15
   Structure: icon → title → sub → action
═══════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--sp9) var(--sp6);
  color: var(--text3);
}
.empty-state-icon  { font-size: 28px; margin-bottom: var(--sp3); opacity: .45; line-height: 1; }
.empty-state-title { font-size: 15px; font-weight: 700; color: var(--text2); margin-bottom: 6px; }
.empty-state-sub   { font-size: 13px; color: var(--text3); max-width: 28ch; line-height: 1.55; margin-bottom: var(--sp6); }

/* ═══════════════════════════════════════════
   PANEL HEADER — consistent chrome for all panels/cards
═══════════════════════════════════════════ */
.panel-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px var(--sp4);
  border-bottom: 1px solid var(--border);
  gap: var(--sp2);
}
.panel-hdr .lbl { margin: 0; }

/* ═══════════════════════════════════════════
   NOTEBOOK — stable sidebar, predictable editor
═══════════════════════════════════════════ */
.nb-sidebar { width: 190px; flex-shrink: 0; border-right: 1px solid var(--border); padding-right: var(--sp3); }
.nb-item {
  padding: 9px 11px;
  border-radius: var(--rs);
  cursor: pointer;
  margin-bottom: 3px;
  background: rgba(18,17,16,.03);
  border: 1px solid transparent;
  transition: background var(--ease);
  user-select: none;
}
.nb-item:hover { background: rgba(18,17,16,.07); }
.nb-item.active { background: var(--btn-bg); border-color: var(--btn-bg); }
.nb-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nb-item.active .nb-item-title { color: var(--btn-fg); }
.nb-item-date { font-size: 10px; color: var(--text3); margin-top: 2px; }
.nb-item.active .nb-item-date { color: rgba(245,244,241,.55); }
.nb-editor { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.nb-editor-header { display: flex; align-items: center; gap: 10px; }
.nb-editor-actions {
  display: flex;
  gap: var(--sp2);
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════
   MODAL — design bible §16 overlay system
   Centered · max 480px · flat backdrop rgba(0,0,0,.14)
   NO backdrop-filter · soft premium shadow
═══════════════════════════════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.14);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  /* NO backdrop-filter — explicitly banned in POS design bible */
}
.modal {
  background: var(--card);
  border-radius: var(--r);
  padding: var(--sp6);
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.13), 0 1px 4px rgba(0,0,0,.06);
  border: 1px solid var(--border);
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: var(--sp5);
  color: var(--text);
}
.modal-footer {
  display: flex;
  gap: var(--sp2);
  justify-content: flex-end;
  margin-top: var(--sp5);
  padding-top: var(--sp4);
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════
   GRID HELPERS
═══════════════════════════════════════════ */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ═══════════════════════════════════════════
   SECTION HELPERS — inline content headings
═══════════════════════════════════════════ */
.section-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: var(--sp2); }
.section-sub   { font-size: 12px; color: var(--text3); margin-bottom: var(--sp3); line-height: 1.5; }

/* Tabular numbers — mandatory for metrics/dates (design bible §05.5) */
.num { font-variant-numeric: tabular-nums; }

/* ═══════════════════════════════════════════
   SCROLLBAR — thin, on hover only (design bible §12.12)
═══════════════════════════════════════════ */
.biz-list::-webkit-scrollbar,
#content::-webkit-scrollbar,
.rte-editor::-webkit-scrollbar,
.modal::-webkit-scrollbar { width: 4px; }

.biz-list::-webkit-scrollbar-track,
#content::-webkit-scrollbar-track,
.rte-editor::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track { background: transparent; }

.biz-list::-webkit-scrollbar-thumb,
#content::-webkit-scrollbar-thumb,
.rte-editor::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ═══════════════════════════════════════════
   RESPONSIVE — mobile (design bible §12.4)
   Below 768px: sidebar stacks top, content tightens
   No fragile or fancy responsive patterns
═══════════════════════════════════════════ */
@media (max-width: 768px) {
  body { flex-direction: column; height: auto; min-height: 100vh; overflow: auto; }

  #sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .biz-list { max-height: 180px; }

  #main { overflow: visible; }
  #content  { overflow: visible; padding: var(--sp3); }
  #top-bar  { padding: var(--sp2) var(--sp3); }
  #hdr      { padding: 10px var(--sp3); }

  .g2, .g3  { grid-template-columns: 1fr; }

  .modal { width: 96vw; padding: var(--sp4); }

  .tab-bar  { flex-wrap: wrap; }
  .tab-btn  { flex: unset; padding: 7px 10px; }
}
