/* ── Vantedge v3 theme for FundOS — the Liquid frontend's re-theme ─────────
 *
 * Loaded ONLY when platform_embed is true (host ends with vantedgeai.com —
 * see inject_platform_embed in app/__init__.py + templates/_vantedge_theme.html).
 * kela.com / stage.kela.com / DOKS hosts never load this file: zero change there.
 *
 * Strategy: override, don't rewrite. This sheet loads AFTER each base's inline
 * <style> block (and after module_styles), so at equal specificity it wins the
 * cascade. It rebinds the existing CSS-var systems (--fundos-*, --vdr-*) to the
 * Vantedge v3 "Paper + Ink + teal" tokens and restyles the Bootstrap 5.3
 * component vars. Token source: ventureinsights-v2 src/app/v3-tokens.css.
 *
 * v3 palette: paper #FBFAF7/#F5F2EC/#ECE7DD/#DDD6C7 · ink #16181F/#2C2F38/
 * #4A4E58/#6A6E78 · signal teal #0E799A (hover #0A5973, soft #E8F2F5) ·
 * ledger green #2F7F4F · warn #B5731B · bad #B23F3F.
 * Fonts: Inter (body) · Instrument Serif 400 (display) · JetBrains Mono (data).
 * Fonts are <link>-loaded in templates/_vantedge_theme.html (preconnect+swap).
 */

/* ── 1 · Token rebind — the big lever ─────────────────────────────────────
 * Every rule in fundos/base.html + style.css that reads these vars re-skins
 * instantly. Same-specificity :root, later in cascade → wins. Both systems are
 * defined here so on the bridge the legacy VDR tree themes too; on kela this
 * file never loads, so the templates' own :root values stand unchanged. */
