/* ============================================================
   Protectia Stylebook — style.css
   PRD §3: Color palette, typography, components, layout
   ============================================================ */

/* ----------------------------------------------------------
   0. CSS Custom Properties (Design Tokens)
   PRD §3.1 Paleta de colores + §3.2 Tipografía + §3.4 Layout
   ---------------------------------------------------------- */
:root {
  /* Primary */
  --color-primary:       #003B73;
  --color-primary-light: #0A4F8A;
  --color-primary-dark:  #002A52;

  /* Secondary — Electric Teal */
  --color-teal:          #00B4D8;
  --color-teal-light:    #48CAE4;
  --color-teal-dark:     #0096B7;
  --color-teal-50:       #E8F8FB;

  /* Accent — Warm Amber */
  --color-amber:         #FFA726;
  --color-amber-light:   #FFB74D;
  --color-amber-dark:    #F57C00;
  --color-amber-50:      #FFF8E1;

  /* Semantic */
  --color-success:       #4CAF50;
  --color-success-light: #E8F5E9;
  --color-warning:       #E65100;
  --color-warning-light: #FFF3E0;
  --color-danger:        #F44336;
  --color-danger-light:  #FFEBEE;

  /* Neutrals */
  --color-text:          #1A1A2E;
  --color-text-secondary:#6B7280;
  --color-text-muted:    #9CA3AF;
  --color-border:        #E5E7EB;
  --color-border-light:  #F3F4F6;
  --color-bg:            #F3F4F6;
  --color-surface:       #FFFFFF;
  --color-overlay:       rgba(0, 0, 0, 0.50);

  /* Typography */
  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, monospace;
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  /* Type scale */
  --text-xs:   0.75rem;   /* 12px — caption */
  --text-sm:   0.875rem;  /* 14px — small / code */
  --text-base: 1rem;      /* 16px — body */
  --text-lg:   1.125rem;  /* 18px */
  --text-xl:   1.25rem;   /* 20px */
  --text-2xl:  1.5rem;    /* 24px — h3 */
  --text-3xl:  2rem;      /* 32px — h2 */
  --text-4xl:  2.5rem;    /* 40px — h1 */

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Radii */
  --radius-sm:  4px;
  --radius-md:  8px;   /* cards */
  --radius-lg:  12px;  /* modals */
  --radius-xl:  16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md:  0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg:  0 10px 15px rgba(0, 0, 0, 0.10);
  --shadow-xl:  0 20px 25px rgba(0, 0, 0, 0.10);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.15);

  /* Layout */
  --container-max: 1280px;
  --sidebar-width: 16rem; /* 256px / w-64 */
  --header-height: 4rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Z-index */
  --z-dropdown: 10;
  --z-sticky:   20;
  --z-header:   50;
  --z-overlay:  60;
  --z-modal:    70;
  --z-toast:    80;
}


/* ----------------------------------------------------------
   1. Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--color-teal); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-teal-dark); }
code, pre { font-family: var(--font-mono); font-size: var(--text-sm); }


/* ----------------------------------------------------------
   2. Typography
   PRD §3.2
   ---------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 { line-height: 1.25; color: var(--color-text); }

h1 { font-size: var(--text-4xl); font-weight: var(--fw-bold); }
h2 { font-size: var(--text-3xl); font-weight: var(--fw-semibold); }
h3 { font-size: var(--text-2xl); font-weight: var(--fw-semibold); }
h4 { font-size: var(--text-xl);  font-weight: var(--fw-semibold); }

.text-sm      { font-size: var(--text-sm); }
.text-xs      { font-size: var(--text-xs); }
.text-lg      { font-size: var(--text-lg); }
.text-muted   { color: var(--color-text-secondary); }
.text-caption  { font-size: var(--text-xs); font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-secondary); }
.font-mono    { font-family: var(--font-mono); }


/* ----------------------------------------------------------
   3. Layout & Grid
   PRD §3.4 — 12 col, max-w-7xl, gap-6
   ---------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.grid       { display: grid; gap: var(--space-6); }
.grid-12    { grid-template-columns: repeat(12, 1fr); }
.grid-3     { grid-template-columns: repeat(3, 1fr); }
.grid-4     { grid-template-columns: repeat(4, 1fr); }
.grid-2     { grid-template-columns: repeat(2, 1fr); }

.col-span-2  { grid-column: span 2; }
.col-span-3  { grid-column: span 3; }
.col-span-4  { grid-column: span 4; }
.col-span-6  { grid-column: span 6; }
.col-span-8  { grid-column: span 8; }
.col-span-9  { grid-column: span 9; }
.col-span-12 { grid-column: span 12; }

.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.section    { padding-block: var(--space-12); }
.section-lg { padding-block: var(--space-20); }

@media (max-width: 768px) {
  .grid-12, .grid-3, .grid-4, .grid-2 {
    grid-template-columns: 1fr;
  }
  .col-span-2, .col-span-3, .col-span-4,
  .col-span-6, .col-span-8, .col-span-9 {
    grid-column: span 1;
  }
}


/* ----------------------------------------------------------
   4. Header
   PRD §3.3 — bg-white, shadow-sm, sticky top-0, z-50
   ---------------------------------------------------------- */
