/* Amanda - asistente virtual de Fotografo La Serena
   Diseno alineado a la marca: fondo #07080a, tinta #101114, panel #15171c,
   panel-2 #1c1f26, papel #f8f8f6, plata #d7d8d5, gris #a8abb2,
   rojo #ff1616, rojo oscuro #b90909, linea #262a32. */

.ama-root {
  position: fixed;
  right: 20px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  /* Sobre la cabecera fija (100), para que no intercepte el cierre. */
  z-index: 110;
  font-family: inherit;
  color: #f8f8f6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Boton flotante ---------- */
.ama-launch {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  padding: 0;
  -webkit-appearance: none; appearance: none;
  font-family: inherit;
  border: 1px solid #ff1616;
  border-radius: 50%;
  background: #101114;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(255, 22, 22, 0.45);
  cursor: pointer;
  transition: transform 180ms ease-out, background 180ms ease-out;
  animation: amaPulse 4s ease-out infinite;
}
.ama-launch:hover { transform: translateY(-2px); background: #15171c; }
.ama-launch:focus-visible { outline: 3px solid #ff1616; outline-offset: 3px; }
.ama-launch img { width: 44px; height: 44px; border-radius: 50%; display: block; }
.ama-launch .ama-dot {
  position: absolute;
  right: 1px; bottom: 1px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #1da851; border: 2px solid #101114;
}
.ama-launch::after {
  content: attr(data-tip);
  position: absolute;
  right: 70px;
  white-space: nowrap;
  background: #15171c;
  color: #f8f8f6;
  border: 1px solid #262a32;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px; font-weight: 600;
  opacity: 0;
  transform: translateX(6px);
  pointer-events: none;
  transition: opacity 160ms ease-out, transform 160ms ease-out;
}
.ama-launch:hover::after, .ama-launch:focus-visible::after { opacity: 1; transform: translateX(0); }
@keyframes amaPulse {
  0% { box-shadow: 0 12px 28px rgba(0,0,0,0.5), 0 0 0 0 rgba(255,22,22,0.40); }
  70% { box-shadow: 0 12px 28px rgba(0,0,0,0.5), 0 0 0 14px rgba(255,22,22,0); }
  100% { box-shadow: 0 12px 28px rgba(0,0,0,0.5), 0 0 0 0 rgba(255,22,22,0); }
}

/* ---------- Panel ---------- */
.ama-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: min(384px, calc(100vw - 32px));
  /* Reservar la base del widget (88px), la separacion (74px) y 18px arriba. */
  height: min(580px, calc(100vh - 180px - env(safe-area-inset-bottom, 0px)));
  height: min(580px, calc(100dvh - 180px - env(safe-area-inset-bottom, 0px)));
  display: none;
  grid-template-rows: auto 1fr auto;
  background: #101114;
  border: 1px solid #262a32;
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.62);
  overflow: hidden;
  transform-origin: bottom right;
}
.ama-root.ama-open .ama-panel { display: grid; animation: amaIn 200ms ease-out; }
@keyframes amaIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

.ama-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px 13px 16px;
  background: #15171c;
  border-bottom: 1px solid #262a32;
}
.ama-head::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: #ff1616; }
.ama-head img { width: 42px; height: 42px; border-radius: 50%; display: block; border: 1px solid #262a32; }
.ama-head .ama-id { flex: 1 1 0; min-width: 0; }
.ama-head .ama-name { font-size: 16px; font-weight: 700; line-height: 1.2; letter-spacing: 0.1px; }
.ama-head .ama-role { font-size: 12px; color: #a8abb2; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.ama-head .ama-role::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #1da851; }
.ama-close {
  width: 36px; height: 36px; padding: 0; flex: 0 0 auto;
  display: grid; place-items: center;
  -webkit-appearance: none; appearance: none;
  background: #15171c; color: #d7d8d5;
  border: 1px solid #262a32; border-radius: 6px;
  font-family: inherit; font-size: 18px; line-height: 1; cursor: pointer;
  transition: border-color 140ms ease-out, color 140ms ease-out, background 140ms ease-out;
}
.ama-close:hover { border-color: #d7d8d5; color: #fff; }
.ama-close:focus-visible { outline: 3px solid #ff1616; outline-offset: 1px; }
.ama-msg a { color: inherit; text-decoration: underline; overflow-wrap: anywhere; }

/* ---------- Conversacion ---------- */
.ama-log {
  min-height: 0;
  padding: 18px 16px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  align-content: start;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(255, 22, 22, 0.06), transparent 60%),
    #101114;
  scrollbar-width: thin;
  scrollbar-color: #333844 transparent;
}
.ama-log::-webkit-scrollbar { width: 8px; }
.ama-log::-webkit-scrollbar-thumb { background: #2a2f38; border-radius: 8px; }
.ama-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ama-msg.ama-user {
  justify-self: end;
  background: #ff1616;
  color: #101114;
  font-weight: 600;
  border-bottom-right-radius: 4px;
}
.ama-msg.ama-bot {
  justify-self: start;
  background: #1c1f26;
  color: #f8f8f6;
  border: 1px solid #262a32;
  border-bottom-left-radius: 4px;
}
.ama-msg.ama-note {
  justify-self: center;
  color: #a8abb2; font-size: 13px; text-align: center;
  background: transparent; border: 0; max-width: 100%;
}

.ama-typing { justify-self: start; display: flex; gap: 4px; padding: 14px 6px; }
.ama-typing span { width: 7px; height: 7px; border-radius: 50%; background: #a8abb2; animation: amaBlink 1.2s infinite ease-in-out; }
.ama-typing span:nth-child(2) { animation-delay: 0.15s; }
.ama-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes amaBlink { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

/* ---------- Entrada ---------- */
.ama-foot { border-top: 1px solid #262a32; background: #15171c; padding: 10px 10px 8px; }
.ama-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.ama-input {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  padding: 12px 13px;
  font-size: 16px;
  font-family: inherit;
  color: #f8f8f6;
  background: #101114;
  border: 1px solid #262a32;
  border-radius: 8px;
  transition: border-color 140ms ease-out;
}
.ama-input::placeholder { color: #7c8089; }
.ama-input:focus { outline: none; border-color: #ff1616; }
.ama-send {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  -webkit-appearance: none; appearance: none;
  font-family: inherit;
  background: #ff1616; color: #101114;
  border: 0; border-radius: 8px; cursor: pointer;
  transition: background 140ms ease-out, transform 140ms ease-out;
}
.ama-send:hover { background: #b90909; transform: translateY(-1px); }
.ama-send:disabled { opacity: 0.45; cursor: default; transform: none; }
.ama-send:focus-visible { outline: 3px solid #f8f8f6; outline-offset: 1px; }
.ama-whatsapp { display: block; margin: 9px 2px 0; color: #f8f8f6; font-size: 12px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.ama-whatsapp:hover { color: #ff6c6c; }
.ama-whatsapp:focus-visible { outline: 2px solid #ff1616; outline-offset: 2px; }

/* ---------- Movil ---------- */
@media (max-width: 480px) {
  .ama-root { right: 14px; bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
  .ama-launch { width: 54px; height: 54px; }
  .ama-launch img { width: 40px; height: 40px; }
  .ama-launch::after { display: none; }
  .ama-panel {
    position: fixed;
    left: 10px; right: 10px; bottom: 10px;
    width: auto;
    height: min(80vh, 640px);
    height: min(80dvh, 640px);
    transform-origin: bottom center;
  }
  /* Con el panel abierto, el boton flotante taparia el campo de texto. */
  .ama-root.ama-open .ama-launch { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ama-launch, .ama-send { transition: none; animation: none; }
  .ama-root.ama-open .ama-panel { animation: none; }
  .ama-typing span { animation: none; opacity: 0.6; }
}
