/* ─────────────────────────────────────────────────────────
   Aura — Asistente de inteligencia climática del IDEAM
   Paleta basada en el logo: azules profundos + teal/verde
   ───────────────────────────────────────────────────────── */

:root {
  --aura-navy: #1B3A6F;
  --aura-blue: #1E5099;
  --aura-blue-2: #2E6BBF;
  --aura-teal: #28A89A;
  --aura-teal-light: #5FC2B5;
  --aura-green: #4DAA50;

  --bg: #F4F9FC;
  --bg-sidebar: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-user: var(--aura-blue);
  --bg-agent: #FFFFFF;
  --bg-quick: #FFFFFF;
  --bg-input: #FFFFFF;

  --text-primary: #1B2A4E;
  --text-secondary: #5C6B89;
  --text-muted: #8A98B5;
  --text-on-blue: #FFFFFF;

  --border: #E4ECF3;
  --border-strong: #D2DEEA;

  --shadow-sm: 0 1px 2px rgba(27, 58, 111, 0.06);
  --shadow-md: 0 4px 12px rgba(27, 58, 111, 0.08);
  --shadow-lg: 0 8px 24px rgba(27, 58, 111, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  background: white;
  -webkit-font-smoothing: antialiased;
}

button, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ───── App layout ───── */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;        /* fallback navegadores viejos */
  height: 100dvh;       /* iOS Safari: respeta área visible real, no incluye URL bar */
  width: 100%;
}

/* ═════════════════ SIDEBAR ═════════════════ */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.sidebar-top {
  padding: 24px 20px 8px;
  text-align: center;
}

.sidebar-logo {
  width: 140px;
  height: auto;
  max-width: 100%;
}

.btn-new-chat {
  margin: 28px 20px 0;
  padding: 12px 16px;
  background: #0943b5;
  color: var(--text-on-blue);
  border: 0;
  border-radius: var(--radius-xl);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, transform .1s ease;
}

.btn-new-chat:hover { background: var(--aura-blue-2); }
.btn-new-chat:active { transform: scale(.98); }
.btn-new-chat .plus { font-size: 18px; line-height: 1; }

