/* ============================================================
   S38 v3 — Armonización del interior con el login "producto vivo"
   Sidebar de tinta cálida + hero editorial Fraunces + composer
   refinado + acento unificado al canónico #E94E1B.
   Override ADITIVO: carga al final, todo scoped a .chat-screen
   (admin.html no lo carga — intacto). Reversible quitando el <link>.
   ============================================================ */

.chat-screen {
  /* Unificación de acento: chat-tokens traía #ff551a; el canónico
     declarado por Ricardo es #E94E1B (mismo del login/logo/correos). */
  --accent: #E94E1B;
  --accent-soft: rgba(233, 78, 27, 0.07);

  --c3-ink-0: #0F1822;
  --c3-ink-1: #131E29;
  --c3-cream-0: #EDF2F8;
  --c3-cream-1: #DCE2E7;
  --c3-cream-2: #AEB8C0;
  --c3-cream-3: #5A6B73;
  --c3-cream-4: #54606B;
  --c3-accent-bright: #FF6A3D;
  --c3-accent-deep: #B83A0E;
  --c3-glow: rgba(233, 78, 27, 0.45);
}

/* =========================================================
   SIDEBAR — tinta cálida (continuidad con el login)
   ========================================================= */
.chat-screen .sidebar {
  background: linear-gradient(180deg, var(--c3-ink-1), var(--c3-ink-0));
  border-right: 1px solid rgba(237, 242, 248, 0.08);
}
.chat-screen .sidebar-header { border-bottom: 1px solid rgba(237, 242, 248, 0.08); }
.chat-screen .sidebar-mark { color: var(--c3-cream-0); }
.chat-screen .sidebar-mark em { color: var(--c3-accent-bright); }
.chat-screen .sidebar-header .aduax-mark img { filter: none; }

.chat-screen .sidebar-newchat {
  background: linear-gradient(150deg, var(--c3-accent-bright), var(--accent) 60%, var(--c3-accent-deep));
  color: #fff;
  border: 0;
  box-shadow: 0 8px 22px -10px var(--c3-glow), 0 1px 0 rgba(255, 255, 255, 0.18) inset;
  transition: filter 0.15s ease, box-shadow 0.18s ease, transform 0.06s ease;
}
.chat-screen .sidebar-newchat:hover {
  background: linear-gradient(150deg, var(--c3-accent-bright), var(--accent) 60%, var(--c3-accent-deep));
  filter: brightness(1.07);
  box-shadow: 0 12px 28px -10px var(--c3-glow), 0 1px 0 rgba(255, 255, 255, 0.22) inset;
}
.chat-screen .sidebar-newchat:active { transform: translateY(1px); }

.chat-screen .sidebar-search {
  background: rgba(237, 242, 248, 0.06);
  border: 1px solid rgba(237, 242, 248, 0.12);
}
.chat-screen .sidebar-search input { color: var(--c3-cream-0); background: transparent; }
.chat-screen .sidebar-search input::placeholder { color: var(--c3-cream-4); }
.chat-screen .sidebar-search svg { color: var(--c3-cream-3); stroke: var(--c3-cream-3); }

.chat-screen .sidebar-section-label { color: var(--c3-cream-3); }

