/*
 * LTV Audit CRM — Design System v1
 * PR7: Global visual harmonization layer
 * Loaded after page-specific <style> blocks to safely override
 * where needed without touching business logic.
 *
 * Principles:
 *   1. Hierarchy first — primary → secondary → utility → danger
 *   2. Less noise — secondary elements muted or hidden
 *   3. Consistency > creativity — same elements look the same everywhere
 *   4. Density with clarity — compact but readable
 */

/* ═══════════════════════════════════════════════════════════════
   SHELL — Instantly-style icon sidebar + header + sub-tab bar
   Injected by shell.js into .app-shell.
   Layout: sidebar 56px fixed left | header fixed top-left:56px |
            subtabs fixed top:56px left:56px | content offset
   ═══════════════════════════════════════════════════════════════ */

/* ── Icon Sidebar ───────────────────────────────────────────── */
.shell-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 56px;
  height: 100vh;
  background: #1A1A1A;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 200;
  overflow: visible;
  /* Sidebar expands on hover to reveal section labels inline. Width-only
     transition; page content keeps its 56px left padding because the
     sidebar is position:fixed and overlays content on expand — no reflow. */
  transition: width .15s ease-out;
}

/* Hover state — expand to ~220px and shift contents to left-aligned rows */
.shell-sidebar:hover {
  width: 220px;
  align-items: stretch;
  box-shadow: 4px 0 14px rgba(0, 0, 0, .22);
}

/* Logo at top */
.shell-slogo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  text-decoration: none;
  margin-top: 4px;
}

/* Nav area: icon buttons */
.shell-snav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  width: 100%;
  padding-top: 8px;
}

/* Each section icon button */
.shell-sitem {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888888;
  text-decoration: none;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.shell-sitem:hover {
  background: rgba(255,255,255,.08);
  color: #ffffff;
}
.shell-sitem.active {
  background: rgba(255,255,255,.15);
  color: #ffffff;
  box-shadow: inset 3px 0 0 #C4704A;
}

/* Count badge on sidebar icon (e.g. Review pending count) */
.shell-sbadge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #C4704A;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  font-family: 'DM Mono', ui-monospace, monospace;
  box-shadow: 0 0 0 2px rgba(20,20,20,.9);
  pointer-events: none;
}
.shell-sbadge[hidden] { display: none; }

/* Tooltip */
.shell-tooltip {
  position: absolute;
  left: 52px;
  top: 50%;
  transform: translateY(-50%);
  background: #333333;
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .1s;
  z-index: 300;
}
.shell-tooltip.visible { opacity: 1; }

/* ── Hover-expand state — reveal labels inline ─────────────────────────────
   When the sidebar is hovered, switch each .shell-sitem from a 44x44 icon
   square to a full-width row with the label rendered inline. The tooltip
   span (otherwise an absolute popout in collapsed mode) flips to static
   positioning so the same DOM serves both modes — no JS / no HTML change.

   `body.shell-sidebar-no-hover` opt-out (e.g. when a modal is open) is
   reserved for future tweaks; nothing toggles it today. */
.shell-sidebar:hover .shell-snav {
  align-items: stretch;
  padding-left: 8px;
  padding-right: 8px;
}
.shell-sidebar:hover .shell-sitem {
  width: 100%;
  height: 40px;
  justify-content: flex-start;
  padding: 0 10px;
  gap: 10px;
}
.shell-sidebar:hover .shell-sitem .shell-tooltip {
  position: static;
  transform: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: inherit;
  opacity: 1;
  /* Avoid the original .shell-tooltip absolute hover popout from running in
     parallel with the inline label — it would double-render the text. */
  box-shadow: none;
  transition: none;
  z-index: auto;
}
.shell-sidebar:hover .shell-sitem .shell-sbadge {
  /* Reposition the count badge so it sits to the right of the label
     (it was anchored to the icon's top-right corner). */
  top: 50%;
  right: 10px;
  left: auto;
  transform: translateY(-50%);
}
.shell-sidebar:hover .shell-slogo {
  width: 100%;
  justify-content: flex-start;
  padding-left: 18px;
}
.shell-sidebar:hover .shell-sbottom {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  padding: 0 14px 14px;
  gap: 10px;
}
.shell-sidebar:hover .shell-sep {
  display: none;
}

/* Bottom: separator + avatar + logout */
.shell-sbottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-bottom: 14px;
  width: 100%;
}

.shell-sep {
  width: 32px;
  height: 1px;
  background: rgba(255,255,255,.12);
  margin-bottom: 4px;
}

.shell-savatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #C4704A;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-user-select: none;
  user-select: none;
}

.shell-slogout {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #888888;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.shell-slogout:hover {
  background: rgba(255,255,255,.08);
  color: #ffffff;
}

