/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* --- CORRECCIÓN: Body se prepara para un hijo de altura completa --- */
html, body {
  height: 100%;
  overflow: hidden; /* Evita el scroll en la página principal */
}

body {
  font-family: "Segoe UI", sans-serif;
  background-color: #f1f1f1;
  color: #333;
  padding: 0; /* Sin padding en el body para el modo móvil */
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- CORRECCIÓN: Contenedor principal ahora es flexible --- */
.chat-container {
  width: 100%;
  max-width: 500px; /* ancho para escritorio */
  height: 50vh;    /* Altura relativa para escritorio */
  max-height: 700px;
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column; /* La clave: los hijos se apilan verticalmente */
  overflow: hidden;
}

/* --- Encabezado --- */
.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0; /* No se encoge */
}
.widget-header .header-left, .widget-header .header-right {
    flex: 1;
    display: flex;
    align-items: center;
}
.widget-header .header-left { justify-content: flex-start; }
.widget-header .header-right { justify-content: flex-end; position: relative; }
.widget-header h2 {
    flex-grow: 2; text-align: center; margin: 0 5px; color: #ed872b;
    font-size: 1.2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Botones de idioma y menú */
.lang-btn { padding: 4px 8px; border: 1px solid #ccc; background: white; cursor: pointer; border-radius: 4px; font-size: 0.8em; margin: 0 2px; }
.lang-btn.active { background-color: #ed872b; color: white; border-color: #ed872b; }
.menu-btn { position: static; background: none; border: none; font-size: 1.5em; cursor: pointer; }
.menu-options { position: absolute; top: 35px; right: 0; background: white; border: 1px solid #ccc; border-radius: 8px; display: none; flex-direction: column; box-shadow: 0 4px 10px rgba(0,0,0,0.1); z-index: 10; min-width: 200px; }
.menu-options button { padding: 12px 20px; border: none; background: white; text-align: left; cursor: pointer; font-size: 0.95em; border-bottom: 1px solid #eee; }
.menu-options button:last-child { border-bottom: none; }
.menu-options button:hover { background: #f5f5f5; }


/* --- El área del chat ahora es elástica --- */
.chat-box {
  flex-grow: 1; /* <<-- ESTA ES LA CLAVE: Ocupa todo el espacio sobrante */
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Estilos para el contenedor de bienvenida */
.welcome-message {
    text-align: center;
    padding: 20px;
    color: #888;
    margin: auto; /* Centra vertical y horizontalmente dentro del flexbox */
}

.welcome-logo {
    max-width: 100px; /* Ajusta el tamaño de tu logo */
    margin-bottom: 15px;
    opacity: 0.7;
}

.welcome-message h3 {
    font-size: 1.2em;
    color: #555;
    margin-bottom: 5px;
}

.welcome-message p {
    font-size: 0.9em;
    max-width: 300px;
    margin: 0 auto;
}

/* --- Lógica para ocultar la bienvenida --- */
/* Cuando el chat tenga burbujas, el mensaje de bienvenida se ocultará */
.chat-box.chat-active .welcome-message {
    display: none;
}

/* --- Fila de Input --- */
.input-row {
  display: flex;
  gap: 10px;
  padding: 15px;
  border-top: 1px solid #eee;
  flex-shrink: 0; /* No se encoge */
}
.input-row input[type="text"] { flex: 1; padding: 12px; font-size: 1em; border: 1px solid #ccc; border-radius: 8px; }
.input-row button { padding: 12px 18px; font-size: 1em; border: none; border-radius: 8px; background-color: #ed872b; color: white; cursor: pointer; }

/* Burbujas y Opciones (sin cambios estéticos mayores) */
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 18px; line-height: 1.5; word-wrap: break-word; }
.bubble.user { align-self: flex-end; background-color: #ed872b; color: white; border-bottom-right-radius: 4px; }
.bubble.bot { font-style: italic; align-self: flex-start; background-color: #e9e9eb; color: #000; border-bottom-left-radius: 4px; white-space: pre-line; }
.bubble.bot a { color: #007bff; }
.bot-options { background: transparent !important; padding: 0 !important; border: none !important; align-self: flex-start; display: flex; flex-direction: column; gap: 8px; margin-top: 5px; }
.follow-up-btn { background-color: #fff; border: 1px solid #ed872b; color: #ed872b; padding: 8px 12px; border-radius: 20px; cursor: pointer; text-align: left; font-size: 0.9em; }
.follow-up-btn:hover { background-color: #ed872b; color: #fff; }
.follow-up-btn:disabled { background-color: #eee; color: #aaa; border-color: #ddd; cursor: not-allowed; }

.clear-prompt {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #fff8e1;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    font-size: 14px;
    color: #555;
}
.clear-prompt button {
    background-color: #ed872b;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.clear-prompt button:hover {
    opacity: 0.9;
}
/* ================================================================ */
/* RESPONSIVE: Comportamiento de pantalla completa para móvil       */
/* ================================================================ */
@media (max-width: 600px) {
  .chat-container {
    width: 100%;
    height: 100%; /* El contenedor ocupa el 100% de la altura visible de la ventana */
    max-height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }
}