/*
 * SOVRENAI UNIVERSAL DESIGN STANDARD v1.3
 * Single source of truth for all surfaces.
 * Light only. White always. Color on action only.
 * Import this file FIRST in every HTML page.
 */

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

:root {

  /* ── BACKGROUNDS (LIGHT THEME — v1.3) ── */
  --bg:            #FAFAFA;
  --white:         #FFFFFF;
  --surface:       #F5F5F5;
  --overlay:       #EEEEEE;

  /* ── TEXT ── */
  --text:          #111111;
  --muted:         #666666;
  --placeholder:   #999999;
  --disabled:      #CCCCCC;

  /* ── BORDERS ── */
  --border:        rgba(0, 0, 0, 0.08);
  --border-light:  rgba(0, 0, 0, 0.04);

  /* ── ACTION COLORS ── */
  --accent:        #2563EB;
  --accent-hover:  #1D4ED8;
  --accent-light:  rgba(37, 99, 235, 0.08);

  --green:         #16A34A;
  --green-hover:   #15803D;
  --green-bg:      rgba(22, 163, 74, 0.08);
  --green-light:   rgba(22, 163, 74, 0.04);

  --red:           #DC2626;
  --red-hover:     #B91C1C;
  --red-bg:        rgba(220, 38, 38, 0.08);
  --red-light:     rgba(220, 38, 38, 0.04);

  --yellow:        #D97706;
  --yellow-bg:     rgba(217, 119, 6, 0.08);
  --yellow-light:  rgba(217, 119, 6, 0.04);

  /* ── TIER COLORS — HIDDEN BY DEFAULT ── */
  --t0:   #64748B;
  --t1:   #0EA5E9;
  --t2:   #22C55E;
  --t3:   #3B82F6;
  --t4:   #A855F7;
  --t5:   #F59E0B;
  --t6:   #6366F1;
  --t7:   #EC4899;
  --t8:   #EF4444;
  --t9:   #94A3B8;
  --t10:  #14B8A6;
  --t11:  #F97316;
  --t12:  #78716C;

  /* ── TYPOGRAPHY ── */
  --font-ui:   'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-doc:  Georgia, 'Times New Roman', serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* ── SPACING ── */
  --sp-1:   4px;
  --sp-2:   8px;
  --sp-3:   12px;
  --sp-4:   16px;
  --sp-5:   20px;
  --sp-6:   24px;
  --sp-8:   32px;
  --sp-10:  40px;
  --sp-12:  48px;
  --sp-16:  64px;

  /* ── RADIUS ── */
  --r-sm:   4px;
  --r-md:   8px;
  --r-lg:   12px;
  --r-xl:   16px;
  --r-full: 9999px;

  /* ── SHADOWS ── */
  --sh-sm:    0 1px 2px rgba(0,0,0,0.05);
  --sh-md:    0 4px 6px rgba(0,0,0,0.07);
  --sh-lg:    0 10px 15px rgba(0,0,0,0.08);
  --sh-focus: 0 0 0 3px rgba(37,99,235,0.18);

  /* ── LAYOUT ── */
  --topbar-h:      48px;
  --sidebar-sm:    220px;
  --sidebar-lg:    280px;
  --panel-pad:     24px;
  --panel-min:     280px;
}

/* ════════════════════════════════════
   BASE RESET
   ════════════════════════════════════ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Light theme is the default (v1.3) */

/* ════════════════════════════════════
   TECHNICAL ELEMENTS — HIDDEN DEFAULT
   ════════════════════════════════════ */

.tier-badge,
.tier-label,
.tier-color,
.barcode-id,
.integrity-score,
.confidence-score,
.domain-label,
.bond-count,
.token-manifest,
.pipeline-timing,
.gate-rate,
.entropy-value,
.epistemic-gap,
.session-stats,
.raw-json,
.signature-hash,
.technical-only {
  display: none !important;
}

/* ════════════════════════════════════
   TECHNICAL MODE — REVEALED
   body.technical-mode enables all
   ════════════════════════════════════ */

.technical-mode .tier-badge,
.technical-mode .tier-label,
.technical-mode .tier-color,
.technical-mode .barcode-id,
.technical-mode .integrity-score,
.technical-mode .confidence-score,
.technical-mode .domain-label,
.technical-mode .bond-count,
.technical-mode .token-manifest,
.technical-mode .pipeline-timing,
.technical-mode .gate-rate,
.technical-mode .entropy-value,
.technical-mode .epistemic-gap,
.technical-mode .session-stats,
.technical-mode .raw-json,
.technical-mode .signature-hash,
.technical-mode .technical-only {
  display: inline-flex !important;
}

/* ════════════════════════════════════
   TOPBAR — UNIVERSAL
   ════════════════════════════════════ */

