/* Widget de chat de Simian Army. Mismos colores que la web (src/layouts/Layout.astro). */
.sa-chat {
  --sa-paper: #f1f2ee;
  --sa-paper-2: #e6e8e2;
  --sa-ink: #16193a;
  --sa-muted: #5c6075;
  --sa-rule: #cfd2ca;
  --sa-accent: #2b3ae8;
  --sa-on-accent: #ffffff;
  --sa-wa: #1f8f4e;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  font-family: 'Archivo', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--sa-ink);
}
@media (prefers-color-scheme: dark) {
  .sa-chat {
    --sa-paper: #0e1029;
    --sa-paper-2: #151838;
    --sa-ink: #e6e8f2;
    --sa-muted: #9a9ebb;
    --sa-rule: #2b2f57;
    --sa-accent: #8b95ff;
    --sa-on-accent: #0e1029;
    --sa-wa: #4cc985;
  }
}
.sa-chat *, .sa-chat *::before, .sa-chat *::after { box-sizing: border-box; }

.sa-chat-launcher {
  display: block;
  margin-left: auto;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--sa-accent);
  color: var(--sa-on-accent);
  font: inherit;
  font-weight: 600;
  font-stretch: 112%;
  cursor: pointer;
  box-shadow: 0 6px 24px rgb(22 25 58 / 0.25);
}
.sa-chat.is-open .sa-chat-launcher { display: none; }

.sa-chat-panel {
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100dvh - 40px));
  background: var(--sa-paper);
  border: 1px solid var(--sa-rule);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 48px rgb(22 25 58 / 0.25);
}
.sa-chat-panel[hidden] { display: none; }

.sa-chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--sa-rule);
  font-stretch: 112%;
}
.sa-chat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sa-accent); }
.sa-chat-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--sa-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.sa-chat-close:hover { background: var(--sa-paper-2); color: var(--sa-ink); }

.sa-chat-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  overflow-y: auto;
}
.sa-chat-beta {
  border: 1px solid var(--sa-accent);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--sa-ink);
  font-size: 13px;
  line-height: 1.4;
}
.sa-chat-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sa-chat-bot { align-self: flex-start; background: var(--sa-paper-2); border-bottom-left-radius: 4px; }
.sa-chat-user { align-self: flex-end; background: var(--sa-accent); color: var(--sa-on-accent); border-bottom-right-radius: 4px; }
.sa-chat-msg a { color: inherit; }

.sa-chat-typing { display: flex; gap: 4px; padding: 13px; }
.sa-chat-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sa-muted);
  animation: sa-chat-blink 1.2s infinite both;
}
.sa-chat-typing i:nth-child(2) { animation-delay: 0.2s; }
.sa-chat-typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes sa-chat-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.sa-chat-handoff {
  align-self: flex-start;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--sa-accent);
  color: var(--sa-on-accent);
  font-weight: 600;
  text-decoration: none;
}
.sa-chat-whatsapp { background: var(--sa-wa); color: #fff; }
@media (prefers-color-scheme: dark) { .sa-chat-whatsapp { color: #0e1029; } }

.sa-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--sa-rule);
}
.sa-chat-input {
  flex: 1;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--sa-rule);
  border-radius: 10px;
  background: var(--sa-paper);
  color: var(--sa-ink);
  font: inherit;
  resize: none;
}
.sa-chat-input:focus { outline: 2px solid var(--sa-accent); outline-offset: -1px; }
.sa-chat-send {
  height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--sa-accent);
  color: var(--sa-on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.sa-chat-send:disabled, .sa-chat-input:disabled { opacity: 0.5; cursor: default; }
.sa-chat-trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.sa-chat-foot { padding: 0 14px 12px; color: var(--sa-muted); font-size: 12px; }
.sa-chat-foot a { color: var(--sa-accent); }

@media (max-width: 480px) {
  .sa-chat { right: 16px; bottom: 16px; }
  .sa-chat.is-open { inset: 0; }
  .sa-chat.is-open .sa-chat-panel { width: 100%; height: 100dvh; border: 0; border-radius: 0; }
}
