/* ============================================================================
   TERMINAL PLATFORM — Phase 1
   Pushes the whole platform toward the workspace aesthetic:
   sharp corners · hairline borders · IBM Plex Mono numerics · amber accent.

   Mounted via header.ejs after bundle.min.css + bloomberg-terminal.css so this
   wins. Activated by `body.ix-bloomberg-tight` (default-on in header). To opt
   any page out, remove the class on body.

   Strategy: tighten the BASELINE (typography, tables, buttons, inputs, cards,
   chart wrappers, page containers) without touching page-specific custom layouts.
   Pages with strong inline styles still win; pages relying on the shared
   .card / .glass-card / generic <table> get the terminal look automatically.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700;800&display=swap');

/* ── Tokens (workspace-aligned, override bloomberg-terminal.css) ─────────── */
body.ix-bloomberg-tight {
  --bb-bg:            #0a0a09;
  --bb-bg-1:          #141413;
  --bb-bg-2:          #1a1918;
  --bb-bg-3:          #1f1e1d;
  --bb-bg-elev:       #252422;
  --bb-bg-panel:      #141413;
  --bb-bg-row:        #141413;
  --bb-bg-hover:      #1a1918;
  --bb-bg-input:      #141413;
  --bb-bg-elevated:   #252422;

  --bb-border:        #2a2927;
  --bb-border-2:      #3a3735;
  --bb-border-bright: #3a3735;
  --bb-border-focus:  #d97757;

  --bb-text:          #e8e5de;
  --bb-text-2:        #b0aba5;
  --bb-text-3:        #8a8580;
  --bb-text-4:        #5e5953;
  --bb-text-dim:      #8a8580;
  --bb-text-muted:    #a09c97;

  --bb-amber:         #d97757;
  --bb-amber-2:       #ec9b7e;
  --bb-amber-dim:     rgba(217,119,87,0.16);
  --bb-amber-line:    rgba(217,119,87,0.45);
  --bb-amber-glow:    rgba(217,119,87,0.12);
  --bb-green:         #22c55e;
  --bb-green-dim:     rgba(34,197,94,0.14);
  --bb-red:           #ef4444;
  --bb-red-dim:       rgba(239,68,68,0.14);
  --bb-blue:          #d97757;
  --bb-blue-dim:      rgba(217,119,87,0.14);

  --bb-mono:          'IBM Plex Mono', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --bb-row-h:         28px;

  background: var(--bb-bg);
  color: var(--bb-text);
  font-feature-settings: 'cv11' on, 'ss01' on;
}

/* ── Sharp corners everywhere — broad sweep, easy to opt out per element ─ */
body.ix-bloomberg-tight,
body.ix-bloomberg-tight *:not(.material-symbols-outlined):not(svg):not(svg *):not(img):not(.preserve-radius):not(.preserve-radius *) {
  /* Avoid clobbering rounded chips that depend on it for shape (use opt-out class) */
  border-radius: 0 !important;
}
/* Restore radii where it really matters: chart popups, tooltips, avatars */
body.ix-bloomberg-tight .ix-avatar,
body.ix-bloomberg-tight .fn-user-avatar,
body.ix-bloomberg-tight [data-radius="round"],
body.ix-bloomberg-tight .preserve-radius {
  border-radius: 50% !important;
}

/* ── Numerics — tabular IBM Plex Mono everywhere prices live ─────────────── */
body.ix-bloomberg-tight .num,
body.ix-bloomberg-tight .price,
body.ix-bloomberg-tight .ticker-price,
body.ix-bloomberg-tight .stat-value,
body.ix-bloomberg-tight .kpi-value,
body.ix-bloomberg-tight .metric-value,
body.ix-bloomberg-tight .value-display,
body.ix-bloomberg-tight code,
body.ix-bloomberg-tight pre,
body.ix-bloomberg-tight .tabular,
body.ix-bloomberg-tight [data-numeric] {
  font-family: var(--bb-mono) !important;
  font-variant-numeric: tabular-nums !important;
  letter-spacing: 0.01em;
}

