:root {
  --bg-1: #eef1ff;
  --bg-2: #f7f5ff;
  --surface: #ffffff;
  --ink: #14152b;
  --muted: #6b7390;
  --faint: #9aa1bd;
  --line: #ececf6;
  --brand-1: #6366f1;
  --brand-2: #a855f7;
  --grad: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --user-ink: #ffffff;
  --bot: #f5f6fc;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px rgba(20, 21, 43, .06);
  --shadow-md: 0 8px 24px rgba(76, 70, 160, .10);
  --shadow-lg: 0 24px 60px rgba(50, 44, 120, .22);
  --radius: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 12% -8%, #dfe3ff 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 10%, #f3e4ff 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

/* ---------- Marca ---------- */
.accentbar { height: 4px; flex: 0 0 auto; background: var(--grad); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: var(--grad);
  color: #fff;
  font-size: 20px;
  border-radius: 13px;
  box-shadow: 0 6px 16px rgba(124, 92, 246, .45);
}
.brand-text { min-width: 0; }
.topbar h1 { font-size: 16.5px; margin: 0; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.topbar h1 .tag {
  font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--brand-1); background: #eef0ff; border: 1px solid #dcdffb;
  padding: 2px 7px; border-radius: 999px;
}
.status { margin: 3px 0 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(16,185,129,.18); }

/* Lado derecho del header: wordmark de TechNova + botón */
.brand-right { display: flex; align-items: center; gap: 14px; }
.wordmark {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--ink); letter-spacing: -.01em;
  padding-right: 14px; border-right: 1px solid var(--line);
}
.wordmark strong { font-weight: 800; }
.nova { display: block; }

