/* ============================================================
   LouieAuto — Award Design System
   Red Dot / Webby level polish layer.
   Loads AFTER design-tokens.css and platform.css.
   ============================================================ */

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

/* ── Extended color tokens ── */
:root {
  /* Teal — the modern primary (used for CTAs, Louie's pick) */
  --teal:        #8b6a2a;
  --teal-light:  #a5795a;
  --teal-dark:   #0d6b63;
  --teal-bg:     rgba(139,106,42,0.08);
  --teal-border: rgba(139,106,42,0.25);

  /* Override legacy gold variable to teal */
  --color-gold:        #8b6a2a;
  --color-gold-border: rgba(139,106,42,0.3);

  /* Amber — heads up, watch items */
  --amber:       #D97706;
  --amber-light: #fbbf24;
  --amber-bg:    rgba(217,119,6,0.09);
  --amber-border:rgba(217,119,6,0.25);

  /* Emerald — wins, approvals */
  --emerald:     #059669;
  --emerald-bg:  rgba(5,150,105,0.09);

  /* Crimson — fires only */
  --crimson:     #DC2626;
  --crimson-bg:  rgba(220,38,38,0.09);

  /* Near-white bg — easier on eyes for long shifts */
  --surface-app: #F8FAFC;

  /* Dark palette — required by platform.css badges */
  --color-dark-1: #0d1b2e;
  --color-dark-2: #ffffff;

  /* Monospace data font */
  --font-data: 'IBM Plex Mono', 'JetBrains Mono', monospace;
  --font-display: 'Inter Tight', 'Inter', -apple-system, sans-serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Global font enforcement ── */
body,
button, input, select, textarea,
.sidebar, .main-content, .overlay,
[class*="-overlay"], [class*="-dashboard"],
[class*="-modal"], [class*="-panel"] {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  line-height: 1.5;
}

/* Headings: Inter Tight for impact */
h1, h2, h3, .page-title, .overlay-title,
[class*="-title"]:not([class*="car-"]):not([class*="vehicle-"]) {
  font-family: 'Inter Tight', 'Inter', -apple-system, sans-serif !important;
  line-height: 1.2;
}

/* Data values: IBM Plex Mono for precision */
[class*="-val"], [class*="-stat"], [class*="-kpi"],
[class*="-amount"], [class*="-count"], [class*="-pct"],
[class*="-score"], [class*="-rate"] {
  font-family: 'IBM Plex Mono', monospace !important;
}

/* Code and textarea monospace contexts */
code, pre, kbd, samp,
textarea[style*="monospace"],
textarea[style*="Mono"] {
  font-family: 'IBM Plex Mono', 'Fira Code', Consolas, monospace !important;
}

/* ── Dark mode token overrides ── */
html.dark-mode {
  --surface-app: #0f172a;
  --bg-white: #1e293b;
  --border-light: rgba(255,255,255,0.08);
  --ink: #f1f5f9;
  --text-secondary: #94a3b8;
}

/* ── Typography upgrade — data values use mono ── */
.hkpi2-val,
.hkpi-val,
[class*="kpi-val"],
[class*="stat-val"],
.dc-approval-pct,
.dc-stat-val {
  font-family: var(--font-data) !important;
  letter-spacing: -0.02em;
}

.hkpi2-label,
.hkpi-label,
[class*="kpi-label"],
[class*="-label"],
.hd-card-title {
  font-family: var(--font-ui) !important;
}

/* ── Micro-animations ── */
@keyframes louie-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes louie-slide-right {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes louie-pop {
  0%   { transform: scale(0.92); opacity: 0; }
  60%  { transform: scale(1.03); }
  100% { transform: scale(1);    opacity: 1; }
}
@keyframes louie-pulse-red {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
@keyframes louie-number-count {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes louie-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
@keyframes louie-bar-fill {
  from { width: 0; }
}

/* ── KPI cards — upgrade hover & entrance ── */
.hkpi2 {
  animation: louie-fade-in 0.35s ease both;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease !important;
}
.hkpi2:hover {
  border-color: var(--teal-light) !important;
  box-shadow: 0 8px 24px rgba(139,106,42,0.12), 0 2px 8px rgba(0,0,0,0.06) !important;
}
.hkpi2:nth-child(1) { animation-delay: 0.05s; }
.hkpi2:nth-child(2) { animation-delay: 0.10s; }
.hkpi2:nth-child(3) { animation-delay: 0.15s; }
.hkpi2:nth-child(4) { animation-delay: 0.20s; }

/* ── Quick launch buttons ── */
.ql-btn {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.2s ease !important;
}
.ql-btn:hover {
  border-color: var(--teal-light) !important;
  box-shadow: 0 6px 20px rgba(139,106,42,0.15) !important;
}
.ql-btn:nth-child(1) { animation: louie-fade-in 0.3s 0.1s ease both; }
.ql-btn:nth-child(2) { animation: louie-fade-in 0.3s 0.15s ease both; }
.ql-btn:nth-child(3) { animation: louie-fade-in 0.3s 0.2s ease both; }
.ql-btn:nth-child(4) { animation: louie-fade-in 0.3s 0.25s ease both; }
.ql-btn:nth-child(5) { animation: louie-fade-in 0.3s 0.3s ease both; }
.ql-btn:nth-child(6) { animation: louie-fade-in 0.3s 0.35s ease both; }
.ql-btn:nth-child(7) { animation: louie-fade-in 0.3s 0.4s ease both; }
.ql-btn:nth-child(8) { animation: louie-fade-in 0.3s 0.45s ease both; }

/* ── Sidebar upgrades ── */
.nav-dept-header {
  transition: background 0.15s ease, color 0.15s ease !important;
}
.inv-trigger {
  transition: background 0.15s ease, color 0.12s ease, transform 0.12s ease !important;
}
.inv-trigger:hover {
  transform: translateX(2px) !important;
}
.nav-dept-items {
  animation: louie-slide-right 0.2s ease both;
}

/* ── Role pills (injected by role-views.js) ── */
#role-selector {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.role-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  letter-spacing: 0.04em;
}
.role-pill:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }
.role-pill.active { background: var(--teal); color: #ffffff; border-color: var(--teal); }

/* ── Today's priorities widget ── */
#louie-priorities {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
#louie-priorities .priority-title {
  font-size: 9px;
  font-weight: 700;
  color: #c9a84c;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 8px;
  font-family: var(--font-ui);
}
.priority-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.priority-item:last-child { border-bottom: none; }
.priority-item .p-icon { font-size: 12px; flex-shrink: 0; margin-top: 1px; }
.priority-item .p-text { font-size: 11px; color: #b0bccb; line-height: 1.4; font-family: var(--font-ui); }
.priority-item.urgent .p-text { color: #fca5a5; }

/* ── Header action buttons (search, dark mode) ── */
#header-search-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #94a3b8;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-ui);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
#header-search-btn:hover { background: rgba(255,255,255,0.12); color: #e2e8f0; }
#header-search-btn kbd {
  font-family: var(--font-data);
  font-size: 9px;
  background: rgba(255,255,255,0.1);
  padding: 1px 5px;
  border-radius: 3px;
  color: #64748b;
}

#dark-mode-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: #94a3b8;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
#dark-mode-btn:hover { background: rgba(255,255,255,0.1); color: #e2e8f0; }

/* ── Deal Coach panel styles ── */
#desk-louie {
  animation: louie-fade-in 0.4s ease both;
}
.dc-section {
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.dc-section:last-child { border-bottom: none; }
.dc-label {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  font-family: var(--font-ui);
}
.dc-approval-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.dc-approval-bar-wrap {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  overflow: hidden;
}
.dc-approval-bar {
  height: 100%;
  background: linear-gradient(90deg, #16a34a, #22c55e);
  border-radius: 4px;
  transition: width 1.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  width: 0%;
}
.dc-approval-pct {
  font-family: var(--font-data);
  font-size: 20px;
  font-weight: 700;
  color: #22c55e;
  min-width: 48px;
  text-align: right;
}
.dc-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}
.dc-stat {
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 10px 12px;
}
.dc-stat-label {
  font-size: 9px;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
  font-family: var(--font-ui);
}
.dc-stat-val {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  font-family: var(--font-data);
}
.dc-voice {
  background: rgba(201,168,76,0.1);
  border-left: 3px solid #c9a84c;
  border-radius: 0 8px 8px 0;
  padding: 12px 14px !important;
}
.dc-voice-text {
  font-size: 13px;
  line-height: 1.7;
  color: #e2e8f0;
  font-family: var(--font-ui);
}
.dc-fi-title,
.dc-obj-title {
  font-size: 9px;
  font-weight: 700;
  color: #c9a84c;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  font-family: var(--font-ui);
}
.dc-fi-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #d1d5db;
  line-height: 1.5;
  font-family: var(--font-ui);
}
.dc-obj-item {
  margin-bottom: 8px;
}
.dc-obj-q {
  font-size: 11px;
  color: #fca5a5;
  font-weight: 600;
  margin-bottom: 2px;
  font-family: var(--font-ui);
}
.dc-obj-a {
  font-size: 12px;
  color: #d1d5db;
  line-height: 1.5;
  padding-left: 10px;
  border-left: 2px solid rgba(201,168,76,0.3);
  font-family: var(--font-ui);
}
.dc-sequence {
  margin-top: 4px;
}
.dc-sequence summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  padding: 8px 0;
  list-style: none;
  font-family: var(--font-ui);
  user-select: none;
}
.dc-sequence summary:hover { color: #c9a84c; }
.dc-step {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.dc-step:last-child { border-bottom: none; }
.dc-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(201,168,76,0.2);
  color: #c9a84c;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-data);
}
.dc-step-body {
  flex: 1;
}
.dc-step-title {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 3px;
  font-family: var(--font-ui);
}
.dc-step-script {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.5;
  font-style: italic;
  font-family: var(--font-ui);
}
.dc-step-timing {
  font-size: 10px;
  color: #64748b;
  margin-top: 3px;
  font-family: var(--font-data);
}

/* ── Omnisearch overlay ── */
#louie-omnisearch-overlay {
  font-family: var(--font-ui) !important;
}

/* ── Morning Brief v2 overlay ── */
#louie-morning-brief-overlay {
  font-family: var(--font-ui) !important;
}