/* ── Tables — terminal density, hairline rows, mono numerics, amber hover ─ */
body.ix-bloomberg-tight table:not(.preserve-style),
body.ix-bloomberg-tight .data-table,
body.ix-bloomberg-tight .ix-table {
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
body.ix-bloomberg-tight table:not(.preserve-style) thead th,
body.ix-bloomberg-tight .data-table thead th,
body.ix-bloomberg-tight .ix-table thead th {
  background: var(--bb-bg-1) !important;
  color: var(--bb-text-3) !important;
  font-family: var(--bb-mono) !important;
  font-size: 9.5px !important;
  font-weight: 700 !important;
  letter-spacing: 0.16em !important;
  text-transform: uppercase;
  text-align: left;
  padding: 7px 10px !important;
  border-bottom: 1px solid var(--bb-border) !important;
  border-top: 0 !important;
}
body.ix-bloomberg-tight table:not(.preserve-style) tbody td,
body.ix-bloomberg-tight .data-table tbody td,
body.ix-bloomberg-tight .ix-table tbody td {
  padding: 7px 10px !important;
  border-bottom: 1px solid var(--bb-border) !important;
  background: transparent !important;
  vertical-align: middle;
}
body.ix-bloomberg-tight table:not(.preserve-style) tbody tr:hover td,
body.ix-bloomberg-tight .data-table tbody tr:hover td,
body.ix-bloomberg-tight .ix-table tbody tr:hover td {
  background: rgba(217, 119, 87, 0.06) !important;
}
/* Numeric-leaning columns: right-align inline-style support */
body.ix-bloomberg-tight td.num,
body.ix-bloomberg-tight th.num { text-align: right !important; font-family: var(--bb-mono) !important; }

/* ── Buttons — sharp pill removed, hairline border, mono uppercase label ─ */
body.ix-bloomberg-tight .btn,
body.ix-bloomberg-tight button:not(.preserve-style):not(.material-symbols-outlined):not([class*="ixws-"]):not([class*="fn-winctrl"]):not(.fn-winswitch-row-x):not(.ix-terminal-pop-row-x):not(.ix-terminal-pop-act):not(.ixd-card-action) {
  background: transparent;
  border: 1px solid var(--bb-border-2);
  color: var(--bb-text-2);
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
body.ix-bloomberg-tight .btn:hover,
body.ix-bloomberg-tight button:not(.preserve-style):not(.material-symbols-outlined):not([class*="ixws-"]):not([class*="fn-winctrl"]):not(.fn-winswitch-row-x):not(.ix-terminal-pop-row-x):not(.ix-terminal-pop-act):hover {
  border-color: var(--bb-amber-line);
  color: var(--bb-amber);
  background: var(--bb-amber-dim);
}
body.ix-bloomberg-tight .btn-primary,
body.ix-bloomberg-tight .button-primary,
body.ix-bloomberg-tight button.primary {
  background: var(--bb-amber-dim) !important;
  color: var(--bb-amber) !important;
  border-color: var(--bb-amber-line) !important;
}
body.ix-bloomberg-tight .btn-primary:hover,
body.ix-bloomberg-tight .button-primary:hover,
body.ix-bloomberg-tight button.primary:hover {
  background: rgba(217, 119, 87, 0.28) !important;
  border-color: var(--bb-amber) !important;
  color: var(--bb-amber-2) !important;
}
body.ix-bloomberg-tight .btn-danger,
body.ix-bloomberg-tight button.danger {
  background: rgba(239, 68, 68, 0.10) !important;
  color: var(--bb-red) !important;
  border-color: rgba(239, 68, 68, 0.45) !important;
}

/* ── Inputs — sharp, hairline, amber focus glow ──────────────────────────── */
body.ix-bloomberg-tight input:not([type="checkbox"]):not([type="radio"]):not(.preserve-style),
body.ix-bloomberg-tight select:not(.preserve-style),
body.ix-bloomberg-tight textarea:not(.preserve-style) {
  background: var(--bb-bg-1) !important;
  border: 1px solid var(--bb-border) !important;
  color: var(--bb-text) !important;
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
body.ix-bloomberg-tight input:focus,
body.ix-bloomberg-tight select:focus,
body.ix-bloomberg-tight textarea:focus {
  border-color: var(--bb-amber) !important;
  box-shadow: 0 0 0 1px var(--bb-amber-dim) !important;
}
body.ix-bloomberg-tight input::placeholder,
body.ix-bloomberg-tight textarea::placeholder { color: var(--bb-text-4) !important; }

/* ── Cards / panels — drop the soft glass, sharp hairlines ───────────────── */
body.ix-bloomberg-tight .card:not(.preserve-style),
body.ix-bloomberg-tight .glass-card:not(.preserve-style),
body.ix-bloomberg-tight .panel:not(.preserve-style),
body.ix-bloomberg-tight .ix-card:not(.preserve-style),
body.ix-bloomberg-tight .bb-card,
body.ix-bloomberg-tight .stat-card,
body.ix-bloomberg-tight .metric-card {
  background: var(--bb-bg-1) !important;
  border: 1px solid var(--bb-border) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

/* ── Headings — mono, uppercase eyebrow style for section headers ───────── */
body.ix-bloomberg-tight .section-title,
body.ix-bloomberg-tight .panel-title,
body.ix-bloomberg-tight .card-title,
body.ix-bloomberg-tight h6 {
  font-family: var(--bb-mono) !important;
  font-size: 10.5px !important;
  font-weight: 700 !important;
  letter-spacing: 0.18em !important;
  text-transform: uppercase;
  color: var(--bb-text-3) !important;
}

/* ── Chips / badges — sharp, hairline, mono micro-label ──────────────────── */
body.ix-bloomberg-tight .badge,
body.ix-bloomberg-tight .chip,
body.ix-bloomberg-tight .pill,
body.ix-bloomberg-tight .tag {
  background: rgba(217, 119, 87, 0.08) !important;
  border: 1px solid rgba(217, 119, 87, 0.32) !important;
  color: var(--bb-amber) !important;
  font-family: var(--bb-mono) !important;
  font-size: 9.5px !important;
  font-weight: 700 !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase;
  padding: 2px 7px !important;
}
body.ix-bloomberg-tight .badge-success,
body.ix-bloomberg-tight .chip-success,
body.ix-bloomberg-tight .badge-up,
body.ix-bloomberg-tight .chip.up {
  background: var(--bb-green-dim) !important;
  border-color: rgba(34,197,94,0.45) !important;
  color: var(--bb-green) !important;
}
body.ix-bloomberg-tight .badge-danger,
body.ix-bloomberg-tight .chip-danger,
body.ix-bloomberg-tight .badge-down,
body.ix-bloomberg-tight .chip.dn {
  background: var(--bb-red-dim) !important;
  border-color: rgba(239,68,68,0.45) !important;
  color: var(--bb-red) !important;
}

/* ── Modals — sharp, less padded, terminal-styled header ─────────────────── */
body.ix-bloomberg-tight .modal,
body.ix-bloomberg-tight .modal-content,
body.ix-bloomberg-tight .dialog {
  background: var(--bb-bg-1) !important;
  border: 1px solid var(--bb-border-2) !important;
  box-shadow: 0 12px 60px rgba(0,0,0,0.55) !important;
}
body.ix-bloomberg-tight .modal-header,
body.ix-bloomberg-tight .dialog-header {
  background: var(--bb-bg-2) !important;
  border-bottom: 1px solid var(--bb-border) !important;
  padding: 10px 14px !important;
  font-family: var(--bb-mono) !important;
  font-size: 10.5px !important;
  font-weight: 700 !important;
  letter-spacing: 0.16em !important;
  text-transform: uppercase;
  color: var(--bb-text-3) !important;
}

/* ── Page backgrounds — kill warm-charcoal washes ───────────────────────── */
body.ix-bloomberg-tight .page-bg,
body.ix-bloomberg-tight .page-content,
body.ix-bloomberg-tight #mainContentWrapper {
  background: var(--bb-bg) !important;
}

/* ── Top nav baseline polish (Phase 2 will replace structurally) ─────────── */
body.ix-bloomberg-tight .ix-nav,
body.ix-bloomberg-tight nav.topnav,
body.ix-bloomberg-tight .topbar {
  background: rgba(10, 10, 9, 0.92) !important;
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  border-bottom: 1px solid var(--bb-border) !important;
  box-shadow: none !important;
}

/* ── Live ticker bar — already mono but tighten ──────────────────────────── */
body.ix-bloomberg-tight .live-ticker-wrapper,
body.ix-bloomberg-tight .ticker-bar {
  background: var(--bb-bg-1) !important;
  border-bottom: 1px solid var(--bb-border) !important;
  font-family: var(--bb-mono) !important;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* ── Charts — leave inner SVG alone, just tighten the wrapper ──────────── */
body.ix-bloomberg-tight .chart-wrapper,
body.ix-bloomberg-tight .chart-container,
body.ix-bloomberg-tight .chart-card {
  background: var(--bb-bg-1) !important;
  border: 1px solid var(--bb-border) !important;
  box-shadow: none !important;
}

/* ── Up / down semantic colors (override platform-wide) ──────────────────── */
body.ix-bloomberg-tight .text-success,
body.ix-bloomberg-tight .up,
body.ix-bloomberg-tight .gain,
body.ix-bloomberg-tight .positive,
body.ix-bloomberg-tight [data-trend="up"],
body.ix-bloomberg-tight [data-color="green"] { color: var(--bb-green) !important; }
body.ix-bloomberg-tight .text-danger,
body.ix-bloomberg-tight .dn,
body.ix-bloomberg-tight .loss,
body.ix-bloomberg-tight .negative,
body.ix-bloomberg-tight [data-trend="down"],
body.ix-bloomberg-tight [data-color="red"] { color: var(--bb-red) !important; }
body.ix-bloomberg-tight .text-muted,
body.ix-bloomberg-tight .muted { color: var(--bb-text-3) !important; }

/* ── Scrollbars — slim & dark to match terminal ──────────────────────────── */
body.ix-bloomberg-tight ::-webkit-scrollbar { width: 8px; height: 8px; }
body.ix-bloomberg-tight ::-webkit-scrollbar-track { background: transparent; }
body.ix-bloomberg-tight ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 0 !important;
}
body.ix-bloomberg-tight ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); }

/* ── Links — amber, no underline, dashed underline on hover ──────────────── */
body.ix-bloomberg-tight a:not(.preserve-style):not(.btn):not([class*="nav"]):not([class*="ix-"]) {
  color: var(--bb-amber);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}
body.ix-bloomberg-tight a:not(.preserve-style):not(.btn):not([class*="nav"]):not([class*="ix-"]):hover {
  color: var(--bb-amber-2);
  border-bottom-color: var(--bb-amber-line);
}

/* ── Selection — amber ──────────────────────────────────────────────────── */
body.ix-bloomberg-tight ::selection {
  background: rgba(217, 119, 87, 0.30);
  color: var(--bb-text);
}

/* ── Dividers / hairlines ──────────────────────────────────────────────── */
body.ix-bloomberg-tight hr {
  border: 0 !important;
  border-top: 1px solid var(--bb-border) !important;
  margin: 16px 0 !important;
}

/* ── Code blocks — terminal-styled ──────────────────────────────────────── */
body.ix-bloomberg-tight code {
  background: rgba(217, 119, 87, 0.10) !important;
  border: 1px solid rgba(217, 119, 87, 0.22) !important;
  color: var(--bb-amber) !important;
  font-family: var(--bb-mono) !important;
  font-size: 0.9em;
  padding: 1px 6px !important;
}
body.ix-bloomberg-tight pre {
  background: var(--bb-bg-1) !important;
  border: 1px solid var(--bb-border) !important;
  color: var(--bb-text-2) !important;
  font-family: var(--bb-mono) !important;
  padding: 12px !important;
  font-size: 11.5px;
  line-height: 1.55;
}

/* ── Nav dropdowns / mega-menus ───────────────────────────────────────── */
body.ix-bloomberg-tight .ix-mega,
body.ix-bloomberg-tight .ix-user-drop,
body.ix-bloomberg-tight .dropdown-menu {
  background: var(--bb-bg-1) !important;
  border: 1px solid var(--bb-border-2) !important;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55) !important;
  backdrop-filter: blur(8px) saturate(120%);
}