.header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding-inline: var(--space-6);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.header__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: var(--fw-bold);
  font-size: var(--text-lg);
  color: var(--color-primary);
}

.header__logo img,
.header__logo svg {
  height: 32px;
  width: auto;
}

.header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  list-style: none;
}

.header__nav a {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
}

.header__nav a:hover,
.header__nav a.active {
  color: var(--color-primary);
}


/* ----------------------------------------------------------
   5. Badges
   PRD §3.3 — px-3 py-1, rounded-full, text-xs font-medium
   ---------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  line-height: 1.5;
  white-space: nowrap;
}

/* Semantic variants */
.badge--primary   { background: var(--color-primary);   color: #fff; }
.badge--teal      { background: var(--color-teal);      color: #fff; }
.badge--amber     { background: var(--color-amber);     color: #fff; }
.badge--success   { background: var(--color-success-light); color: #1B5E20; }
.badge--warning   { background: var(--color-warning-light); color: var(--color-warning); }
.badge--danger    { background: var(--color-danger-light);  color: var(--color-danger); }
.badge--neutral   { background: var(--color-border-light);  color: var(--color-text-secondary); }

/* Mode badges: MOCK (amber) / LIVE (green) — PRD §3.3 Header */
.badge--mock { background: var(--color-amber);   color: #fff; font-weight: var(--fw-semibold); }
.badge--live { background: var(--color-success);  color: #fff; font-weight: var(--fw-semibold); }

/* Agent type badges */
.badge--cs    { background: #E3F2FD; color: #1565C0; }
.badge--sales { background: #F3E5F5; color: #7B1FA2; }

/* Insight type badges */
.badge--sentiment    { background: #E8F5E9; color: #2E7D32; }
.badge--intent       { background: #E3F2FD; color: #1565C0; }
.badge--opportunity  { background: var(--color-amber-50); color: var(--color-amber-dark); }
.badge--risk         { background: var(--color-danger-light); color: var(--color-danger); }
.badge--action       { background: var(--color-teal-50); color: var(--color-teal-dark); }

/* Dot indicator */
.badge--dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}


/* ----------------------------------------------------------
   6. Cards
   PRD §3.3 — bg-white, shadow-sm, rounded-xl, p-6, border
   ---------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
}

.card__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.card__body { flex: 1; }

.card__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-light);
}

/* Stat card (admin dashboard) */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stat-card__label {
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
}

.stat-card__value {
  font-size: var(--text-3xl);
  font-weight: var(--fw-bold);
  color: var(--color-text);
  line-height: 1;
}

.stat-card__delta {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
}

.stat-card__delta--up   { color: var(--color-success); }
.stat-card__delta--down { color: var(--color-danger); }


/* ----------------------------------------------------------
   7. Banners
   ---------------------------------------------------------- */
.banner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
}

.banner--info {
  background: var(--color-teal-50);
  color: var(--color-teal-dark);
  border: 1px solid var(--color-teal);
}

.banner--success {
  background: var(--color-success-light);
  color: #1B5E20;
  border: 1px solid var(--color-success);
}

.banner--warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
}

.banner--danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

/* Handoff banner (CS → Sales transfer) */
.banner--handoff {
  background: linear-gradient(135deg, var(--color-teal-50), #F3E5F5);
  border: 1px solid var(--color-teal);
  color: var(--color-primary);
  font-weight: var(--fw-semibold);
}

.banner__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.banner__dismiss {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
}

.banner__dismiss:hover { opacity: 1; }


/* ----------------------------------------------------------
   8. Buttons
   PRD §3.3 — primary, secondary, CTA variants
   ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  line-height: 1.5;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

/* Primary: bg-teal, text-white */
.btn--primary {
  background: var(--color-teal);
  color: #fff;
  border-color: var(--color-teal);
}
.btn--primary:hover:not(:disabled) {
  background: var(--color-teal-dark);
  border-color: var(--color-teal-dark);
}

/* Secondary: border-teal, text-teal */
.btn--secondary {
  background: transparent;
  color: var(--color-teal);
  border-color: var(--color-teal);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--color-teal-50);
}

/* CTA: bg-amber, text-white, font-semibold */
.btn--cta {
  background: var(--color-amber);
  color: #fff;
  border-color: var(--color-amber);
  font-weight: var(--fw-semibold);
}
.btn--cta:hover:not(:disabled) {
  background: var(--color-amber-dark);
  border-color: var(--color-amber-dark);
}

/* Danger */
.btn--danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn--danger:hover:not(:disabled) {
  background: #D32F2F;
  border-color: #D32F2F;
}

/* Ghost */
.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn--ghost:hover:not(:disabled) {
  background: var(--color-border-light);
  color: var(--color-text);
}

/* Sizes */
.btn--sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn--lg { padding: var(--space-4) var(--space-8); font-size: var(--text-base); }

/* Icon button */
.btn--icon {
  padding: var(--space-2);
  border-radius: var(--radius-md);
}


/* ----------------------------------------------------------
   9. Form Controls
   PRD §3.3 — border-gray-300, rounded-lg, focus:ring teal
   ---------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.15);
}

.form-input::placeholder { color: var(--color-text-muted); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-select { cursor: pointer; }

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
}

/* Checkbox / Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  accent-color: var(--color-teal);
  width: 16px;
  height: 16px;
}


/* ----------------------------------------------------------
   10. Tables
   ---------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-weight: var(--fw-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tr:hover td {
  background: var(--color-border-light);
}

/* Clickable row */
.table tr.table-row--clickable {
  cursor: pointer;
}

/* Numeric column alignment */
.table .col-num { text-align: right; font-family: var(--font-mono); }


/* ----------------------------------------------------------
   11. Score Gradients & Gauges
   PRD §3.3 — sale_opportunity_score, audit scores, insights
   ---------------------------------------------------------- */

/* --- Score pill (inline) --- */
.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: #fff;
}

/* Five-step score gradient: 0-20 red, 21-40 orange, 41-60 amber, 61-80 teal, 81-100 green */
.score--critical { background: var(--color-danger); }       /* 0-20   */
.score--low      { background: var(--color-warning); }       /* 21-40  */
.score--medium   { background: var(--color-amber); }         /* 41-60  */
.score--high     { background: var(--color-teal); }          /* 61-80  */
.score--excellent{ background: var(--color-success); }       /* 81-100 */

/* --- Score bar (horizontal progress) --- */
.score-bar {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-border-light);
  overflow: hidden;
}

.score-bar__fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.score-bar__fill--critical { background: var(--color-danger); }
.score-bar__fill--low      { background: var(--color-warning); }
.score-bar__fill--medium   { background: var(--color-amber); }
.score-bar__fill--high     { background: var(--color-teal); }
.score-bar__fill--excellent{ background: var(--color-success); }

/* --- Sale opportunity score (gradient bar) --- */
.sale-score {
  position: relative;
  height: 12px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg,
    var(--color-danger)  0%,
    var(--color-warning) 25%,
    var(--color-amber)   50%,
    var(--color-teal)    75%,
    var(--color-success) 100%
  );
  overflow: visible;
}

.sale-score__marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 3px solid var(--color-primary);
  box-shadow: var(--shadow-md);
  transition: left var(--transition-slow);
}

.sale-score__label {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

/* --- Circular gauge (SVG-based via inline styles) --- */
.gauge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gauge__svg {
  transform: rotate(-90deg);
}

.gauge__bg {
  fill: none;
  stroke: var(--color-border-light);
  stroke-width: 8;
}

.gauge__fill {
  fill: none;
  stroke: var(--color-teal);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--transition-slow);
}

.gauge__fill--critical { stroke: var(--color-danger); }
.gauge__fill--low      { stroke: var(--color-warning); }
.gauge__fill--medium   { stroke: var(--color-amber); }
.gauge__fill--high     { stroke: var(--color-teal); }
.gauge__fill--excellent{ stroke: var(--color-success); }

.gauge__value {
  position: absolute;
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: var(--color-text);
}


/* ----------------------------------------------------------
   12. Insight Cards
   ---------------------------------------------------------- */
.insight-card {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4);
  border-left: 3px solid var(--color-teal);
  background: var(--color-surface);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.insight-card:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow-md);
}

/* Variants by insight type */
.insight-card--sentiment   { border-left-color: var(--color-success); }
.insight-card--intent      { border-left-color: #1565C0; }
.insight-card--opportunity { border-left-color: var(--color-amber); }
.insight-card--risk        { border-left-color: var(--color-danger); }
.insight-card--action      { border-left-color: var(--color-teal); }

.insight-card__time {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  min-width: 4rem;
}

.insight-card__content { flex: 1; }

.insight-card__type {
  margin-bottom: var(--space-1);
}

.insight-card__text {
  font-size: var(--text-sm);
  color: var(--color-text);
}

/* New insight animation */
@keyframes insight-enter {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.insight-card--new {
  animation: insight-enter 0.3s ease-out;
}


/* ----------------------------------------------------------
   13. Audit Components
   ---------------------------------------------------------- */
/* Audit score display */
.audit-score {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.audit-score__gauge { flex-shrink: 0; }

.audit-score__details {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.audit-score__label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.audit-score__value {
  font-size: var(--text-4xl);
  font-weight: var(--fw-bold);
  font-family: var(--font-mono);
  line-height: 1;
}

/* Criterion row (in audit detail) */
.criterion-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
}

.criterion-row:last-child { border-bottom: none; }

.criterion-row__name {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
}

.criterion-row__weight {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  min-width: 3rem;
  text-align: right;
}

.criterion-row__level {
  min-width: 5rem;
}

/* Level badges */
.level--excellent { background: var(--color-success-light); color: #1B5E20; }
.level--good      { background: #E3F2FD; color: #1565C0; }
.level--adequate  { background: var(--color-amber-50); color: var(--color-amber-dark); }
.level--poor      { background: var(--color-warning-light); color: var(--color-warning); }
.level--critical  { background: var(--color-danger-light); color: var(--color-danger); }

.criterion-row__evidence {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-style: italic;
  margin-top: var(--space-1);
}


/* ----------------------------------------------------------
   14. Transcript Viewer
   ---------------------------------------------------------- */
.transcript {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  max-height: 500px;
  overflow-y: auto;
}

.transcript__msg {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
}

.transcript__msg--agent {
  background: var(--color-teal-50);
}

.transcript__msg--user {
  background: var(--color-border-light);
}

.transcript__speaker {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}

.transcript__speaker--agent { color: var(--color-teal-dark); }
.transcript__speaker--user  { color: var(--color-text-secondary); }

.transcript__text {
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* Auto-scroll indicator */
.transcript__live {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-teal);
  font-weight: var(--fw-medium);
}

.transcript__live::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-teal);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}


/* ----------------------------------------------------------
   15. Modal / Dialog
   PRD §3.3 — bg-white, rounded-xl, shadow-2xl, overlay
   ---------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2xl);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
}

.modal__title {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
}

.modal__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: var(--space-1);
}

.modal__close:hover { color: var(--color-text); }

.modal__body { padding: var(--space-6); }

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border-light);
}


/* ----------------------------------------------------------
   16. Admin Sidebar
   PRD §3.3 — bg-gray-900, text-white, w-64
   ---------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #111827; /* gray-900 */
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: var(--z-sticky);
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6);
  font-weight: var(--fw-bold);
  font-size: var(--text-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__brand img,
.sidebar__brand svg {
  height: 28px;
  width: auto;
}

.sidebar__nav {
  flex: 1;
  padding: var(--space-4) 0;
}

.sidebar__section {
  padding: var(--space-2) var(--space-6);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
  margin-top: var(--space-4);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.7);
  transition: all var(--transition-fast);
}

.sidebar__link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar__link.active {
  background: rgba(0, 180, 216, 0.15);
  color: var(--color-teal-light);
  border-right: 3px solid var(--color-teal);
}

.sidebar__link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Admin main content offset */
.admin-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}


/* ----------------------------------------------------------
   17. Tooltip
   PRD §3.3
   ---------------------------------------------------------- */
.tooltip {
  position: relative;
  cursor: help;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-2) var(--space-3);
  background: var(--color-text);
  color: #fff;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: var(--z-toast);
}

.tooltip:hover::after { opacity: 1; }


/* ----------------------------------------------------------
   18. Loading & Feedback States
   PRD §1.3 — feedback de procesamiento
   ---------------------------------------------------------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-teal);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.skeleton {
  background: linear-gradient(90deg,
    var(--color-border-light) 25%,
    var(--color-border) 50%,
    var(--color-border-light) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Processing indicator (for insights/audit/script generation) */
.processing {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-teal-50);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-teal-dark);
}


