/**
 * COV Chatbot — widget público.
 *
 * Variables CSS:
 *   --cov-bot-color   color principal (se inyecta desde JS según panel admin)
 */

.cov-bot {
  --cov-bot-color: #2877fa;
  --cov-bot-bg: #ffffff;
  --cov-bot-fg: #1d2327;
  --cov-bot-muted: #50575e;
  --cov-bot-border: rgba(0, 0, 0, 0.08);
  --cov-bot-bg-me: var(--cov-bot-color);
  --cov-bot-bg-bot: #f4f5f7;

  position: fixed;
  bottom: 140px;
  z-index: 99998;
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--cov-bot-fg);
}
.cov-bot--right { right: 24px; }
.cov-bot--left  { left:  24px; }

/* ─── Burbuja flotante ────────────────────────────────────────────── */
.cov-bot-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  background: var(--cov-bot-color);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 0 0 4px rgba(0, 0, 0, 0.04);
  transition: transform 0.18s, box-shadow 0.18s;
}
.cov-bot-bubble:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.24);
}
.cov-bot-bubble:active { transform: scale(0.96); }
.cov-bot-bubble-icon {
  font-size: 28px;
  line-height: 1;
}
.cov-bot-bubble-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--cov-bot-color);
  opacity: 0.4;
  animation: cov-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
.cov-bot-bubble.is-open .cov-bot-bubble-pulse { display: none; }
@keyframes cov-pulse {
  0%   { transform: scale(1);   opacity: 0.5; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ─── Panel del chat ──────────────────────────────────────────────── */
.cov-bot-panel {
  position: absolute;
  bottom: 76px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: var(--cov-bot-bg);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18), 0 0 0 1px var(--cov-bot-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cov-pop 0.18s ease-out;
}
.cov-bot--right .cov-bot-panel { right: 0; }
.cov-bot--left  .cov-bot-panel { left:  0; }
@keyframes cov-pop {
  from { transform: translateY(12px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* ─── Header ──────────────────────────────────────────────────────── */
.cov-bot-header {
  background: var(--cov-bot-color);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.cov-bot-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.cov-bot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.cov-bot-name {
  font-weight: 600;
  font-size: 15px;
}
.cov-bot-online {
  font-size: 12px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
}
.cov-bot-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px #4ade80;
}
.cov-bot-header-actions {
  display: flex;
  gap: 4px;
}
.cov-bot-iconbtn {
  background: rgba(255, 255, 255, 0.15);
  border: 0;
  color: #fff;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.cov-bot-iconbtn:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ─── Mensajes ────────────────────────────────────────────────────── */
.cov-bot-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cov-bot-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: cov-msgin 0.18s ease-out;
}
@keyframes cov-msgin {
  from { transform: translateY(4px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
.cov-bot-msg--bot {
  background: var(--cov-bot-bg-bot);
  color: var(--cov-bot-fg);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.cov-bot-msg--me {
  background: var(--cov-bot-bg-me);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.cov-bot-msg--me a { color: #fff; text-decoration: underline; }
.cov-bot-msg--bot a { color: var(--cov-bot-color); text-decoration: underline; }
.cov-bot-msg--error {
  background: #fee2e2;
  color: #991b1b;
}

/* Typing indicator */
.cov-bot-typing {
  background: var(--cov-bot-bg-bot);
  align-self: flex-start;
  padding: 12px 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cov-bot-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cov-bot-muted);
  animation: cov-typing 1.2s ease-in-out infinite;
}
.cov-bot-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.cov-bot-typing-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes cov-typing {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ─── Handoff (botones "Hablar con humano") ──────────────────────── */
.cov-bot-handoff {
  padding: 10px 16px;
  border-top: 1px solid var(--cov-bot-border);
  background: #fff;
}
.cov-bot-handoff-msg {
  font-size: 12px;
  color: var(--cov-bot-muted);
  margin-bottom: 8px;
}
.cov-bot-handoff-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cov-bot-handoff-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  text-decoration: none;
  background: #25d366;
  color: #fff;
  font-weight: 500;
}
.cov-bot-handoff-btn:hover { opacity: 0.9; }
.cov-bot-handoff-btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  gap: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
}
.cov-bot-handoff-btn--icon svg {
  display: block;
  flex-shrink: 0;
}
.cov-bot-handoff-btn--ghost {
  background: transparent;
  color: var(--cov-bot-color);
  border: 1px solid var(--cov-bot-border);
}
.cov-bot-handoff-btn--ghost:hover {
  background: var(--cov-bot-bg-bot);
}

.cov-bot-handoff-saved {
  font-size: 12px;
  color: #065f46;
  background: #d1fae5;
  padding: 4px 10px;
  border-radius: 999px;
}

/* Form de identificación */
.cov-bot-identify-form {
  margin-top: 10px;
  padding: 10px;
  background: var(--cov-bot-bg-bot);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cov-bot-identify-intro {
  font-size: 12px;
  color: var(--cov-bot-fg);
  line-height: 1.45;
}
.cov-bot-identify-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--cov-bot-border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  font-family: inherit;
}
.cov-bot-identify-input:focus {
  outline: none;
  border-color: var(--cov-bot-color);
}
.cov-bot-identify-hint {
  font-size: 11px;
  color: var(--cov-bot-muted);
  line-height: 1.4;
}
.cov-bot-identify-error {
  font-size: 12px;
  color: #b91c1c;
  background: #fee2e2;
  padding: 6px 10px;
  border-radius: 6px;
}
.cov-bot-identify-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

/* ─── Footer (input + enviar) ─────────────────────────────────────── */
.cov-bot-footer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--cov-bot-border);
  background: #fff;
}
.cov-bot-input {
  flex: 1;
  border: 1px solid var(--cov-bot-border);
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  outline: none;
  background: #f4f5f7;
  color: var(--cov-bot-fg);
  max-height: 140px;
  min-height: 38px;
}
.cov-bot-input:focus {
  border-color: var(--cov-bot-color);
  background: #fff;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--cov-bot-color) 18%, transparent);
}
.cov-bot-send {
  background: var(--cov-bot-color);
  color: #fff;
  border: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}
.cov-bot-send:hover { transform: scale(1.06); }
.cov-bot-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── Branding ────────────────────────────────────────────────────── */
.cov-bot-branding {
  text-align: center;
  font-size: 10px;
  color: var(--cov-bot-muted);
  padding: 4px 0 6px;
  background: #fff;
  border-top: 1px solid var(--cov-bot-border);
  opacity: 0.7;
}
.cov-bot-branding strong {
  font-weight: 600;
  color: var(--cov-bot-fg);
}

/* ─── Responsive: móvil pantalla completa ─────────────────────────── */
@media (max-width: 540px) {
  .cov-bot {
    bottom: 132px; /* sube para no tapar el widget de idiomas */
  }
  .cov-bot--right { right: 12px; }
  .cov-bot--left  { left:  12px; }

  .cov-bot-panel {
    position: fixed;
    bottom: 204px; /* 132px chatbot + 60px burbuja + 12px margen */
    left: 12px;
    right: 12px;
    width: auto;
    height: calc(100vh - 170px);
    max-height: none;
  }
}