/* S39b — plantillas en sidebar */
.chat-screen .sidebar-templates-head { display: flex; justify-content: space-between; align-items: center; }
.chat-screen .sidebar-templates-head button {
  background: none; border: 1px solid rgba(237, 242, 248, 0.16); border-radius: 5px;
  color: var(--c3-cream-3); font-family: var(--font-mono-x); font-size: 9.5px;
  letter-spacing: 0.04em; padding: 2px 7px; cursor: pointer;
}
.chat-screen .sidebar-templates-head button:hover { color: var(--c3-accent-bright); border-color: var(--c3-accent-bright); }
.chat-screen .sidebar-templates { display: flex; flex-direction: column; gap: 2px; padding: 0 10px 10px; }
.chat-screen .template-item {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 0; border-radius: 6px;
  padding: 6px 8px; cursor: pointer; text-align: left; width: 100%;
  color: var(--c3-cream-2); font-family: var(--font-body-x); font-size: 12px;
}
.chat-screen .template-item:hover { background: rgba(237, 242, 248, 0.05); color: var(--c3-cream-0); }
.chat-screen .template-icon { color: var(--c3-accent-bright); font-size: 11px; flex-shrink: 0; }
.chat-screen .template-item.is-own .template-icon { color: #5E9BC4; }
.chat-screen .template-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.chat-screen .template-del { color: var(--c3-cream-4); padding: 0 4px; font-size: 13px; }
.chat-screen .template-del:hover { color: #E15C4E; }

.chat-screen .history-item { background: transparent; }
.chat-screen .history-item .history-title { color: var(--c3-cream-1); }
.chat-screen .history-item .history-meta { color: var(--c3-cream-4); }
.chat-screen .history-item:hover { background: rgba(237, 242, 248, 0.05); }
.chat-screen .history-item.is-active {
  background: rgba(233, 78, 27, 0.13);
  box-shadow: 2px 0 0 0 var(--accent) inset;
}
.chat-screen .history-item.is-active .history-title { color: var(--c3-cream-0); }
.chat-screen .sidebar-history-empty { color: var(--c3-cream-3); }

.chat-screen .sidebar-history::-webkit-scrollbar-thumb {
  background: rgba(237, 242, 248, 0.16);
}
.chat-screen .sidebar-history { scrollbar-color: rgba(237, 242, 248, 0.16) transparent; }

.chat-screen .sidebar-footer { border-top: 1px solid rgba(237, 242, 248, 0.08); }
.chat-screen .user-avatar {
  background: linear-gradient(150deg, var(--c3-accent-bright), var(--c3-accent-deep));
  color: #fff;
  box-shadow: 0 4px 12px -4px var(--c3-glow);
}
.chat-screen .user-email { color: var(--c3-cream-1); }
.chat-screen .user-role { color: var(--c3-cream-3); }
.chat-screen .sidebar-action {
  background: transparent;
  border: 1px solid rgba(237, 242, 248, 0.14);
  color: var(--c3-cream-2);
}
.chat-screen .sidebar-action:hover {
  color: var(--c3-accent-bright);
  border-color: var(--c3-accent-bright);
  background: rgba(233, 78, 27, 0.08);
}

/* =========================================================
   HERO — drama editorial (Fraunces + folio + rule con tab)
   ========================================================= */
.chat-screen .hero-eyebrow::before {
  content: '№ AD·2026';
  color: var(--text-tertiary);
  border-right: 1px solid var(--border-hairline);
  padding-right: 10px;
  margin-right: 10px;
}
.chat-screen .hero-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 300;
  font-size: clamp(42px, 4.6vw, 62px);
  letter-spacing: -0.03em;
  line-height: 1.02;
}
.chat-screen .hero-title em {
  font-style: italic;
  font-weight: 400;
  color: transparent;
  background: linear-gradient(100deg, var(--c3-accent-bright), var(--accent) 55%, #d97742);
  -webkit-background-clip: text;
  background-clip: text;
}
.chat-screen .hero-sub::after {
  content: '';
  display: block;
  height: 2px;
  max-width: 520px;
  margin-top: 22px;
  background: linear-gradient(90deg, var(--accent) 0 64px, var(--border-hairline) 64px);
}

/* quick-actions: lift + hairline naranja que se enciende */
.chat-screen .qa-card {
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.chat-screen .qa-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  height: 2px; width: 0;
  background: var(--accent);
  transition: width 0.25s ease;
}
.chat-screen .qa-card:hover {
  transform: translateY(-2px);
  border-color: rgba(233, 78, 27, 0.35);
  box-shadow: 0 14px 30px -16px rgba(15, 24, 34, 0.28);
}
.chat-screen .qa-card:hover::after { width: 100%; }

.chat-screen .corpus-stats strong {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  font-size: 21px;
  letter-spacing: -0.01em;
}

/* =========================================================
   COMPOSER — de caja dura a superficie con foco luminoso
   ========================================================= */
.chat-screen .composer {
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  box-shadow: 0 12px 32px -20px rgba(15, 24, 34, 0.30);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.chat-screen .composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 78, 27, 0.14), 0 12px 32px -20px rgba(15, 24, 34, 0.30);
}
/* empty-state: chat-tokens ponía borde naranja 2px duro; aquí el énfasis
   es luminoso (ring suave), consistente con el login glass */
.chat-screen.is-empty-state .composer {
  border: 1px solid rgba(233, 78, 27, 0.45);
  box-shadow: 0 0 0 3px rgba(233, 78, 27, 0.10), 0 12px 32px -20px rgba(15, 24, 34, 0.30);
}
.chat-screen.is-empty-state .composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 78, 27, 0.16), 0 12px 32px -20px rgba(15, 24, 34, 0.30);
}
.chat-screen .composer-send {
  background: linear-gradient(150deg, var(--c3-accent-bright), var(--accent) 60%, var(--c3-accent-deep));
  border-radius: 9px;
  box-shadow: 0 8px 22px -10px var(--c3-glow), 0 1px 0 rgba(255, 255, 255, 0.18) inset;
  transition: filter 0.15s ease, box-shadow 0.18s ease, transform 0.06s ease;
}
.chat-screen .composer-send:hover {
  background: linear-gradient(150deg, var(--c3-accent-bright), var(--accent) 60%, var(--c3-accent-deep));
  filter: brightness(1.07);
}
.chat-screen .composer-send:active { transform: translateY(1px); }