.sovren-topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.sovren-brand {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.sovren-brand-sub {
  color: var(--muted);
  font-weight: 400;
  margin-left: var(--sp-2);
  font-size: 13px;
}

.sovren-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex: 1;
}

.sovren-nav-btn {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: none;
  padding: 6px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.sovren-nav-btn:hover {
  background: var(--overlay);
}

.sovren-nav-btn.active {
  color: var(--accent);
  background: var(--accent-light);
}

.sovren-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.sovren-status {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

/* ════════════════════════════════════
   SIDEBAR — UNIVERSAL
   ════════════════════════════════════ */

.sovren-sidebar {
  width: var(--sidebar-sm);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  height: 100%;
}

.sovren-sidebar-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
}

.sovren-sidebar-item {
  display: flex;
  flex-direction: column;
  padding: var(--sp-2) var(--sp-4);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s;
  text-decoration: none;
  color: var(--text);
}

.sovren-sidebar-item:hover {
  background: var(--overlay);
}

.sovren-sidebar-item.active {
  background: var(--accent-light);
  border-left-color: var(--accent);
}

.sovren-sidebar-item.active .sovren-sidebar-title {
  color: var(--accent);
}

.sovren-sidebar-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.sovren-sidebar-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* ════════════════════════════════════
   BUTTONS — UNIVERSAL
   ════════════════════════════════════ */

.btn {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--r-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--sh-focus);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}
.btn-secondary:hover:not(:disabled) { background: var(--overlay); }

.btn-approve {
  background: var(--green);
  color: #FFFFFF;
}
.btn-approve:hover:not(:disabled) { background: var(--green-hover); }

.btn-deny {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  font-weight: 600;
}
.btn-deny:hover:not(:disabled) { background: var(--red-bg); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  padding: 6px 10px;
}
.btn-ghost:hover:not(:disabled) { background: var(--overlay); color: var(--text); }

.btn-sm { font-size: 12px; padding: 5px 10px; }

/* ════════════════════════════════════
   INPUTS — UNIVERSAL
   ════════════════════════════════════ */

.sovren-input,
.sovren-textarea,
.sovren-select {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 12px;
  width: 100%;
  transition: border-color 0.1s, box-shadow 0.1s;
  outline: none;
  line-height: 1.5;
}

.sovren-input::placeholder,
.sovren-textarea::placeholder {
  color: var(--placeholder);
}

.sovren-input:focus,
.sovren-textarea:focus,
.sovren-select:focus {
  border-color: var(--accent);
  box-shadow: var(--sh-focus);
}

.sovren-textarea {
  resize: vertical;
  min-height: 80px;
}

/* ════════════════════════════════════
   STATUS DOTS — UNIVERSAL
   ════════════════════════════════════ */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  flex-shrink: 0;
  display: inline-block;
}

.status-dot.connected,
.status-dot.ok    { background: var(--green); }
.status-dot.disconnected,
.status-dot.err   { background: var(--red); }
.status-dot.pending  { background: var(--yellow); }
.status-dot.processing {
  background: var(--accent);
  animation: sovren-pulse 1.5s ease infinite;
}

@keyframes sovren-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ════════════════════════════════════
   CARDS — UNIVERSAL
   ════════════════════════════════════ */

.sovren-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  transition: box-shadow 0.15s;
}

.sovren-card:hover { box-shadow: var(--sh-sm); }
.sovren-card-lg { padding: var(--sp-6); }

/* ════════════════════════════════════
   DIFF BLOCKS — DOCUMENT SURFACES
   ════════════════════════════════════ */

.sovren-diff {
  padding: 12px 16px;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  margin: var(--sp-2) 0;
  font-family: var(--font-doc);
  font-size: 16px;
  line-height: 1.75;
}

.sovren-diff.remove {
  background: var(--red-bg);
  border-left: 3px solid var(--red);
  color: var(--red);
}

.sovren-diff.add {
  background: var(--green-bg);
  border-left: 3px solid var(--green);
  color: var(--green);
}

.sovren-diff.insert {
  background: var(--yellow-bg);
  border-left: 3px solid var(--yellow);
  color: var(--yellow);
}

.sovren-diff-controls {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

/* ════════════════════════════════════
   TOOLTIP — UNIVERSAL
   ════════════════════════════════════ */

[data-tooltip] {
  position: relative;
  cursor: default;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #FFFFFF;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 6px;
  max-width: 280px;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 1000;
  box-shadow: var(--sh-md);
}

[data-tooltip]:hover::after { opacity: 1; }

/* ════════════════════════════════════
   MODAL — UNIVERSAL
   ════════════════════════════════════ */

.sovren-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.sovren-modal {
  background: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  padding: var(--sp-6);
  width: 100%;
  max-width: 560px;
  position: relative;
}

.sovren-modal-close {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
}

/* ════════════════════════════════════
   REASONING AREA — UNIVERSAL
   ════════════════════════════════════ */

.sovren-reasoning {
  background: var(--overlay);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-4);
  max-height: 200px;
  overflow-y: auto;
  transition: max-height 0.3s ease;
}

