/* ==============================
   GENÉTICA TI · Chat de Soporte
   CSS completo y responsivo (PC + iPhone)
   ============================== */

/* ----- Variables de layout ----- */
:root{
  --header-h: 68px;                 /* altura de cabecera en escritorio */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

/* ----- Base ----- */
html, body { height: 100%; }
* { box-sizing: border-box; }
body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: radial-gradient(circle at top, #0f2027, #203a43, #2c5364);
  margin: 0;
  padding: 0;
  color: #fff;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: contain;
}

/* ----- Header: logo a la izquierda (desktop) y título centrado ----- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #0d1b2a;
  padding-top: var(--safe-top);      /* respeta el notch */
  box-shadow: 0 2px 12px rgba(0,0,0,0.6);
}
.header-inner {
  position: relative;                /* permite centrar el título */
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  min-height: var(--header-h);
}
.header .logo {
  height: 40px;
  flex: 0 0 auto;                    /* logo a la izquierda en desktop */
}
.header .title {
  position: absolute;                /* título perfectamente centrado */
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  line-height: 1.1;
}
.header .title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .3px;
  color: #00aaff;
}
.header .title p {
  margin: 0;
  font-size: 13px;
  color: #a9bcd0;
}

/* ----- Contenedor del chat ----- */
/* Usamos 100svh (small viewport) para iOS/Android y fallback a dvh */
.chat-container {
  width: 100%;
  max-width: 1000px;
  /* Altura visible total menos header y safe-area inferior */
  height: calc(100svh - var(--header-h) - var(--safe-top));
  min-height: calc(100dvh - var(--header-h) - var(--safe-top));
  margin: 0 auto;
  background: rgba(13,27,42,0.92);
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  backdrop-filter: blur(8px);
}

/* ----- Área de mensajes ----- */
#chat-box {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: #2b3a55 transparent;
}
#chat-box::-webkit-scrollbar { width: 6px; }
#chat-box::-webkit-scrollbar-thumb { background: #2b3a55; border-radius: 3px; }

/* ----- Mensajes ----- */
.message {
  margin: 0;                          /* el gap del contenedor maneja los espacios */
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 15px;
  display: inline-block;              /* se ajusta al contenido */
  max-width: 80%;
  word-wrap: break-word;
  word-break: break-word;
  animation: fadeInUp .35s ease;
}
.user {
  background: linear-gradient(135deg, #007bff, #00aaff);
  color: #fff;
  margin-left: auto;                  /* al lado derecho */
  text-align: right;
  border-bottom-right-radius: 6px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}
.bot {
  background: #1b263b;
  border: 1px solid rgba(255,255,255,0.1);
  color: #e5e5e5;
  margin-right: auto;                 /* al lado izquierdo */
  text-align: left;
  border-bottom-left-radius: 6px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

/* ----- Input + botón ----- */
.input-container {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: #0d1b2a;
  border-top: 1px solid #0a1522;
  padding-bottom: calc(12px + var(--safe-bottom));  /* levanta sobre el notch */
}
#user-input {
  flex: 1;
  padding: 14px;
  font-size: 15px;
  border: none;
  border-radius: 12px;
  outline: none;
  background: #1b263b;
  color: #fff;
}
#user-input::placeholder { color: #7c8698; }

button {
  background: linear-gradient(135deg, #007bff, #00aaff);
  color: #fff;
  border: none;
  padding: 12px 20px;                 /* compacto y cómodo */
  font-size: 15px;
  cursor: pointer;
  border-radius: 8px;                 /* NO ovalado */
  box-shadow: 0 3px 12px rgba(0,123,255,0.4);
  transition: box-shadow .2s, transform .08s ease-in;
}
button:hover { box-shadow: 0 3px 15px rgba(0,123,255,0.7); }
button:active { transform: translateY(1px); }

/* ----- Animación suave ----- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----- Responsivo (iPhone / móviles) ----- */
@media (max-width: 768px) {
  :root{ --header-h: 92px; }          /* header más alto en móvil */
  .header-inner {
    position: static;                 /* resetea absolute del título */
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    min-height: unset;
  }
  .header .title {
    position: static;
    transform: none;
    text-align: center;
  }
  .header .logo {
    margin: 0 auto;
    height: 36px;
  }

  .chat-container {
    max-width: 100%;
    border-radius: 8px;               /* bordes suaves en móvil */
    /* altura ya se calcula con svh/dvh y safe-area */
  }

  #chat-box { font-size: 14px; padding: 14px; }
  #user-input { font-size: 14px; padding: 12px; border-radius: 10px; }
  button { font-size: 14px; padding: 11px 16px; border-radius: 8px; }
}

/* ----- Ultra pequeño (iPhone SE, 320-360px) ----- */
@media (max-width: 380px) {
  .header .title h1 { font-size: 18px; }
  .header .title p  { font-size: 12px; }
  .message { max-width: 90%; }
}
/* Enlaces dentro de los mensajes del chat */
.message a {
  color: #0ea5e9;
  text-decoration: underline;
  word-break: break-word;   /* por si la URL es larguísima */
}
.message a:hover {
  text-decoration: none;
}