/* header del main: hairline editorial */
.chat-screen .main-header { border-bottom: 1px solid var(--border-hairline); }

/* S39.1 — acciones de respuesta SIEMPRE visibles (estaban opacity:0 hasta
   hover — Ricardo batalló para encontrar "Avísame si cambia" sabiendo que
   existía; un usuario nuevo jamás las descubriría) */
.chat-screen .msg-actions { opacity: 1; }
/* la campana destaca: es la acción de mayor valor */
.chat-screen .msg-action[data-action="watch"] {
  color: var(--accent);
  border-color: rgba(233, 78, 27, 0.45);
  background: var(--accent-soft);
}
.chat-screen .msg-action[data-action="watch"]:hover {
  background: rgba(233, 78, 27, 0.14);
  border-color: var(--accent);
}

/* S39c — compartir + banner de vista compartida
   S39.1: relleno naranja (Ricardo: "cambia color para que sea más visible") */
.chat-screen .share-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(150deg, var(--c3-accent-bright), var(--accent) 60%, var(--c3-accent-deep));
  border: 0; border-radius: 7px;
  padding: 7px 14px; cursor: pointer;
  font-family: var(--font-body-x); font-size: 12px; font-weight: 600; color: #fff;
  box-shadow: 0 6px 16px -8px var(--c3-glow);
}
.chat-screen .share-btn:hover { filter: brightness(1.07); }
.chat-screen .share-btn svg { stroke: #fff; }
.chat-screen .share-btn svg { width: 13px; height: 13px; }
.chat-screen .shared-banner {
  max-width: 720px; margin: 18px auto 6px;
  font-family: var(--font-mono-x); font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-tertiary);
  border: 1px dashed var(--border-hairline); border-radius: 8px;
  padding: 9px 14px; text-align: center;
}

/* =========================================================
   S39 — Drawer de fuentes (cita → texto íntegro del corpus)
   ========================================================= */
.chat-screen .citation[data-entidad] { cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.chat-screen .citation[data-entidad]:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px -4px rgba(233, 78, 27, 0.35);
}