/* ── Header (top bar, starts at left: 56px) ─────────────────── */
.shell-header {
  position: fixed;
  top: 0;
  left: 56px;
  right: 0;
  height: 56px;
  background: var(--surface, #161616);
  border-bottom: 1px solid var(--border, #2a2a2a);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  gap: 12px;
}
:root.light .shell-header {
  background: #ffffff;
  border-bottom-color: #E8E4E0;
}

.shell-page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text, #f0f0f0);
  flex-shrink: 0;
}
:root.light .shell-page-title { color: #1A1A1A; }

.shell-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.shell-clocks {
  display: flex;
  align-items: center;
  gap: 14px;
}

.shell-clock {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted, #888);
}
.shell-clock .flag { font-size: 14px; }
.shell-clock .time { font-weight: 600; color: var(--text, #f0f0f0); }
:root.light .shell-clock .time { color: #1A1A1A; }

/* ── Sub-tab bar (below header, starts at left: 56px) ───────── */
.shell-subtabs {
  position: fixed;
  top: 56px;
  left: 56px;
  right: 0;
  height: 44px;
  background: var(--surface, #161616);
  border-bottom: 1px solid var(--border, #2a2a2a);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 99;
}
:root.light .shell-subtabs {
  background: #ffffff;
  border-bottom-color: #E8E4E0;
}

.shell-tab {
  font-size: 13px;
  font-weight: 400;
  color: #8C8580;
  text-decoration: none;
  padding: 0 14px;
  height: 44px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
  cursor: pointer;
}
.shell-tab:hover { color: #1A1A1A; }
.shell-tab.active {
  color: #C4704A;
  font-weight: 600;
  border-bottom-color: #C4704A;
}
.shell-tab.disabled {
  color: #cccccc;
  cursor: not-allowed;
}
.shell-tab.disabled:hover { color: #cccccc; }
:root:not(.light) .shell-tab { color: #8C8580; }
:root:not(.light) .shell-tab:hover { color: #ffffff; }
:root:not(.light) .shell-tab.disabled { color: #555; }
:root:not(.light) .shell-tab.disabled:hover { color: #555; }

/* ── Content area offset ────────────────────────────────────── */
.app-shell {
  margin-left: 56px !important;
  padding-top: 100px !important; /* 56px header + 44px subtabs */
  padding-left: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  height: 100vh !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}
/* Pages without sub-tabs (e.g. Dashboard) — collapse the 44px gap */
:root.no-subtabs .app-shell { padding-top: 56px !important; }
:root.no-subtabs .shell-subtabs { display: none !important; }

/* ── Hide legacy page-level chrome (old sidebar, topbars) ───── */
.sidebar { display: none !important; }
.topbar { display: none !important; }
.li-topbar { display: none !important; }

/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR — uniform 5px slim across all pages
   ═══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }
:root.light ::-webkit-scrollbar-thumb { background: rgba(0,0,0,.1); }
:root.light ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.2); }

/* ═══════════════════════════════════════════════════════════════
   ANALYTICS — primary button: align to accent (was: blue)
   All other pages use accent (#c2714a) for primary actions.
   report.html was using blue rgba(91,157,255) — harmonized here.
   ═══════════════════════════════════════════════════════════════ */
.rp-btn.primary {
  background: rgba(194,113,74,.14);
  border-color: rgba(194,113,74,.36);
  color: #e09060;
}
.rp-btn.primary:hover {
  background: rgba(194,113,74,.22);
  border-color: rgba(194,113,74,.52);
}

/* ═══════════════════════════════════════════════════════════════
   ANALYTICS — primary KPI value: reduce from 52px → 44px
   Still dominant, but less overwhelming in the layout.
   ═══════════════════════════════════════════════════════════════ */
.kpi-value-primary { font-size: 44px; }

/* ═══════════════════════════════════════════════════════════════
   ANALYTICS — page scroll area: tighter padding
   Matches Today/Pipeline/LinkedIn density (was 22px 28px).
   ═══════════════════════════════════════════════════════════════ */
.rp-scroll { padding: 16px 22px 22px; }

/* ═══════════════════════════════════════════════════════════════
   INBOX — left list items: slight row compaction
   Consistent with table row padding across Pipeline and LinkedIn.
   ═══════════════════════════════════════════════════════════════ */
.lead-item { padding: 8px 13px; }
.lead-item.sel { padding-left: 10px; }

/* ═══════════════════════════════════════════════════════════════
   GLOBAL — empty / loading states: consistent muted appearance
   ═══════════════════════════════════════════════════════════════ */
.empty-st,
.list-empty,
.li-empty { font-size: 12px; color: var(--muted); }

/* ═══════════════════════════════════════════════════════════════
   GLOBAL — ghost button: ensure no wrapping on short labels
   ═══════════════════════════════════════════════════════════════ */
.btn-ghost { white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════════
   PIPELINE — selected row: warm accent tint
   (Defined here for clarity; also in pipeline_crm.html CSS)
   ═══════════════════════════════════════════════════════════════ */
tbody tr.selected-row { border-left: none; }
tbody tr.selected-row td { background: rgba(194,113,74,.06) !important; }

/* ═══════════════════════════════════════════════════════════════
   GLOBAL — section labels: unified uppercase micro-text
   Used across all pages for panel/card section titles.
   ═══════════════════════════════════════════════════════════════ */
.d-stitle,
.li-sec-title,
.composer-title,
.ib-lbl,
.eb-lbl,
.kpi-label,
.li-bucket-lbl,
.rp-head h2,
.rp-head h3 {
  letter-spacing: .07em;
}

/* ═══════════════════════════════════════════════════════════════
   GLOBAL — modal backdrop blur: consistent across all modals
   ═══════════════════════════════════════════════════════════════ */
.mail-ov,
.edit-ov,
.batch-ov,
.d-ov,
.li-detail-overlay {
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
