/* ============================================================================
   PANDORAW · chat_app.css  —  el chat como APP, no como widget
   Amber 💎 · 31/10/2026 · "el chat debe de ser tipo app porque como esta no
   se entiende nada como funciona" (oktanuz)

   ---------------------------------------------------------------------------
   QUE CAMBIA Y POR QUE
   ---------------------------------------------------------------------------
   ANTES: un panel flotante chiquito, esquina inferior derecha, con burbujas
   apretadas y un input que no se distinguia. No se entendia donde escribir
   ni quien hablaba.

   AHORA: pantalla completa tipo WhatsApp/Telegram.
     - Cabecera clara con quien es y su estado
     - Mensajes con avatar y nombre (se sabe QUIEN habla)
     - Burbujas alineadas: bot a la izquierda, tu a la derecha
     - Zona de escribir grande, pegada abajo, con boton visible
     - Indicador de "escribiendo" con puntitos animados
     - Sugerencias como chips tocables al inicio

   Se carga DESPUES de synth.css para ganarle sin pelearse.
   ============================================================================ */


/* ============================================================================
   1. LA BURBUJA FLOTANTE — el boton de abrir
   ============================================================================ */
.chat-burbuja {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .85em 1.35em;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-family: "Chakra Petch", sans-serif;
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .06em;
  color: #04121a;
  background: linear-gradient(135deg, #05d9e8 0%, #00b3c4 100%);
  box-shadow:
    0 0 0 1px rgba(5,217,232,.5),
    0 8px 26px rgba(5,217,232,.42),
    0 0 44px rgba(5,217,232,.28);
  transition: transform .22s cubic-bezier(.2,.8,.3,1), box-shadow .22s;
  -webkit-tap-highlight-color: transparent;
}

.chat-burbuja:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow:
    0 0 0 1px rgba(5,217,232,.7),
    0 12px 34px rgba(5,217,232,.55),
    0 0 60px rgba(5,217,232,.38);
}

.chat-burbuja:active {
  transform: translateY(-1px) scale(.99);
}

.chat-burbuja.oculto {
  display: none;
}


/* ============================================================================
   2. EL PANEL — pantalla completa tipo app
   ============================================================================ */
.chat-panel {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  background: #08010f;
  animation: chatEntra .26s cubic-bezier(.2,.8,.3,1);
}

.chat-panel[hidden] {
  display: none !important;
}

@keyframes chatEntra {
  from { opacity: 0; transform: translateY(18px) scale(.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}


/* ---------------------------------------------------------------------------
   2.1 CABECERA — quien es y su estado
   --------------------------------------------------------------------------- */
.chat-cab {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .85rem 1rem;
  background: linear-gradient(180deg, rgba(30,1,64,.98) 0%, rgba(20,0,43,.98) 100%);
  border-bottom: 1px solid rgba(5,217,232,.32);
  box-shadow: 0 4px 22px rgba(0,0,0,.55);
}

.chat-cab img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: contain;
  background: rgba(8,1,15,.85);
  padding: 5px;
  border: 1px solid rgba(5,217,232,.45);
  flex: 0 0 auto;
}

.chat-cab > div {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-cab strong {
  font-family: "Orbitron", sans-serif;
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .07em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-estado {
  font-family: "Chakra Petch", sans-serif;
  font-size: .7rem;
  color: #05d9e8;
  letter-spacing: .04em;
}

.chat-cab button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,42,109,.42);
  border-radius: 50%;
  background: rgba(255,42,109,.10);
  color: #ff5c8a;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background .2s, color .2s, transform .2s;
  -webkit-tap-highlight-color: transparent;
}

.chat-cab button:hover {
  background: #ff2a6d;
  color: #fff;
  transform: rotate(90deg);
}


/* ---------------------------------------------------------------------------
   2.2 CUERPO — los mensajes
   --------------------------------------------------------------------------- */
.chat-cuerpo {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.1rem 1rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(181,55,242,.10) 0%, transparent 55%),
    #08010f;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* la barra de scroll, discreta */
.chat-cuerpo::-webkit-scrollbar { width: 6px; }
.chat-cuerpo::-webkit-scrollbar-track { background: transparent; }
.chat-cuerpo::-webkit-scrollbar-thumb {
  background: rgba(5,217,232,.28);
  border-radius: 3px;
}


/* ---------------------------------------------------------------------------
   2.3 BURBUJAS — se sabe QUIEN habla
   --------------------------------------------------------------------------- */
.msg {
  max-width: 82%;
  padding: .78rem 1rem;
  border-radius: 16px;
  font-size: .92rem;
  line-height: 1.62;
  word-wrap: break-word;
  overflow-wrap: break-word;
  position: relative;
  animation: msgEntra .22s ease-out;
}

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

/* --- el bot: izquierda, con acento cian --- */
.msg.bot {
  align-self: flex-start;
  background: linear-gradient(135deg, rgba(30,1,64,.95) 0%, rgba(20,0,43,.95) 100%);
  border: 1px solid rgba(5,217,232,.28);
  border-bottom-left-radius: 5px;
  color: #e8dcff;
  box-shadow: 0 3px 14px rgba(0,0,0,.35);
}

/* --- tu: derecha, con acento magenta --- */
.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #ff2a6d 0%, #c4005a 100%);
  border: 1px solid rgba(255,92,138,.5);
  border-bottom-right-radius: 5px;
  color: #fff;
  box-shadow: 0 3px 18px rgba(255,42,109,.32);
}

