/* ✦ Siggy — Asistente de Voz IA
   Widget flotante con voz bidireccional.
   Se carga globalmente desde base.html. */

/* ── Burbuja flotante ─────────────────────────────────────── */
.siga-ai-bubble {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10050;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #7c5cff, #b57bff);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(124, 92, 255, 0.35),
              0 4px 10px rgba(0,0,0,0.15);
  transition: transform .18s ease, box-shadow .2s ease;
}
.siga-ai-bubble:hover { transform: translateY(-2px) scale(1.04); }
.siga-ai-bubble.is-active { transform: rotate(10deg) scale(1.05); }

/* Animación de "hablando" — pulso azul alrededor */
.siga-ai-bubble.is-speaking {
  animation: siga-ai-speak-pulse 1.2s ease-in-out infinite;
}
@keyframes siga-ai-speak-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 92, 255, 0.5), 0 12px 30px rgba(124, 92, 255, 0.35); }
  50%      { box-shadow: 0 0 0 14px rgba(124, 92, 255, 0), 0 12px 30px rgba(124, 92, 255, 0.35); }
}

/* ── Panel principal ───────────────────────────────────────── */
.siga-ai-panel {
  position: fixed;
  right: 22px;
  bottom: 92px;
  z-index: 10050;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: var(--bg-elev, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 16px;
  box-shadow: 0 32px 72px -12px rgba(0,0,0,0.35),
              0 8px 24px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: siga-ai-in .25s cubic-bezier(.2,.8,.2,1);
}
.siga-ai-panel[hidden],
.siga-ai-panel.is-hidden {
  display: none !important;
}
[data-theme="dark"] .siga-ai-panel {
  background: #17171b;
  border-color: rgba(255,255,255,0.08);
}

@keyframes siga-ai-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ────────────────────────────────────────────────── */
.siga-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, rgba(0,0,0,0.08));
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.08), transparent);
}
.siga-ai-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text, #0b0b0c);
}
[data-theme="dark"] .siga-ai-title { color: #f4f4f6; }

.siga-ai-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.siga-ai-tts-toggle {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  opacity: 0.6;
  transition: opacity .15s;
}
.siga-ai-tts-toggle:hover { opacity: 1; background: rgba(0,0,0,0.06); }
.siga-ai-tts-toggle.is-on { opacity: 1; }
[data-theme="dark"] .siga-ai-tts-toggle:hover { background: rgba(255,255,255,0.08); }

.siga-ai-close {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-dim, #888);
  padding: 4px 8px;
  border-radius: 6px;
}
.siga-ai-close:hover { background: rgba(0,0,0,0.06); }

/* ── Mensajes ──────────────────────────────────────────────── */
.siga-ai-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.siga-ai-msg { display: flex; }
.siga-ai-msg-user { justify-content: flex-end; }
.siga-ai-msg-assistant { justify-content: flex-start; }

.siga-ai-bubble-txt {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
}
.siga-ai-msg-user .siga-ai-bubble-txt { white-space: pre-line; }

/* ── Markdown rendered inside assistant bubbles ──────────── */
.siga-ai-msg-assistant .siga-ai-bubble-txt p {
  margin: 0 0 6px;
}
.siga-ai-msg-assistant .siga-ai-bubble-txt p:last-child { margin-bottom: 0; }
.siga-ai-msg-assistant .siga-ai-bubble-txt strong {
  font-weight: 600;
  color: inherit;
}
.siga-ai-msg-assistant .siga-ai-bubble-txt em { font-style: italic; }
.siga-ai-msg-assistant .siga-ai-bubble-txt ul {
  margin: 4px 0 8px 0;
  padding-left: 18px;
  list-style: disc;
}
.siga-ai-msg-assistant .siga-ai-bubble-txt li {
  margin-bottom: 3px;
}
.siga-ai-msg-assistant .siga-ai-bubble-txt br + br { display: none; }
.siga-ai-msg-user .siga-ai-bubble-txt {
  background: linear-gradient(135deg, #7c5cff, #b57bff);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.siga-ai-msg-assistant .siga-ai-bubble-txt {
  background: rgba(0,0,0,0.06);
  color: var(--text, #0b0b0c);
  border-bottom-left-radius: 4px;
}
[data-theme="dark"] .siga-ai-msg-assistant .siga-ai-bubble-txt {
  background: rgba(255,255,255,0.08);
  color: #f4f4f6;
}

/* ── Botones de acción dentro de mensajes ──────────────────── */
.siga-ai-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.siga-ai-action-btn {
  padding: 5px 14px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  background: #fff;
  color: var(--text, #0b0b0c);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.siga-ai-action-btn:hover {
  background: rgba(124, 92, 255, 0.08);
  transform: translateY(-1px);
}
.siga-ai-action-btn.primary {
  background: linear-gradient(135deg, #7c5cff, #b57bff);
  color: #fff;
  border-color: transparent;
}
.siga-ai-action-btn.primary:hover { filter: brightness(1.1); }
.siga-ai-action-btn.cancel {
  background: transparent;
  color: #888;
  border-color: rgba(0,0,0,0.1);
}
.siga-ai-action-btn.cancel:hover { background: rgba(0,0,0,0.04); }
[data-theme="dark"] .siga-ai-action-btn {
  background: rgba(255,255,255,0.06);
  color: #f4f4f6;
  border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .siga-ai-action-btn.primary {
  background: linear-gradient(135deg, #7c5cff, #b57bff);
  color: #fff;
}

/* ── Status line ───────────────────────────────────────────── */
.siga-ai-status {
  min-height: 18px;
  padding: 0 16px 6px;
  font-size: 12px;
  color: var(--text-dim, #888);
  font-style: italic;
}

/* ── Actions row (input + mic + send) ──────────────────────── */
.siga-ai-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 6px;
  border-top: 1px solid var(--border, rgba(0,0,0,0.08));
}

.siga-ai-input {
  flex: 1;
  border: 1px solid var(--border, rgba(0,0,0,0.12));
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  background: var(--bg, #fff);
  color: var(--text, #0b0b0c);
  outline: none;
}
.siga-ai-input:focus { border-color: #7c5cff; box-shadow: 0 0 0 3px rgba(124,92,255,0.15); }
[data-theme="dark"] .siga-ai-input { background: #0f0f12; color: #f4f4f6; border-color: rgba(255,255,255,0.12); }

.siga-ai-mic, .siga-ai-send {
  flex: 0 0 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.06);
  color: var(--text, #0b0b0c);
  font-size: 18px;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.siga-ai-mic:hover, .siga-ai-send:hover { background: rgba(0,0,0,0.1); transform: translateY(-1px); }
[data-theme="dark"] .siga-ai-mic, [data-theme="dark"] .siga-ai-send {
  background: rgba(255,255,255,0.08); color: #f4f4f6;
}

.siga-ai-mic.is-rec {
  background: #ff3b5c;
  color: #fff;
  animation: siga-ai-rec 1.1s ease-in-out infinite;
}
@keyframes siga-ai-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 92, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(255, 59, 92, 0); }
}

.siga-ai-send {
  background: linear-gradient(135deg, #7c5cff, #b57bff);
  color: #fff;
}
.siga-ai-send:hover { filter: brightness(1.08); }

/* ── Hint bar ──────────────────────────────────────────────── */
.siga-ai-hint {
  font-size: 11px;
  color: var(--text-dim, #888);
  padding: 4px 16px 12px;
  line-height: 1.4;
}
.siga-ai-hint a { color: #7c5cff; text-decoration: none; font-weight: 500; }
.siga-ai-hint a:hover { text-decoration: underline; }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .siga-ai-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 80px;
    height: calc(100vh - 120px);
  }
}