/* ----------------------------------------------------------
   19. Hero Section (Landing)
   ---------------------------------------------------------- */
.hero {
  text-align: center;
  padding: var(--space-20) var(--space-6);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  color: #fff;
}

.hero h1 { color: #fff; margin-bottom: var(--space-4); }

.hero__tagline {
  font-size: var(--text-xl);
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: var(--space-8);
}

.hero__actions {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  flex-wrap: wrap;
}

/* Hero Agent Avatar Cards */
.hero-agents {
  display: flex;
  gap: var(--space-6);
  justify-content: center;
  flex-wrap: wrap;
}

.hero-agent {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-6);
  min-width: 240px;
  transition: background 0.2s, transform 0.15s;
}
.hero-agent:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-2px);
}

.hero-agent__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-agent__avatar--cs {
  background: rgba(21, 101, 192, 0.5);
}
.hero-agent__avatar--sales {
  background: rgba(123, 31, 162, 0.5);
}

.hero-agent__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hero-agent__name {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: #fff;
}

.hero-agent__role {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.7);
}

.hero-agent__status {
  margin-left: auto;
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
}
.hero-agent__status--online {
  background: rgba(76, 175, 80, 0.25);
  color: #A5D6A7;
}
.hero-agent__status--online::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4CAF50;
  margin-right: 6px;
  vertical-align: middle;
  animation: status-blink 2s ease-in-out infinite;
}
@keyframes status-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}