.sidebar-questions,
.sidebar-history {
  margin: 20px 8px 0;
  padding: 0 4px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.sidebar-questions::-webkit-scrollbar,
.sidebar-history::-webkit-scrollbar { width: 6px; }
.sidebar-questions::-webkit-scrollbar-thumb,
.sidebar-history::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.history-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.3;
  transition: background .12s ease, color .12s ease;
  font-family: inherit;
}
.history-item:hover {
  background: #F1F7FB;
  color: var(--aura-blue);
}
.history-item:active { background: #E8F1FB; }
.hist-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.hist-icon-img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 15px;
  background: #ffffff00;
  padding: 0;
}
.hist-water     { background: #E6F3FA; }
.hist-tree      { background: #E8F5E9; }
.hist-climate   { background: #FFF1E0; }
.hist-rain      { background: #E8F1FB; }
.hist-hurricane { background: #E4EEF7; }
.hist-air       { background: #ECF3F4; }

.sidebar-section-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 0 0 8px;
  padding: 0 8px;
}

.question-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.question-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.35;
  transition: background .12s ease, color .12s ease;
}
.question-item:hover {
  background: #F1F7FB;
  color: var(--aura-blue);
}
.question-item:active { background: #E8F1FB; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.dot-person    { background: #6B5BD2; }
.dot-rain      { background: #3F8FCC; }
.dot-alert     { background: #E07A4C; }
.dot-hurricane { background: #2E7AB8; }
.dot-water     { background: var(--aura-teal); }
.dot-tree      { background: #2F8A33; }
.dot-climate   { background: #D97706; }
.dot-fire      { background: #C44232; }
.dot-air       { background: #4A8F9F; }

.sidebar-mountains {
  width: 100%;
  height: auto;
  max-height: 180px;
  object-fit: contain;
  object-position: bottom;
  display: block;
  flex-shrink: 0;
  pointer-events: none;
  user-select: none;
}

.sidebar-footer {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  background: #FAFCFE;
  flex-shrink: 0;
}

.help-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  transition: background .12s ease, color .12s ease;
}
.help-btn:hover { background: #F1F7FB; color: var(--aura-blue); }
.help-icon {
  width: 24px; height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #F1F7FB;
  border-radius: 50%;
  font-size: 12px;
}

.doc-count {
  font-size: 10.5px;
  color: var(--text-muted);
  text-align: center;
}

/* ═════════════════ MAIN ═════════════════ */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
}

/* Header (legacy) */
.main-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
}

/* Top bar (new redesign: just utility icons on the right) */
.main-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px 0;
  background: transparent;
}
.topbar-spacer { flex: 1; }
.topbar-actions {
  display: flex;
  gap: 6px;
}
.theme-toggle { background: #FFFFFF; box-shadow: var(--shadow-sm); }

.sidebar-collapse {
  display: none;
  background: transparent;
  border: 0;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
}

.main-title { flex: 1; min-width: 0; }
.main-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}
.main-title h1 .brand {
  color: var(--aura-teal);
  font-weight: 700;
}
.main-title p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.header-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover {
  background: #EAF1F8;
  color: var(--aura-blue);
}

/* Chat area */
.chat-area {
  flex: 1;
  min-height: 0;        /* permite que flex shrink funcione bien en mobile */
  overflow-y: auto;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.chat-area::-webkit-scrollbar { width: 8px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

/* Welcome screen */
.welcome {
  max-width: 1200px;
  margin: 8px auto 0;
  padding-top: 8px;
  text-align: center;
  display: none;
}
.chat-empty .welcome { display: block; }
.chat-empty .messages { display: none; }

.welcome-logo {
  width: 120px;
  height: auto;
  margin-bottom: 12px;
}
.welcome-title {
  font-size: 34px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 8px;
  letter-spacing: -0.5px;
}
.welcome-title .ia-icon {
  height: 1.1em;
  width: auto;
  vertical-align: -0.18em;
  margin-left: 4px;
}
.welcome-sub {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0 0 28px;
  line-height: 1.5;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.quick-card {
  background: #ffffff;
  border: 0px solid #CDDC39;
  border-radius: 10em;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-primary);
  line-height: 1.35;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  box-shadow: 0px 16px 22px #f9f9f9;
}
.quick-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--aura-teal-light);
}

.quick-icon {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
}
.quick-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ───── Welcome header ───── */
.welcome-head {
  text-align: center;
  margin-top: 8px;
  margin-bottom: 28px;
}
.welcome-hand {
  display: inline-block;
  margin-right: 6px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
}
.welcome-ia {
  height: 1.05em;
  width: auto;
  vertical-align: -0.18em;
  margin-right: 8px;
}
.welcome-gradient {
  background: linear-gradient(90deg, #1E5099 0%, #28A89A 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}
.welcome-question {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 16px;
}

/* ───── Chip row (6 quick suggestions) ───── */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 0 auto 32px;
  max-width: 980px;
  padding: 0 16px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(27, 58, 111, 0.04);
  transition: border-color .15s ease, transform .12s ease, box-shadow .15s ease;
  font-family: inherit;
}
.chip:hover {
  border-color: var(--aura-teal-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.chip-svg {
  flex-shrink: 0;
  display: block;
}

/* ───── Especial de Bosques frame (gradient border around 4 cards) ───── */
.bosques-frame {
  max-width: 1140px;
  margin: 0 auto 28px;
  padding: 2px;
  border-radius: 24px;
  background: linear-gradient(135deg, #4DAA50 0%, #28A89A 50%, #1E5099 100%);
  position: relative;
}
.bosques-frame::before {
  content: "";
  position: absolute;
  inset: 2px;
  background: #FFFFFF;
  border-radius: 22px;
  z-index: 0;
}
.bosques-frame-head,
.bosques-frame > .photo-grid {
  position: relative;
  z-index: 1;
}
.bosques-frame-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px 8px;
}
.bosques-leaf {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(77, 170, 80, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bosques-frame-titles { text-align: left; }
.bosques-frame-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.2px;
  background: linear-gradient(90deg, #2F8A33 0%, #1E5099 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.bosques-frame-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.bosques-frame .photo-grid {
  padding: 4px 18px 20px;
  margin: 0;
  max-width: none;
}

/* ───── Photo cards grid (4 large cards) ───── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 28px;
}
.photo-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  padding: 0;
  box-shadow: 0 4px 14px rgba(27, 58, 111, 0.06);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.photo-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(27, 58, 111, 0.12);
  border-color: var(--aura-teal-light);
}
.photo-card-img {
  height: 140px;
  background-size: cover;
  background-position: center;
  background-color: #DCE7F0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.photo-card-img::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 50%, rgba(0,0,0,0.18) 100%);
}
.photo-card-img { height: 160px; }
.photo-card-badge {
  position: absolute;
  top: 138px;
  left: 16px;
  width: 44px; height: 44px;
  background: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  z-index: 2;
}
.photo-card-body {
  padding: 28px 18px 18px;
}
.photo-card-body h4 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.photo-card-body p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

@media (max-width: 1000px) {
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
  .photo-grid { grid-template-columns: 1fr; }
  .chip { font-size: 12px; padding: 8px 12px; }
}

/* Messages */
.messages {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  animation: fadeIn .25s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.message.user { justify-content: flex-end; }
.message.user .message-bubble {
  background: #E8F1FB;
  color: var(--text-primary);
  border-radius: 18px 18px 4px 18px;
  max-width: 80%;
}
.message.user .agent-avatar { display: none; }
.message.user .user-avatar {
  order: 2;
  background: linear-gradient(135deg, var(--aura-navy), var(--aura-blue));
}
.message.user .user-avatar svg { color: white; }

.message.agent .message-bubble {
  background: var(--bg-agent);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 4px 18px 18px 18px;
  max-width: 80%;
  box-shadow: var(--shadow-sm);
}

.agent-avatar, .user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: white;
  display: flex; align-items: center; justify-content: center;
}
.agent-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.user-avatar {
  background: linear-gradient(135deg, var(--aura-navy), var(--aura-blue));
}

.message-bubble {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.55;
  /* Links/nombres de archivo largos (ej. boletines SMByC) no tienen
     espacios donde partir la línea — sin esto se salen de la pantalla.
     min-width:0 es necesario porque .message-bubble es un flex item: por
     default no se encoge por debajo del ancho intrínseco del contenido. */
  overflow-wrap: break-word;
  min-width: 0;
}
.message-bubble p { margin: 0 0 8px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble a {
  color: var(--aura-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.message-bubble code {
  background: #F1F5F9;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.message-bubble pre {
  background: #F1F5F9;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12.5px;
}
.message-bubble ul { padding-left: 18px; margin: 8px 0; }
.message-bubble li { margin: 2px 0; }
.message-bubble hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}
.message-bubble strong { color: var(--text-primary); }

/* Markdown tables (cifras históricas SMByC, etc.) */
.md-table-wrap {
  overflow-x: auto;
  margin: 12px 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #FFFFFF;
}
.md-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
  font-family: inherit;
}
.md-table thead {
  background: linear-gradient(90deg, rgba(30,80,153,0.08) 0%, rgba(40,168,154,0.08) 100%);
}
.md-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 700;
  color: var(--aura-navy);
  border-bottom: 2px solid var(--aura-teal-light);
  white-space: nowrap;
}
.md-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: top;
}
.md-table tbody tr:last-child td { border-bottom: 0; }
.md-table tbody tr:nth-child(even) { background: rgba(244, 249, 252, 0.55); }
.md-table tbody tr:hover { background: rgba(40, 168, 154, 0.06); }

/* ═════════════════ LOADING CARD (rediseño) ═════════════════ */
.loading-card {
  display: none;
  max-width: 980px;
  margin: 16px auto 0;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 22px 24px;
  gap: 18px;
  align-items: flex-start;
  animation: fadeIn .25s ease-out;
}
.loading-card.visible { display: flex; }

/* Zorrito al centro entre las 2 info cards (reemplaza el aura logo + fox al costado) */
.loading-fox-center {
  width: 100px;
  height: 100px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  align-self: center;
}

.loading-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.loading-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.loading-titles { min-width: 0; }
.loading-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.loading-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.loading-eta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: #EAF1FB;
  color: var(--aura-blue);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Steps */
.loading-steps {
  list-style: none;
  margin: 0;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: #FBFDFE;
  border: 1px solid var(--border);
  border-radius: 14px;
  position: relative;
}
.loading-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  position: relative;
  padding: 0 8px;
}
/* Línea punteada conectora entre pasos */
.loading-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 14px;
  left: calc(50% + 14px);
  right: calc(-50% + 14px);
  border-top: 2px dashed var(--border-strong);
  z-index: 0;
}
.loading-step.done:not(:last-child)::after {
  border-top-color: #4DAA50;
}
.step-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.loading-step.done .step-mark {
  background: #E8F5E9;
  border-color: #4DAA50;
}
.loading-step.done .step-mark::before {
  content: "";
  width: 8px;
  height: 14px;
  border-right: 2.5px solid #4DAA50;
  border-bottom: 2.5px solid #4DAA50;
  transform: translateY(-1px) rotate(45deg);
}
.loading-step.active .step-mark {
  background: var(--aura-blue);
  border-color: var(--aura-blue);
  animation: step-pulse 1.4s infinite ease-in-out;
}
.loading-step.active .step-mark::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #FFFFFF;
}
@keyframes step-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(30, 80, 153, 0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(30, 80, 153, 0); }
}
.step-info { min-width: 0; }
.step-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  transition: color .2s ease;
}
.loading-step.active .step-name { color: var(--aura-blue); }
.loading-step:not(.active):not(.done) .step-name { color: var(--text-muted); }
.step-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.25;
}
.loading-step:not(.active):not(.done) .step-sub { color: var(--text-muted); opacity: 0.7; }

/* Info cards row: card izq | zorrito centro | card der */
.loading-info-cards {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
}
.loading-info-card {
  display: flex;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 0;
  font-size: 13px;
  color: #FFFFFF;
}
.info-fact     { background: #1E40AF; }   /* azul fuerte */
.info-official { background: #2BA987; }   /* teal/verde */
.info-title {
  font-weight: 700;
  color: #FFFFFF;
  margin-bottom: 4px;
  font-size: 14px;
}
.info-text {
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.4;
}

/* Progress bar */
.loading-progress { padding: 4px 2px 0; }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.progress-label #progressPercent {
  font-weight: 700;
  color: var(--aura-blue);
}
.progress-bar {
  height: 6px;
  background: #EFF4F9;
  border-radius: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--aura-blue) 0%, var(--aura-teal) 100%);
  border-radius: 6px;
  transition: width .4s ease-out;
}

/* Responsive */
@media (max-width: 800px) {
  .loading-card { padding: 18px; gap: 14px; }
  .loading-fox-center { width: 72px; height: 72px; }
  .loading-title { font-size: 14.5px; }
  .loading-steps { grid-template-columns: repeat(2, 1fr); gap: 14px 0; padding: 16px; }
  .loading-step:nth-child(2n)::after,
  .loading-step:last-child::after { display: none; }
  .loading-info-cards { grid-template-columns: 1fr; }
}

/* ═════════════════ INPUT ═════════════════ */
.input-area {
  padding: 16px 32px 18px;
  background: linear-gradient(to top, rgba(244, 249, 252, 1) 60%, rgba(244, 249, 252, 0));
  flex-shrink: 0;       /* nunca se encoja: garantiza visibilidad en mobile */
}
.input-container {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 6px 6px 6px 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input-container:focus-within {
  border-color: var(--aura-teal-light);
  box-shadow: 0 0 0 3px rgba(95, 194, 181, 0.18);
}

.input-prefix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--aura-teal);
  flex-shrink: 0;
  margin-bottom: 6px;
}

#chatInput {
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  /* 16px, no 14px: en iOS Safari un input con font-size < 16px dispara un
     zoom automático al enfocarlo, que descoloca todo el viewport. */
  font-size: 16px;
  line-height: 1.5;
  padding: 12px 0;
  max-height: 140px;
  color: var(--text-primary);
}
#chatInput::placeholder { color: var(--text-muted); }

.btn-send {
  width: 40px; height: 40px;
  background: #0943b5;
  color: white;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, transform .1s ease;
  flex-shrink: 0;
}
.btn-send:hover { background: var(--aura-blue-2); }
.btn-send:active { transform: scale(.94); }
.btn-send:disabled { background: var(--border-strong); cursor: not-allowed; }
.btn-send svg { margin-left: -1px; }

.disclaimer {
  max-width: 760px;
  margin: 8px auto 0;
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
}

/* ═════════════════ DARK THEME ═════════════════ */
body.theme-dark {
  --bg: #0E1726;
  --bg-sidebar: #111C2E;
  --bg-card: #182338;
  --bg-agent: #182338;
  --bg-quick: #182338;
  --bg-input: #182338;
  --text-primary: #E6ECF5;
  --text-secondary: #9AAAC4;
  --text-muted: #6E7E97;
  --border: #25324A;
  --border-strong: #2F3E5A;
}
body.theme-dark { background: var(--bg); color: var(--text-primary); }
body.theme-dark .sidebar { background: var(--bg-sidebar); }
body.theme-dark .chip { background: var(--bg-card); color: var(--text-primary); }
body.theme-dark .photo-card { background: var(--bg-card); }
body.theme-dark .photo-card-body p { color: var(--text-secondary); }
body.theme-dark .input-container { background: var(--bg-input); border-color: var(--border); }
body.theme-dark .theme-toggle { background: var(--bg-card); color: var(--text-primary); }
body.theme-dark .help-btn { color: var(--text-primary); }
body.theme-dark .help-icon { background: #1F2C44; }
body.theme-dark .history-item { color: var(--text-primary); }
body.theme-dark .history-item:hover { background: #1F2C44; }
body.theme-dark .sidebar-footer { background: #0E1726; }
body.theme-dark .message.agent .message-bubble { background: var(--bg-agent); border-color: var(--border); color: var(--text-primary); }
body.theme-dark .message.user .message-bubble { background: #1E5099; color: #FFFFFF; }

/* ═════════════════ TOAST ═════════════════ */
.error-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #B33A2A;
  color: white;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
  z-index: 9999;
}
.error-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ═════════════════ RESPONSIVE ═════════════════ */
.sidebar-toggle, .sidebar-overlay { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(15, 30, 60, 0.4);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  .sidebar-overlay.visible { opacity: 1; pointer-events: auto; }
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 14px; left: 14px;
    width: 38px; height: 38px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    z-index: 998;
    color: var(--aura-blue);
    box-shadow: var(--shadow-sm);
  }
  .main-header { padding-left: 60px; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .chat-area { padding: 16px 16px 8px; }
  .input-area { padding: 12px 16px 16px; }

  /* Respuestas del asistente estilo ChatGPT mobile: full-width, sin avatar
     ni burbuja con borde — solo texto fluyendo con el ancho de la página.
     La pregunta del usuario mantiene su burbuja alineada a la derecha. */
  .message.agent { gap: 0; }
  .message.agent .agent-avatar { display: none; }
  .message.agent .message-bubble {
    max-width: 100%;
    width: 100%;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
  }
  /* Misma especificidad que la regla de dark theme (línea ~1129) — sin esto,
     esa regla gana por especificidad y restaura el fondo/borde en oscuro. */
  body.theme-dark .message.agent .message-bubble {
    background: transparent;
    border: none;
    box-shadow: none;
  }
}

@media (max-width: 480px) {
  .main-title h1 { font-size: 16px; }
  .main-title p { font-size: 11px; }
  .welcome-logo { width: 90px; }
  .welcome-title { font-size: 20px; }
  .quick-card { padding: 12px 8px; font-size: 11.5px; }
  .quick-icon { width: 36px; height: 36px; }
  .quick-icon svg { width: 18px; height: 18px; }
}
