/* ======================================================
   PediaGuía — Hoja de estilos completa
   Paleta: crema/marfil de fondo, verde médico suave de acento
   ====================================================== */

:root {
  /* Colores base */
  --color-bg: #FAF6ED;
  --color-surface: #FFFDF8;
  --color-surface-alt: #F2EEE1;
  --color-text: #2B2B26;
  --color-text-secondary: #7A776C;
  --color-border: #E6E0D0;

  /* Verde médico (marca) */
  --color-primary: #1F7A5C;
  --color-primary-dark: #155A43;
  --color-primary-light: #E3F0EA;

  /* Estados de triaje */
  --color-danger: #D9534F;
  --color-danger-bg: #FCEAE9;
  --color-warning: #C98A00;
  --color-warning-bg: #FFF6DE;
  --color-success: #2E8B57;
  --color-success-bg: #E4F3EA;

  /* Forma y sombra */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 3px rgba(43, 43, 38, 0.06);
  --shadow-md: 0 6px 20px rgba(31, 122, 92, 0.10);

  /* Layout */
  --header-height: 86px;
  --nav-height: 64px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--color-surface-alt);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
}

/* Contenedor centrado tipo "app" en pantallas grandes, full-width en mobile */
.app-header,
.app-main,
.bottom-nav {
  width: 100%;
  max-width: 480px;
}

/* ============ HEADER ============ */
.app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  z-index: 50;
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 20px 16px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.app-header__icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 2px;
}

.app-header__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.app-header__subtitle {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.82);
}

/* ============ SWITCHER DE IDIOMA ============ */
.lang-switcher {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 14px;
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 3px;
}

.lang-switcher__btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-switcher__btn.active {
  background: #fff;
  color: var(--color-primary-dark);
}

/* ============ BOTÓN DE REGRESO ============ */
.header-back-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.16);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.header-back-btn.visible {
  display: flex;
}

.header-back-btn:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.94);
}

/* ============ MAIN ============ */
.app-main {
  background: var(--color-bg);
  min-height: 100vh;
  padding: calc(var(--header-height) + env(safe-area-inset-top, 0px) + 18px) 18px
           calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 24px);
}

/* ============ SCREENS (navegación tipo SPA) ============ */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: screenFadeIn 0.25s ease;
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ TIPOGRAFÍA ============ */
.text-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 12px;
  color: var(--color-text);
}

.text-body {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--color-text);
  margin: 0 0 14px;
}

.text-body--secondary {
  color: var(--color-text-secondary);
}

/* ============ INTRO SCREEN (bienvenida, propósito, placeholder) ============ */
.intro-screen {
  text-align: center;
  padding: 8px 4px 4px;
}

.intro-screen__emoji-circle {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}

.intro-screen .text-title,
.intro-screen .text-body {
  text-align: left;
}

.intro-progress {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 18px 0 22px;
}

.intro-progress__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-border);
  transition: background 0.2s ease;
}

.intro-progress__dot.active {
  background: var(--color-primary);
  width: 18px;
  border-radius: 4px;
}

/* ============ LAYOUT HELPERS ============ */
.flex-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============ CARDS ============ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.card--clickable {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.card--clickable:active {
  transform: scale(0.98);
  box-shadow: none;
}

.card__icon {
  font-size: 22px;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card__title {
  margin: 0 0 2px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--color-text);
}

.card__subtitle {
  margin: 0;
  font-size: 12.5px;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* ============ BADGE / SECTION LABEL ============ */
.badge {
  display: inline-block;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-secondary);
  margin: 18px 0 8px;
}

/* ============ DISCLAIMER ============ */
.disclaimer {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 12px 14px;
  margin: 16px 0;
}

.disclaimer__icon {
  font-size: 16px;
  line-height: 1.4;
}

.disclaimer__text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--color-text-secondary);
}

.disclaimer__text strong {
  color: var(--color-text);
}

/* ============ BOTONES ============ */
.btn {
  width: 100%;
  display: block;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn--primary:hover {
  background: var(--color-primary-dark);
}

.btn--outline {
  background: transparent;
  color: var(--color-primary-dark);
  border: 1.5px solid var(--color-border);
}

.btn--outline:hover {
  border-color: var(--color-primary);
}

/* ============ BOTTOM NAV ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  z-index: 50;
  display: flex;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 8px 4px calc(env(safe-area-inset-bottom, 0px) + 8px);
  box-shadow: 0 -2px 12px rgba(43, 43, 38, 0.05);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 0;
  border-radius: var(--radius-sm);
}

.bottom-nav__icon {
  font-size: 19px;
  line-height: 1;
}

.bottom-nav__item.active {
  color: var(--color-primary-dark);
}

.bottom-nav__item.active .bottom-nav__icon {
  transform: translateY(-1px);
}

/* ======================================================
   CHAT / TRIAJE
   ====================================================== */

.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 18px;
}