.fuente-drawer { position: fixed; inset: 0; z-index: 90; }
.fuente-drawer[hidden] { display: none !important; }
.fuente-overlay { position: absolute; inset: 0; background: rgba(13, 20, 28, 0.45); cursor: pointer; }
.fuente-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(480px, 92vw);
  background: #fffdf9;
  border-left: 1px solid #DCE2E7;
  box-shadow: -30px 0 70px -30px rgba(13, 20, 28, 0.45);
  display: flex; flex-direction: column;
  animation: fuente-in 0.22s ease-out;
}
@keyframes fuente-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.fuente-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid #DCE2E7;
}
.fuente-kicker {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 0.16em; text-transform: uppercase; color: #E94E1B; margin-bottom: 6px;
}
.fuente-header h3 {
  margin: 0; font-family: 'Fraunces', Georgia, serif; font-weight: 500;
  font-size: 19px; letter-spacing: -0.01em; color: #13252d;
}
.fuente-meta { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: #54606B; margin-top: 6px; }
.fuente-meta .ok { color: #2c5e3a; background: #d4ead8; padding: 2px 8px; border-radius: 999px; }
.fuente-meta .warn { color: #2E4452; background: #E2EDF5; padding: 2px 8px; border-radius: 999px; }
.fuente-close {
  background: none; border: 1px solid #DCE2E7; border-radius: 6px;
  width: 30px; height: 30px; font-size: 18px; line-height: 1;
  color: #54606B; cursor: pointer; flex-shrink: 0;
}
.fuente-close:hover { color: #E94E1B; border-color: #E94E1B; }
.fuente-texto {
  flex: 1; overflow-y: auto; padding: 18px 22px;
  font-family: 'Newsreader', Georgia, serif; font-size: 14.5px; line-height: 1.7;
  color: #2c3e44; white-space: pre-wrap;
}
.fuente-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 22px; border-top: 1px solid #DCE2E7;
}
.fuente-copiar {
  font-family: 'IBM Plex Sans', sans-serif; font-size: 13px; font-weight: 600;
  color: #fff; border: 0; border-radius: 8px; padding: 10px 18px; cursor: pointer;
  background: linear-gradient(150deg, #FF6A3D, #E94E1B 60%, #B83A0E);
  box-shadow: 0 6px 18px -8px rgba(233, 78, 27, 0.45);
}
.fuente-copiar:hover { filter: brightness(1.06); }
.fuente-footer a {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: #E94E1B;
  text-decoration: none; border-bottom: 1px solid rgba(233, 78, 27, 0.4);
}

/* S45 — Cobertura del corpus (drawer desde el menú; reusa .fuente-drawer) */
.corpus-drawer-legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 12px 24px;
  border-bottom: 1px solid var(--border-hairline, #DCE2E7); font-size: 12.5px; color: var(--ink-mute, #5A6B73); }
.corpus-drawer-list { overflow-y: auto; padding: 6px 0 24px; flex: 1; }
.corpus-row { display: grid; grid-template-columns: 24px 1fr auto auto; align-items: center; gap: 10px;
  padding: 9px 24px; border-bottom: 1px solid var(--border-hairline, #DCE2E7); font-size: 13.5px; }
.corpus-row:hover { background: var(--surface-hover, #EDF2F8); }
.corpus-row-dot { font-size: 11px; }
.corpus-row-name { color: var(--ink, #0F2530); font-weight: 500; }
.corpus-row-src { font-family: var(--font-mono, monospace); font-size: 11px; letter-spacing: .04em;
  color: var(--citation, #2E6F8E); }
.corpus-row-vig { font-family: var(--font-mono, monospace); font-size: 11.5px; color: var(--ink-mute, #5A6B73);
  text-align: right; min-width: 58px; }

/* S46 — chips de documentos adjuntos en el mensaje del usuario */
.msg-adjuntos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.msg-adjunto { font-size: 12px; font-family: var(--font-mono, monospace);
  background: var(--surface, #fff); border: 1px solid var(--border-hairline, #DCE2E7);
  border-radius: 6px; padding: 3px 9px; color: var(--ink-soft, #2C3E47);
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