:root {
  /* fundos system (templates/fundos/base.html) */
  --fundos-bg: #FBFAF7;
  --fundos-surface: #FFFFFF;
  --fundos-surface-alt: #F5F2EC;
  --fundos-border: #ECE7DD;
  --fundos-border-strong: #DDD6C7;
  --fundos-accent: #0E799A;
  --fundos-accent-hover: #0A5973;
  --fundos-text: #16181F;
  --fundos-text-muted: #6A6E78;
  --fundos-success: #2F7F4F;
  --fundos-warning: #B5731B;
  --fundos-danger: #B23F3F;
  --fundos-primary: #16181F;   /* copilot reads var(--fundos-primary, #0b1220) */

  /* legacy VDR system (static/css/style.css + templates/base.html) */
  --vdr-accent: #0E799A;
  --vdr-accent-hover: #0A5973;
  --vdr-navy: #16181F;          /* dark sidebar → ink-300 */
  --vdr-navy-light: #2C2F38;
  --vdr-sidebar: #16181F;

  /* v3 primitives for local use below */
  --vx-brand-soft: #E8F2F5;
  --vx-shadow-1: 0 1px 0 rgba(11,12,16,.04), 0 0 0 1px #ECE7DD;
  --vx-shadow-2: 0 1px 2px rgba(11,12,16,.06), 0 0 0 1px #ECE7DD;
  --vx-shadow-3: 0 8px 24px -8px rgba(11,12,16,.18), 0 0 0 1px #DDD6C7;
  --vx-font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --vx-font-display: "Instrument Serif", "Times New Roman", Georgia, serif;
  --vx-font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* ── 2 · Body / Bootstrap 5.3 runtime base ───────────────────────────────── */
body {
  --bs-body-bg: #FBFAF7;
  --bs-body-color: #16181F;
  --bs-border-color: #ECE7DD;
  --bs-link-color: #0E799A;
  --bs-link-hover-color: #0A5973;
  --bs-link-color-rgb: 14, 121, 154;
  --bs-link-hover-color-rgb: 10, 89, 115;
  --bs-font-sans-serif: var(--vx-font-sans);
  --bs-font-monospace: var(--vx-font-mono);
  background: #FBFAF7;
  color: #16181F;
  font-family: var(--vx-font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── 3 · Buttons (outrank button-consistency.css, which loads earlier) ────── */
.btn { --bs-btn-border-radius: 8px; }
.btn-primary {
  --bs-btn-bg: #0E799A;
  --bs-btn-border-color: #0E799A;
  --bs-btn-hover-bg: #0A5973;
  --bs-btn-hover-border-color: #0A5973;
  --bs-btn-active-bg: #073F52;
  --bs-btn-active-border-color: #073F52;
  --bs-btn-disabled-bg: #0E799A;
  --bs-btn-disabled-border-color: #0E799A;
  font-weight: 500;
}
.btn-success {
  --bs-btn-bg: #2F7F4F; --bs-btn-border-color: #2F7F4F;
  --bs-btn-hover-bg: #1F5A37; --bs-btn-hover-border-color: #1F5A37;
}
.btn-danger {
  --bs-btn-bg: #B23F3F; --bs-btn-border-color: #B23F3F;
  --bs-btn-hover-bg: #7A2A2A; --bs-btn-hover-border-color: #7A2A2A;
}
.btn-warning {
  --bs-btn-bg: #B5731B; --bs-btn-border-color: #B5731B; --bs-btn-color: #fff;
  --bs-btn-hover-bg: #6F4A12; --bs-btn-hover-border-color: #6F4A12; --bs-btn-hover-color: #fff;
}
.btn-dark { --bs-btn-bg: #16181F; --bs-btn-border-color: #16181F; --bs-btn-hover-bg: #2C2F38; --bs-btn-hover-border-color: #2C2F38; }
.btn-outline-primary {
  --bs-btn-color: #0E799A; --bs-btn-border-color: #0E799A;
  --bs-btn-hover-bg: #E8F2F5; --bs-btn-hover-color: #0A5973; --bs-btn-hover-border-color: #0A5973;
  --bs-btn-active-bg: #0E799A; --bs-btn-active-border-color: #0E799A;
}
.btn-outline-danger {
  --bs-btn-color: #B23F3F; --bs-btn-border-color: #B23F3F;
  --bs-btn-hover-bg: #B23F3F; --bs-btn-hover-border-color: #B23F3F; --bs-btn-hover-color: #fff;
}
.btn-outline-secondary {
  --bs-btn-color: #4A4E58;
  --bs-btn-border-color: #DDD6C7;
  --bs-btn-hover-color: #16181F;
  --bs-btn-hover-bg: #F5F2EC;
  --bs-btn-hover-border-color: #DDD6C7;
}
.btn:focus-visible { outline: 2px solid #0E799A; outline-offset: 2px; box-shadow: none !important; }

/* ── 4 · Semantic utilities (badges / text / bg) ─────────────────────────── */
.badge.bg-primary, .text-bg-primary { background-color: #0E799A !important; }
.badge.bg-success, .text-bg-success { background-color: #2F7F4F !important; }
.badge.bg-danger,  .text-bg-danger  { background-color: #B23F3F !important; }
.badge.bg-warning, .text-bg-warning { background-color: #B5731B !important; color: #fff !important; }
.badge.bg-info,    .text-bg-info    { background-color: #5BA8BF !important; color: #fff !important; }
.text-primary { color: #0E799A !important; }
.text-success { color: #2F7F4F !important; }
.text-danger  { color: #B23F3F !important; }
.text-warning { color: #B5731B !important; }
.bg-primary   { background-color: #0E799A !important; }
.link-primary { color: #0E799A !important; }

/* ── 5 · Tables — hairline paper borders, warm hover, tabular numerals ────── */
.table {
  --bs-table-border-color: #ECE7DD;
  --bs-table-striped-bg: rgba(245, 242, 236, .45);
  --bs-table-hover-bg: rgba(245, 242, 236, .55);
  --bs-table-color: #16181F;
}
.table > thead { border-bottom: 1px solid #DDD6C7; }
.table > :not(caption) > * > * { border-bottom-color: #ECE7DD; }
td, th { font-variant-numeric: tabular-nums; font-feature-settings: "tnum", "lnum"; }

/* ── 6 · Forms — paper borders, teal focus ring ──────────────────────────── */
.form-control, .form-select {
  border-color: #DDD6C7;
  border-radius: 8px;
  color: #16181F;
}
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: #0E799A;
  box-shadow: 0 0 0 3px rgba(14, 121, 154, .28);
}
.form-check-input:checked { background-color: #0E799A; border-color: #0E799A; }
.input-group-text { background: #F5F2EC; border-color: #DDD6C7; color: #4A4E58; }

/* ── 7 · Cards / modals / dropdowns / alerts / tabs ──────────────────────── */
.card { border-color: #DDD6C7; border-radius: 12px; box-shadow: var(--vx-shadow-2); }
.modal-content { border-radius: 12px; border: 1px solid #DDD6C7; box-shadow: var(--vx-shadow-3); }
.dropdown-menu { border-radius: 8px; border: 1px solid #DDD6C7; box-shadow: var(--vx-shadow-3); }
.dropdown-item.active, .dropdown-item:active { background-color: #E8F2F5 !important; color: #0A5973 !important; }
.dropdown-item:focus-visible { background-color: #E8F2F5; outline: none; }
.alert { border-radius: 8px; }
.alert-info    { --bs-alert-color: #0A5973; --bs-alert-bg: #E8F2F5; --bs-alert-border-color: #C7E0E7; }
.alert-success { --bs-alert-color: #1F5A37; --bs-alert-bg: #DDEFE0; --bs-alert-border-color: #BFDFC8; }
.alert-warning { --bs-alert-color: #6F4A12; --bs-alert-bg: #FAEFDC; --bs-alert-border-color: #EFD9B4; }
.alert-danger  { --bs-alert-color: #7A2A2A; --bs-alert-bg: #F5DEDE; --bs-alert-border-color: #E8C2C2; }
.nav-tabs .nav-link { color: #4A4E58; }
.nav-tabs .nav-link.active {
  color: #16181F; font-weight: 500; background: transparent;
  border-color: transparent transparent #16181F; border-bottom-width: 2px;
}
.nav-pills .nav-link.active { background-color: #0E799A; }
.progress-bar { background-color: #0E799A; }

/* selection — matches the #4f83e0 !important rules inlined in both bases */
::selection      { background: #0E799A !important; color: #fff !important; }
::-moz-selection { background: #0E799A !important; color: #fff !important; }

/* ── 8 · Typography — the v3 voice ───────────────────────────────────────── */
h1, h2, .fundos-page-title, .display-1, .display-2, .display-3, .display-4, .display-5, .display-6 {
  font-family: var(--vx-font-display);
  font-weight: 400;
  letter-spacing: -0.015em;
  color: #16181F;
}
h1 .bi, h2 .bi { font-size: .72em; vertical-align: .06em; }   /* icons beside serif titles stay proportionate */
h3, h4, h5, h6 { color: #2C2F38; }

/* eyebrow labels */
.fundos-subnav-label, .fundos-user-menu .dropdown-header, .sidebar-section-label, .kpi-label {
  letter-spacing: 0.08em;
  color: #6A6E78;
  font-weight: 500;
}

/* KPI / stat hero values → Inter tabular (v3: heroes are sans-tabular, not mono;
   mono is reserved for dense table data + code, which FundOS already marks inline) */
.kpi-value, .stat-value, .metric-value {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.fin-number, code, kbd, pre { font-family: var(--vx-font-mono); font-variant-numeric: tabular-nums; }
.kpi-card { border: 1px solid #DDD6C7; border-radius: 12px; background: #FFFFFF; box-shadow: var(--vx-shadow-2); }

/* ── 9 · FundOS chrome (topbar / subnav / cards / chips) ─────────────────── */
.fundos-topbar { background: #FFFFFF; border-bottom: 1px solid #ECE7DD; }
.fundos-module-link:hover { background: #F5F2EC; }
.fundos-module-link.active { background: #16181F; color: #fff; }      /* ink active, not teal — v3 */
.fundos-btn-invite { background: #0E799A; border-color: #0E799A; border-radius: 8px; }
.fundos-btn-invite:hover { background: #0A5973; }
.fundos-btn-exit { border-radius: 8px; }
.fundos-btn-exit:hover { color: #16181F; border-color: #0E799A; }
.fundos-user-avatar { background: #DDD6C7; color: #16181F; }          /* kill blue→purple gradient */
.fundos-user-menu { border-radius: 8px; box-shadow: var(--vx-shadow-3); }
.fundos-user-menu .dropdown-item:hover { background: #F5F2EC; }
.fundos-user-menu .dropdown-item.active,
.fundos-user-menu .dropdown-item:active { background: #E8F2F5 !important; color: #0A5973 !important; }
.fundos-founder-link { color: #5BA8BF; }
.fundos-founder-link:hover { background: #E8F2F5; color: #0A5973; }

.fundos-subnav { background: #FFFFFF; border-right: 1px solid #ECE7DD; }
.fundos-subnav-item:hover { background: #F5F2EC; color: #16181F; }
.fundos-subnav-item.active { background: #E8F2F5; color: #0A5973; font-weight: 500; }   /* v3 rail-kid active */

.fundos-card { border-radius: 12px; border-color: #DDD6C7; box-shadow: var(--vx-shadow-2); }
.fundos-breadcrumb .current { color: #16181F; }
.fundos-breadcrumb a:hover { color: #0E799A; }

.fundos-flash { border-radius: 8px; }
.fundos-flash.info    { background: #E8F2F5; border-color: #0E799A; color: #0A5973; }
.fundos-flash.success { background: #DDEFE0; border-color: #2F7F4F; color: #1F5A37; }
.fundos-flash.warning { background: #FAEFDC; border-color: #B5731B; color: #6F4A12; }
.fundos-flash.danger  { background: #F5DEDE; border-color: #B23F3F; color: #7A2A2A; }

.badge-kela { background: #E8F2F5; color: #0A5973; }
.badge-byod { background: #DDEFE0; color: #1F5A37; }
.fundos-credit-chip { border-radius: 999px; }
.fundos-credit-chip.credit-ok    { background: #DDEFE0; border-color: #BFDFC8; color: #1F5A37; }
.fundos-credit-chip.credit-low   { background: #FAEFDC; border-color: #EFD9B4; color: #6F4A12; }
.fundos-credit-chip.credit-empty { background: #F5DEDE; border-color: #E8C2C2; color: #7A2A2A; }

/* ── 10 · Legacy VDR layout (templates/base.html — data rooms, admin, help) ── */
#sidebar { background: #16181F !important; }                          /* ink-300; beats branding inline */
#sidebar .nav-link { color: #C9CDD4; }
#sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #FBFAF7; }
#sidebar .nav-pills .nav-link.active { background-color: #0E799A !important; }
.topbar { background: #FFFFFF; border-bottom: 1px solid #ECE7DD; }
.breadcrumb-item.active { color: #16181F; }
.user-avatar { background: #DDD6C7 !important; color: #16181F !important; }

/* ── 11 · Copilot sidebar + command palette accents ──────────────────────── */
#copilot-toggle, #copilot-send { background: #16181F; }              /* ink — fallback was #0b1220 */
#copilot-textarea:focus { border-color: #0E799A; }
#copilot-resize:hover, #copilot-resize.dragging { background: rgba(14,121,154,.25); }
#copilot-messages .cp-citations a { color: #0E799A; }
#copilot-messages .cp-msg-assistant .cp-msg-body { background: #F5F2EC; border-radius: 8px; }
#copilot-messages .cp-msg-user { color: #16181F; }

/* ── 12 · Scrollbars + global focus (quiet, v3) ──────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #DDD6C7; border-radius: 999px; border: 2px solid #FBFAF7; }
::-webkit-scrollbar-track { background: transparent; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 2px solid #0E799A; outline-offset: 2px; }