.chip {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, transform 0.12s ease;
}

.chip:active {
  transform: scale(0.96);
  background: var(--color-primary-light);
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  max-height: 48vh;
  overflow-y: auto;
  margin-bottom: 14px;
  padding: 4px 2px;
}

.chat-window:empty::before {
  content: "Tu conversación con el asistente aparecerá aquí.";
  display: block;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-secondary);
  padding: 30px 10px;
}

html:lang(en) .chat-window:empty::before {
  content: "Your conversation with the assistant will appear here.";
}

.chat-message {
  max-width: 85%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.45;
}

.chat-message--user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message--bot {
  align-self: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}

.chat-message--bot.chat-message--loading {
  color: var(--color-text-secondary);
  font-style: italic;
}

.chat-message--bot.triage-rojo {
  border-left: 3px solid var(--color-danger);
  background: var(--color-danger-bg);
}
.chat-message--bot.triage-amarillo {
  border-left: 3px solid var(--color-warning);
  background: var(--color-warning-bg);
}
.chat-message--bot.triage-verde {
  border-left: 3px solid var(--color-success);
  background: var(--color-success-bg);
}

.triage-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.triage-badge--rojo {
  background: #fff;
  color: var(--color-danger);
}
.triage-badge--amarillo {
  background: #fff;
  color: var(--color-warning);
}
.triage-badge--verde {
  background: #fff;
  color: var(--color-success);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.chat-input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
}

.chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.chat-send-btn {
  width: auto;
  padding: 0 20px;
  font-size: 14px;
}

/* ============ APP SHELL (contenedor transparente) ============ */
.app-shell {
  display: contents;
}

/* ============ RESPONSIVE: tablet y escritorio (sitio real, no ventana flotante) ============ */
@media (min-width: 768px) {
  html, body {
    background: #F0ECDE;
  }

  body {
    display: block;
    background:
      radial-gradient(circle at 12% 8%, rgba(31, 122, 92, 0.08), transparent 40%),
      radial-gradient(circle at 92% 92%, rgba(31, 122, 92, 0.06), transparent 45%),
      #F0ECDE;
    min-height: 100vh;
  }

  /* ---- Header: barra completa arriba, contenido alineado a una columna legible ---- */
  .app-header {
    position: sticky;
    top: 0;
    left: auto;
    transform: none;
    width: 100%;
    max-width: none;
    z-index: 50;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 2px;
    column-gap: 14px;
    text-align: left;
    padding: 16px max(28px, calc((100% - 760px) / 2));
    box-shadow: 0 2px 16px rgba(20, 30, 24, 0.12);
  }

  .header-back-btn {
    position: static;
    order: 0;
  }

  .app-header__icon {
    order: 1;
    font-size: 20px;
  }

  .app-header__title {
    order: 2;
    font-size: 17px;
  }

  .app-header__subtitle {
    order: 3;
    font-size: 12.5px;
    margin: 0;
  }

  .lang-switcher {
    position: static;
    order: 10;
    margin-left: auto;
  }

  /* ---- Menú de navegación: pestañas horizontales debajo del header, no flotando ---- */
  .bottom-nav {
    position: static;
    left: auto;
    bottom: auto;
    transform: none;
    width: 100%;
    max-width: none;
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 6px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 10px max(28px, calc((100% - 760px) / 2));
    box-shadow: none;
  }

  .bottom-nav__item {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 999px;
    font-size: 13px;
  }

  .bottom-nav__item:hover {
    background: var(--color-primary-light);
  }

  .bottom-nav__item.active {
    background: var(--color-primary-light);
  }

  .bottom-nav__icon {
    font-size: 16px;
  }

  /* ---- Contenido: columna centrada, legible, sin ancho infinito ---- */
  .app-main {
    position: static;
    max-width: 760px;
    margin: 0 auto;
    border-left: none;
    border-right: none;
    background: transparent;
    padding: 36px 28px 64px;
  }

  .screen.active {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 36px 40px;
    box-shadow: 0 4px 24px rgba(20, 30, 24, 0.06);
  }

  /* ---- Tarjetas: pasan de columna única a grilla de 2 cuando hay espacio ---- */
  .flex-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
  }

  /* ---- Chat: un poco más de aire en escritorio ---- */
  .chat-window {
    max-height: 50vh;
  }
}