/* ----------------------------------------------------------
   20. Dashboard Panel Layout
   Three-column for CS / Sales dashboards
   ---------------------------------------------------------- */
.dashboard {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  gap: var(--space-6);
  padding: var(--space-6);
  min-height: calc(100vh - var(--header-height));
}

.dashboard__panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overflow-y: auto;
  max-height: calc(100vh - var(--header-height) - var(--space-12));
}

.dashboard__panel--main {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
}

@media (max-width: 1024px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
}


/* ----------------------------------------------------------
   21. Breadcrumb (Admin)
   ---------------------------------------------------------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

.breadcrumb a { color: var(--color-text-secondary); }
.breadcrumb a:hover { color: var(--color-teal); }
.breadcrumb__sep { color: var(--color-text-muted); }
.breadcrumb__current { color: var(--color-text); font-weight: var(--fw-medium); }


/* ----------------------------------------------------------
   22. Tabs
   ---------------------------------------------------------- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-6);
}

.tab {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover { color: var(--color-text); }

.tab.active {
  color: var(--color-teal);
  border-bottom-color: var(--color-teal);
}


/* ----------------------------------------------------------
   23. Search / Filter Bar
   ---------------------------------------------------------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
}

.filter-bar__search {
  flex: 1;
  position: relative;
}

.filter-bar__search input {
  width: 100%;
  padding: var(--space-2) var(--space-4) var(--space-2) var(--space-10);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.filter-bar__search input:focus {
  outline: none;
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.15);
}

.filter-bar__search svg {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
}


/* ----------------------------------------------------------
   24. Utilities
   ---------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hidden { display: none; }

/* HTMX loading indicator */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-request.htmx-indicator { display: inline-flex; }

/* SSE connection state */
.sse-connected    { color: var(--color-success); }
.sse-disconnected { color: var(--color-danger); }
.sse-reconnecting { color: var(--color-amber); }