.ghost {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.ghost:hover { color: var(--brand-1); border-color: #d6d8f7; box-shadow: var(--shadow-sm); }
.ghost-icon { font-size: 14px; }

/* ---------- Chat ---------- */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 26px 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Empty state */
.empty { margin: auto; text-align: center; max-width: 460px; padding: 20px; }
.empty-badge {
  width: 66px; height: 66px; margin: 0 auto 18px;
  display: grid; place-items: center;
  font-size: 30px; color: #fff;
  background: var(--grad);
  border-radius: 20px;
  box-shadow: 0 14px 34px rgba(124, 92, 246, .4);
}
.empty-intro { margin: 0 0 14px; color: var(--muted); font-size: 16px; line-height: 1.55; }
.empty h2 { margin: 0 0 20px; font-size: 22px; letter-spacing: -.02em; }
.suggestions { display: flex; flex-direction: column; gap: 10px; }
.suggestion {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all .15s ease;
  box-shadow: var(--shadow-sm);
}
.suggestion:hover { border-color: #c9ccf6; transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* Messages */
.msg { display: flex; gap: 11px; max-width: 92%; animation: rise .25s ease both; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.bot { align-self: flex-start; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.avatar {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700;
  margin-top: 2px;
}
.msg.bot .avatar { background: var(--grad); color: #fff; box-shadow: 0 5px 12px rgba(124,92,246,.4); }
.msg.user .avatar { background: #e8eaf6; color: var(--brand-1); }

.col { min-width: 0; display: flex; flex-direction: column; }
.msg.user .col { align-items: flex-end; }

.bubble {
  padding: 12px 15px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg.user .bubble {
  background: var(--grad);
  color: var(--user-ink);
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 20px rgba(124, 92, 246, .3);
}
.msg.bot .bubble {
  background: var(--bot);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.msg.bot .bubble.no-answer {
  background: #fff8ed;
  border-color: #fde2bd;
  color: #9a5b15;
}
.bubble strong { font-weight: 700; }
.bubble ul { margin: 6px 0; padding-left: 20px; }
.bubble li { margin: 2px 0; }

/* Inline citation badges (reemplazan a los [n]) */
.cite {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  margin: 0 1px; transform: translateY(-1px);
  font-size: 10.5px; font-weight: 700; line-height: 1;
  color: var(--brand-1);
  background: #eef0ff;
  border: 1px solid #dcdffb;
  border-radius: 6px;
  cursor: default;
  vertical-align: super;
}

/* Meta: fuentes + confianza + feedback */
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.sources { display: flex; flex-wrap: wrap; gap: 7px; }
.src {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 5px 10px;
  max-width: 240px;
  box-shadow: var(--shadow-sm);
}
.src .num {
  display: inline-grid; place-items: center;
  width: 15px; height: 15px;
  font-size: 9.5px; font-weight: 700;
  color: var(--brand-1); background: #eef0ff; border-radius: 5px;
}
.src .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.confidence { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--faint); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.high { background: var(--ok); }
.dot.mid { background: var(--warn); }
.dot.low { background: var(--danger); }

.feedback { display: flex; gap: 5px; margin-left: auto; }
.feedback button {
  width: 30px; height: 30px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px; line-height: 1;
  transition: all .15s ease;
}
.feedback button:hover { background: #f4f5ff; border-color: #d6d8f7; transform: translateY(-1px); }
.feedback button.active { background: #eef0ff; border-color: #c9ccf6; }
.feedback button[disabled] { cursor: default; opacity: .55; transform: none; }

/* Typing */
.typing .bubble { display: inline-flex; gap: 5px; padding: 14px 16px; }
.typing .d { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-2); animation: blink 1.3s infinite both; }
.typing .d:nth-child(2) { animation-delay: .2s; }
.typing .d:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }

/* ---------- AI notice + firma de marca ---------- */
.ai-notice {
  font-size: 12px; color: var(--muted);
  padding: 9px 20px;
  background: #fbfbfe;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.ai-notice strong { color: var(--ink); }
.ai-text { display: inline-flex; align-items: baseline; gap: 6px; min-width: 0; }
.brand-credit {
  display: inline-flex; align-items: center; gap: 5px;
  flex: 0 0 auto;
  font-size: 12px; color: var(--muted); letter-spacing: -.01em;
}
.brand-credit strong { color: var(--ink); font-weight: 800; }

@media (max-width: 600px) { .brand-credit { display: none; } }

/* ---------- Composer ---------- */
.composer {
  display: flex; gap: 10px; align-items: center;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.composer input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 14px 18px;
  font-size: 14.5px;
  outline: none;
  background: #fbfbfe;
  transition: all .15s ease;
}
.composer input:focus { border-color: var(--brand-1); background: #fff; box-shadow: 0 0 0 4px rgba(99,102,241,.14); }
.composer button {
  flex: 0 0 auto;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border: 0;
  background: var(--grad);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(124, 92, 246, .4);
  transition: transform .15s ease, box-shadow .15s ease;
}
.composer button:hover { transform: translateY(-1px) scale(1.04); }
.composer button:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }

/* ---------- About (botón flotante + panel) ---------- */
.about-btn {
  position: fixed;
  top: 16px; left: 16px;
  z-index: 50;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px;
  font-size: 13px; font-weight: 600;
  color: var(--brand-1);
  background: rgba(255, 255, 255, .92);
  border: 1px solid #e0e2f7;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-md);
  transition: transform .15s ease, box-shadow .15s ease;
}
.about-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.about-q {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px;
  font-size: 12px; font-weight: 800;
  color: #fff; background: var(--grad);
  border-radius: 50%;
}

.about-panel {
  position: fixed;
  top: 62px; left: 16px;
  z-index: 51;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100dvh - 88px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 18px 20px 20px;
  animation: pop .16s ease both;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.about-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.about-head h3 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.about-close {
  border: 0; background: transparent; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--faint); padding: 0 2px;
}
.about-close:hover { color: var(--ink); }
.about-panel p { margin: 0 0 14px; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.about-panel strong { color: var(--ink); }
.area { margin-bottom: 13px; }
.area-title { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.area-title span { font-size: 14px; }
.hint {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--line);
  background: #fbfbfe;
  color: var(--brand-1);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 12.5px;
  cursor: pointer;
  margin-bottom: 6px;
  transition: all .14s ease;
}
.hint:hover { background: #eef0ff; border-color: #d6d8f7; transform: translateX(2px); }

/* Sugerencias de siguientes preguntas (bajo cada respuesta del agente) */
.followups { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.followup {
  border: 1px solid #dcdffb;
  background: #f3f4ff;
  color: var(--brand-1);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  transition: all .14s ease;
}
.followup::before { content: "↳ "; opacity: .6; }
.followup:hover { background: #e7e9ff; border-color: #c5c9fb; transform: translateY(-1px); }

/* ---------- Responsive ---------- */
/* El pill top-left solo entra cuando hay margen lateral suficiente (app de 860px
   centrada). Por debajo chocaría con el logo, así que lo volvemos un botón
   circular flotante abajo-izquierda (FAB). */
@media (max-width: 1280px) {
  .about-btn {
    top: auto; bottom: 134px; left: 14px;
    width: 46px; height: 46px; padding: 0;
    justify-content: center;
    font-size: 0;            /* oculta el label, deja solo el "?" */
  }
  .about-q { width: 22px; height: 22px; font-size: 14px; }
  .about-panel { top: auto; bottom: 190px; left: 14px; }
}

@media (max-width: 600px) {
  .app { border: 0; }
  .msg { max-width: 100%; }
  .ghost-label { display: none; }
  .topbar h1 .tag { display: none; }
  .wordmark { display: none; }
}