.sovren-reasoning.collapsed {
  max-height: 28px;
  overflow: hidden;
}

.sovren-reasoning-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--placeholder);
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.sovren-reasoning-content {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.sovren-reasoning-line {
  display: block;
  padding: 1px 0;
}

/* ════════════════════════════════════
   DOCUMENT PROSE — UNIVERSAL
   ════════════════════════════════════ */

.sovren-prose {
  font-family: var(--font-doc);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  max-width: 680px;
}

.sovren-prose h1 { font-size: 24px; font-weight: 700; margin-bottom: var(--sp-4); letter-spacing: -0.02em; }
.sovren-prose h2 { font-size: 20px; font-weight: 700; margin-top: var(--sp-6); margin-bottom: var(--sp-3); }
.sovren-prose h3 { font-size: 17px; font-weight: 600; margin-top: var(--sp-5); margin-bottom: var(--sp-3); }
.sovren-prose p  { margin-bottom: var(--sp-4); }

/* ════════════════════════════════════
   SCROLLBARS — UNIVERSAL
   ════════════════════════════════════ */

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ════════════════════════════════════
   SECTION HEADERS — UNIVERSAL
   ════════════════════════════════════ */

.sovren-section-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-2);
}

/* ════════════════════════════════════
   EMPTY STATES — UNIVERSAL
   ════════════════════════════════════ */

.sovren-empty {
  color: var(--placeholder);
  font-size: 14px;
  text-align: center;
  padding: var(--sp-10) var(--sp-6);
  line-height: 1.6;
}

/* ════════════════════════════════════
   TECHNICAL MODE TIER COLORS
   Applied only when body.technical-mode
   ════════════════════════════════════ */

.technical-mode [data-tier="0"]  { color: var(--t0); }
.technical-mode [data-tier="1"]  { color: var(--t1); }
.technical-mode [data-tier="2"]  { color: var(--t2); }
.technical-mode [data-tier="3"]  { color: var(--t3); }
.technical-mode [data-tier="4"]  { color: var(--t4); }
.technical-mode [data-tier="5"]  { color: var(--t5); }
.technical-mode [data-tier="6"]  { color: var(--t6); }
.technical-mode [data-tier="7"]  { color: var(--t7); }
.technical-mode [data-tier="8"]  { color: var(--t8); }
.technical-mode [data-tier="9"]  { color: var(--t9); }
.technical-mode [data-tier="10"] { color: var(--t10); }
.technical-mode [data-tier="11"] { color: var(--t11); }
.technical-mode [data-tier="12"] { color: var(--t12); }

/* ════════════════════════════════════
   TIER BADGE STYLING (technical mode)
   ════════════════════════════════════ */

.technical-mode .tier-badge {
  font-size: 10px;
  font-family: var(--font-ui);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
}

/* ── Retry button (chat error recovery) ── */
.retry-btn {
  display: inline-block;
  margin: 8px 0 0 0;
  padding: 6px 16px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--accent);
  background: var(--white);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.retry-btn:hover {
  background: var(--accent);
  color: var(--white);
}

/* ── Model routing badge ── */
.model-routing-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  margin-left: 8px;
  padding: 2px 8px;
  background: var(--overlay);
  border-radius: var(--r-sm);
  animation: fadeRoutingBadge 5s ease-in-out forwards;
}
@keyframes fadeRoutingBadge {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Delta Disclosure: tier badges + hover tooltips (DOC-D53821C24F25) ── */
.tier-badge-inline {
  display: none;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}
.show-analysis .tier-badge-inline { display: inline; }

/* Shared analysis toggle component (DOC-3786ABD05408 Phase 1) */
.analysis-badge, .analysis-conf-dot { display: none; }
.show-analysis .analysis-badge, .show-analysis .analysis-conf-dot { display: inline; }
/* BARCODE 31: MINI barcode visible only in analysis mode (DOC-3EE3C8419301) */
.bc-mini-tag { display: none !important; }
.show-analysis .bc-mini-tag { display: inline !important; }
[data-tier-label] { position: relative; }
.show-analysis [data-tier-label]:hover::after {
  content: attr(data-tier-label);
  position: absolute; bottom: 100%; left: 0;
  background: var(--text, #111); color: #fff;
  padding: 3px 8px; border-radius: 4px;
  font-size: 11px; white-space: nowrap; z-index: 100;
  pointer-events: none;
}

.tier-hover { position: relative; }
.tier-hover:hover::after {
  content: attr(data-tier-label);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: var(--white, #fff);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text, #111);
  white-space: nowrap;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  pointer-events: none;
}