/* ── Onboarding overlay ── */
#louie-onboarding-overlay {
  font-family: var(--font-ui) !important;
}

/* ── F&I Compliance header fix ── */
#fi-compliance-overlay > div:first-child {
  background: #0d1b2e !important;
  border-bottom: 2px solid #8b6a2a !important;
}
#fi-compliance-overlay span[style*="font-size:18px"] {
  color: #ffffff !important;
}

/* ── Overlay entrance animation ── */
[id$="-overlay"]:not([style*="display:none"]):not([style*="display: none"]) > div:first-child,
[id$="-overlay"].active > div:first-child {
  animation: louie-fade-in 0.25s ease both;
}

/* ── Role-specific KPI visibility ── */
.role-hidden { opacity: 0.35; filter: grayscale(0.6); transition: opacity 0.3s, filter 0.3s; }
.role-highlight { border-color: var(--teal) !important; box-shadow: 0 0 0 2px var(--teal-bg) !important; }

/* ── Loading skeleton shimmer (empty states) ── */
.louie-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: louie-shimmer 1.5s infinite;
  border-radius: 6px;
  height: 14px;
}
html.dark-mode .louie-skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
}

/* ── Better empty states ── */
.louie-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
}
.louie-empty-state .es-icon { font-size: 36px; opacity: 0.6; }
.louie-empty-state .es-title { font-size: 15px; font-weight: 700; color: #1a1a1a; font-family: var(--font-display); }
.louie-empty-state .es-body { font-size: 13px; color: #64748b; line-height: 1.6; max-width: 280px; font-family: var(--font-ui); }
.louie-empty-state .es-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
html.dark-mode .louie-empty-state .es-title { color: #f1f5f9; }

/* ── Responsive upgrades ── */

/* Tablet (768–1024px) */
@media (max-width: 1024px) {
  #home-quick-actions { grid-template-columns: repeat(6, 1fr) !important; }
  #desk-overlay > div { padding: 16px !important; }
  #desk-overlay [style*="grid-template-columns:2fr 1fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
  #desk-overlay [style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
  [style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* Mobile (max 768px) */
@media (max-width: 768px) {
  /* Home dashboard */
  #home-quick-actions { grid-template-columns: repeat(4, 1fr) !important; }
  #home-kpi-grid { grid-template-columns: 1fr 1fr !important; }
  .hkpi2-val { font-size: 20px !important; }
  .hkpi2 { padding: 12px 14px !important; }
  #fi-penetration-widget [style*="grid-template-columns:repeat(5,1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Sidebar */
  #louie-priorities { display: none; }
  #role-selector { display: none; }
  #louie-my-recent { display: none; }

  /* Deal Coach overlay */
  #desk-overlay { overflow-y: auto !important; }
  #desk-overlay > div > div:first-child { flex-direction: column !important; gap: 12px !important; }
  #desk-overlay [style*="grid-template-columns:2fr 1fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
  #desk-overlay [style*="grid-template-columns:1fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
  #desk-overlay [style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Pipeline / Inbox overlays */
  #pipeline-overlay > div,
  #inbox-overlay > div {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  #pipe-detail { display: none !important; } /* single-panel on mobile */

  /* Omnisearch */
  #louie-omnisearch-card { width: calc(100vw - 24px) !important; max-width: none !important; }

  /* Chat header */
  #header-search-btn span:last-child,
  #header-search-btn kbd { display: none !important; }
  #header-search-btn { padding: 5px 8px !important; }

  /* Touch targets */
  .ql-btn { min-height: 44px !important; }
  button { min-height: 36px; }

  /* Persistent KPI strip — stack on mobile */
  #persistent-kpi-strip {
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 8px 12px !important;
  }
  #persistent-kpi-strip > div { min-width: 80px; }
}

/* Small mobile (max 480px) */
@media (max-width: 480px) {
  #home-quick-actions { grid-template-columns: repeat(3, 1fr) !important; }
  #home-kpi-grid { grid-template-columns: 1fr 1fr !important; }
  .hkpi2-val { font-size: 18px !important; }
  #fi-penetration-widget { display: none !important; } /* too cramped */
}

/* ── Button press micro-interaction ── */
button:active:not(:disabled) {
  transform: scale(0.97);
  transition: transform 0.08s ease !important;
}

/* ── Toast notification ── */
.louie-toast {
  position: fixed;
  bottom: 80px;
  right: 24px;
  background: #0d1b2e;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-ui);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: louie-fade-in 0.25s ease both;
  max-width: 320px;
  border-left: 3px solid #22c55e;
}
.louie-toast.warn { border-left-color: #f59e0b; }
.louie-toast.error { border-left-color: #dc2626; }

/* ── Input focus ring upgrade ── */
input:focus, textarea:focus, select:focus {
  outline: none !important;
  border-color: var(--teal-light) !important;
  box-shadow: 0 0 0 3px var(--teal-bg) !important;
}

/* ── Desk overlay improvements ── */
#desk-overlay {
  font-family: var(--font-ui);
}
#desk-overlay input,
#desk-overlay select {
  font-family: var(--font-ui) !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* ── Score badge (morning brief) ── */
.mb2-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(139,106,42,0.12);
  border: 1px solid var(--teal-border);
  border-radius: 20px;
  padding: 4px 14px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--teal-light);
}
.mb2-score-num {
  font-family: var(--font-data);
  font-size: 18px;
  font-weight: 800;
}

/* ── Global scroll behavior ── */
html { scroll-behavior: smooth; }

/* ── Lender card teal highlight (Louie's pick) ── */
.lender-card-primary {
  border-left: 4px solid var(--teal) !important;
  background: var(--teal-bg) !important;
}

/* ── Trend indicator ── */
.trend-up   { color: var(--emerald); }
.trend-down { color: var(--crimson); }
.trend-flat { color: var(--text-secondary); }

/* ── Confetti success animation ── */
@keyframes confetti-fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(60px) rotate(360deg); opacity: 0; }
}
.confetti-piece {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 99999;
  animation: confetti-fall 1s ease-out forwards;
}

/* ── Swipe sidebar indicator on mobile ── */
@media (max-width: 768px) {
  .sidebar {
    touch-action: pan-y !important;
  }
}

/* ── Louie Voice nudge chip ── */
.louie-nudge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(201,168,76,0.08);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 8px;
  font-size: 11px;
  color: #8b6a2a;
  line-height: 1.5;
  font-family: var(--font-ui);
  margin-top: 8px;
}
.louie-nudge::before { content: '💡'; font-size: 12px; }

/* ── F&I penetration bar fill override to handle dark mode ── */
html.dark-mode #fi-penetration-widget {
  background: #1e293b !important;
}
html.dark-mode #fi-penetration-widget [style*="background:#f1f5f9"] {
  background: rgba(255,255,255,0.08) !important;
}
html.dark-mode #fi-penetration-widget [style*="color:#64748b"] {
  color: #94a3b8 !important;
}
html.dark-mode #fi-penetration-widget [style*="color:#8b6a2a"] {
  color: #c9a84c !important;
}

/* ── Tablet deal coach: payment scenarios 2-col ── */
@media (max-width: 900px) {
  #desk-scenarios {
    grid-template-columns: 1fr 1fr !important;
  }
}
