:root {
  --primary: #e30613;
  --navy: #1a1f3c;
  --text-main: #1c1e21;
  --bg-light: #f0f2f5;
  --white: #ffffff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: "Inter", sans-serif;
}

#chatbot-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 9999;
  overscroll-behavior: contain;
}

/* BURBUJA FLOTANTE */
.chat-trigger {
  width: 65px;
  height: 65px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-trigger img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* VENTANA DE CHAT */
.chat-window {
  display: flex;
  width: 360px;
  height: 580px; 
  max-height: 90vh;
  background: var(--white);
  border-radius: 16px;
  position: absolute;
  bottom: 85px;
  right: 0;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.1);
  animation: slideUp 0.3s ease-out;

}

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

/* CABECERA */
.chat-header {
  background: var(--primary);
  color: white;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-header img {
  height: 28px;
  background: white;
  padding: 3px;
  border-radius: 4px;
}
.header-info .title {
  display: block;
  font-weight: 600;
  font-size: 14px;
}
.header-info .status {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.dot {
  width: 7px;
  height: 7px;
  background: #31a24c;
  border-radius: 50%;
  border: 1px solid white;
}

/* CUERPO DEL CHAT */
.chat-body {
  display: flex;
  flex-direction: column;
  padding: 15px;
  overflow-y: auto;
  flex-grow: 1;
  gap: 8px; /* Espacio entre burbujas */
  overflow-y: auto; 
}

/* MENSAJES */
.msg {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 5px;
  word-wrap: break-word;
  position: relative;
}

/* MENSAJE DEL BOT (Izquierda) */
.bot {
  background: #f0f2f5;
  color: var(--text-main);
  align-self: flex-start;
  border-bottom-left-radius: 4px; /* Efecto de "burbuja" */
  margin-right: 20%;
}

/* MENSAJE DEL USUARIO (Derecha) */
.user-msg {
  background: var(--primary); /* El rojo de Inmasan */
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px; /* Efecto de "burbuja" */
  margin-left: 20%;
  text-align: left; /* El texto dentro se lee normal */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* BOTONES DE OPCIONES */
.option-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 5px;
}
/* BOTONES DE OPCIONES (AZUL INMASAN) */
.option-btn {
  background: var(--secondary); /* Usamos el azul */
  color: white; /* Texto blanco para que resalte */
  border: none;
  padding: 12px 15px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  display: block;
  width: 100%;
}

.option-btn:hover {
  background: #252d58; /* Un azul un poco más claro al pasar el ratón */
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.option-btn:active {
  transform: translateY(0);
}

/* Ajuste del contenedor de botones */
.option-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  padding: 5px 0;
}
/* ZONA DE FORMULARIO / INPUT */
.form-zone {
  display: none; /* Se activa por JS con 'flex' */
  flex-direction: column;
  background: #ffffff;
  border-top: 1px solid #eee;
  max-height: 400px;
  overflow-y: auto;
}

/* INPUT DE PREGUNTA */
.input-area {
  display: flex;
  padding: 10px;
  gap: 8px;
  align-items: center;
}
.input-area input {
  flex-grow: 1;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 20px;
  outline: none;
  font-size: 13px;
}
.input-area button {
  all: unset;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 38px;
  height: 38px;

  background: var(--primary);
  color: white;

  border-radius: 50%;
  cursor: pointer;

  font-size: 16px;
  line-height: 1;
}
/* DISEÑO DE FORMULARIO TICKET */
.formulario-container {
  background: #fdfdfd;
  border-radius: 12px;
  padding: 15px;
  border: 1px solid #eee;
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.formulario-container input,
.formulario-container textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: 0.2s;
}
.formulario-container input:focus,
.formulario-container textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.1);
}

.send-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: 0.2s;
}
.send-btn:hover {
  background: #c20511;
}

/* ENLACES Y AUXILIARES */
.back-link {
  background: none;
  border: none;
  color: #888;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
  padding: 5px;
  text-align: center;
}
.back-link:hover {
  color: var(--primary);
}
.typing-indicator {
  display: none;
  padding: 5px 15px;
  font-size: 12px;
  color: #888;
  font-style: italic;
}

/* GRID DE CANALES (LLAMADAS) */
.channel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.channel-card {
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  font-size: 13px;
}
.channel-card:hover {
  border-color: var(--primary);
  background: white;
}

/* ESTADOS DE HORARIO */
.status.offline .dot {
  background: #bbb !important;
}
.status.offline {
  color: #eee;
}

/* RESPONSIVE PARA MÓVILES */

@media screen and (max-width: 480px) {
  #chatbot-container {
    bottom: 15px;
    right: 15px;
  }

  .chat-window {
    width: calc(
      100vw - 30px
    ); /* Ocupa el ancho de pantalla menos 30px de margen */
    max-width: none;
    height: calc(100vh - 120px); /* Casi toda la altura de la pantalla */
    max-height: none;
    bottom: 75px; /* Se sitúa sobre la burbuja */
    position: fixed; /* Cambiamos a fixed para que no dependa del contenedor */
    right: 15px;
    border-radius: 12px;
  }

  /* Ajuste de mensajes para que no sean tan estrechos */

  .bot,
  .user-msg {
    margin-right: 10%;
    margin-left: 10%;
    font-size: 15px; /* Un pelín más grande para leer mejor en móvil */
  }

  /* Ajuste del formulario para que los botones sean fáciles de pulsar */

  .option-btn,
  .send-btn {
    padding: 15px;
    font-size: 14px;
  }

  .chat-trigger {
    width: 55px;
    height: 55px;
  }
}