/* ── Tabs — flat underline-active ───────────────────────────────────────── */
body.ix-bloomberg-tight .tab,
body.ix-bloomberg-tight .nav-tab,
body.ix-bloomberg-tight [role="tab"] {
  background: transparent !important;
  border: 0 !important;
  border-bottom: 2px solid transparent !important;
  color: var(--bb-text-3) !important;
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 14px !important;
}
body.ix-bloomberg-tight .tab.active,
body.ix-bloomberg-tight .nav-tab.active,
body.ix-bloomberg-tight [role="tab"][aria-selected="true"] {
  color: var(--bb-amber) !important;
  border-bottom-color: var(--bb-amber) !important;
  background: transparent !important;
}

/* ── Tooltip — sharp, mono ──────────────────────────────────────────────── */
body.ix-bloomberg-tight .tooltip,
body.ix-bloomberg-tight [role="tooltip"] {
  background: var(--bb-bg-elev) !important;
  border: 1px solid var(--bb-border-2) !important;
  color: var(--bb-text) !important;
  font-family: var(--bb-mono) !important;
  font-size: 10px !important;
  letter-spacing: 0.04em;
}

/* ── Loading skeletons — flat, no shimmer ──────────────────────────────── */
body.ix-bloomberg-tight .skeleton,
body.ix-bloomberg-tight .loading-shimmer {
  background: var(--bb-bg-2) !important;
  animation: ix-pulse 1.4s ease-in-out infinite !important;
}
@keyframes ix-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ── Notification dropdown bell ──────────────────────────────────────────── */
body.ix-bloomberg-tight #notificationDropdown,
body.ix-bloomberg-tight .ix-terminal-pop {
  background: var(--bb-bg-1) !important;
  border: 1px solid var(--bb-border-2) !important;
}

/* ── Footer — mono, dim ────────────────────────────────────────────────── */
body.ix-bloomberg-tight footer:not(.preserve-style),
body.ix-bloomberg-tight .site-footer {
  background: var(--bb-bg) !important;
  border-top: 1px solid var(--bb-border) !important;
  color: var(--bb-text-3) !important;
  font-family: var(--bb-mono) !important;
  font-size: 10.5px !important;
  letter-spacing: 0.04em;
}