/* --- el bot pensando --- */
.msg.pensando {
  align-self: flex-start;
  background: rgba(30,1,64,.85);
  border: 1px solid rgba(5,217,232,.22);
  border-bottom-left-radius: 5px;
  color: #05d9e8;
  font-style: italic;
  font-size: .85rem;
}

/* los puntitos animados */
.puntos::after {
  content: "";
  display: inline-block;
  width: 1.4em;
  text-align: left;
  animation: puntos 1.2s steps(4, end) infinite;
}

@keyframes puntos {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
  100% { content: ""; }
}

/* lo que va dentro de las burbujas */
.msg strong { color: #fff; font-weight: 700; }
.msg.user strong { color: #fff; }
.msg a { color: #05d9e8; text-decoration: underline; }
.msg.user a { color: #fff; }
.msg code {
  background: rgba(0,0,0,.4);
  padding: .12em .4em;
  border-radius: 4px;
  font-size: .88em;
}
.msg ul, .msg ol { margin: .5em 0; padding-left: 1.3em; }
.msg li { margin-bottom: .3em; }
.msg p:last-child { margin-bottom: 0; }
.msg p:first-child { margin-top: 0; }


/* ---------------------------------------------------------------------------
   2.4 SUGERENCIAS — chips tocables
   --------------------------------------------------------------------------- */
.sugerencias {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .3rem;
  padding-bottom: .4rem;
}

.sugerencias button {
  font-family: "Chakra Petch", sans-serif;
  font-size: .8rem;
  font-weight: 600;
  padding: .6em 1em;
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(181,55,242,.45);
  background: rgba(181,55,242,.10);
  color: #d16bff;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}

.sugerencias button:hover {
  background: #b537f2;
  color: #fff;
  border-color: #b537f2;
  transform: translateY(-1px);
}

.sugerencias button:active {
  transform: translateY(0) scale(.98);
}


/* ---------------------------------------------------------------------------
   2.5 PIE — donde se escribe
   --------------------------------------------------------------------------- */
.chat-pie {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem .9rem calc(.75rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(20,0,43,.98) 0%, rgba(30,1,64,.98) 100%);
  border-top: 1px solid rgba(5,217,232,.32);
  box-shadow: 0 -4px 22px rgba(0,0,0,.5);
}

.chat-pie input {
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
  padding: 0 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(5,217,232,.32);
  background: rgba(8,1,15,.92);
  color: #e8dcff;
  font-family: "Chakra Petch", sans-serif;
  font-size: 16px; /* 16px = iOS no hace zoom al escribir */
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.chat-pie input::placeholder {
  color: #6d5a92;
}

.chat-pie input:focus {
  border-color: rgba(5,217,232,.75);
  box-shadow: 0 0 0 3px rgba(5,217,232,.14);
}

.chat-pie button {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #04121a;
  background: linear-gradient(135deg, #05d9e8 0%, #00b3c4 100%);
  box-shadow: 0 4px 16px rgba(5,217,232,.42);
  transition: transform .18s, box-shadow .18s, opacity .18s;
  -webkit-tap-highlight-color: transparent;
}

.chat-pie button:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 6px 22px rgba(5,217,232,.6);
}

.chat-pie button:active:not(:disabled) {
  transform: scale(.96);
}

.chat-pie button:disabled {
  opacity: .42;
  cursor: not-allowed;
  box-shadow: none;
}


/* ============================================================================
   3. CELULAR — ajustes finos
   ============================================================================ */
@media (max-width: 900px) {

  /* la burbuja: solo el icono, redonda, arriba de la barra inferior */
  .chat-burbuja {
    right: 14px;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
  }

  .chat-burbuja span {
    display: none;
  }

  /* el panel deja libre la barra inferior */
  .chat-panel {
    inset: 0 0 calc(76px + env(safe-area-inset-bottom, 0px)) 0;
  }

  .chat-cab {
    padding: .7rem .8rem;
  }

  .chat-cab img {
    width: 36px;
    height: 36px;
  }

  .chat-cab strong {
    font-size: .76rem;
  }

  .chat-estado {
    font-size: .66rem;
  }

  .chat-cuerpo {
    padding: .9rem .8rem 1.2rem;
    gap: .7rem;
  }

  .msg {
    max-width: 88%;
    font-size: .9rem;
    padding: .7rem .9rem;
  }

  .sugerencias button {
    font-size: .76rem;
    padding: .55em .9em;
  }

  .chat-pie {
    padding: .6rem .7rem calc(.6rem + env(safe-area-inset-bottom, 0px));
    gap: .5rem;
  }

  .chat-pie input {
    height: 46px;
    padding: 0 .95rem;
  }

  .chat-pie button {
    width: 46px;
    height: 46px;
  }
}


/* ============================================================================
   4. ESCRITORIO GRANDE — el panel no ocupa TODA la pantalla
   ============================================================================ */
@media (min-width: 901px) {

  .chat-panel {
    inset: auto 24px 24px auto;
    width: 430px;
    height: min(680px, calc(100vh - 48px));
    border-radius: 20px;
    border: 1px solid rgba(5,217,232,.32);
    box-shadow:
      0 24px 70px rgba(0,0,0,.75),
      0 0 60px rgba(5,217,232,.16);
    overflow: hidden;
  }

  .chat-cab {
    border-radius: 20px 20px 0 0;
  }

  .chat-pie {
    border-radius: 0 0 20px 20px;
  }
}


/* ============================================================================
   5. ACCESIBILIDAD
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  .chat-panel,
  .msg,
  .chat-burbuja,
  .chat-pie button,
  .sugerencias button {
    animation: none !important;
    transition: none !important;
  }
  .chat-cuerpo {
    scroll-behavior: auto;
  }
}
