/* ============================================================
   MindIA Widget — Estilos completos v2.0
   Botón flotante + Panel drawer azul marino
   Compatible WordPress 6.0+
   ============================================================ */

/* ── Variables ───────────────────────────────────────────── */
:root {
  --md-z:       99999;
  --md-btn-bg:  linear-gradient(145deg, #1e3a8a 0%, #1a2a6c 50%, #0f172a 100%);
  --md-panel-bg:radial-gradient(circle at 50% 0%, #0d1a3a, #060e25 70%);
  --md-blue:    #3b82f6;
  --md-blue-dk: #1d4ed8;
  --md-text:    #e0f0ff;
  --md-sub:     #93c5fd;
  --md-radius:  22px;
  --md-w:       400px;
}

/* ── Botón flotante ──────────────────────────────────────── */
#mindia-btn {
  position: fixed;
  bottom: 100px;
  right: 20px;
  z-index: var(--md-z);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--md-btn-bg);
  border: 2px solid rgba(255,255,255,.15);
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(10,20,80,.45), 0 2px 6px rgba(0,0,0,.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: transform .2s ease, box-shadow .2s ease;
  padding: 0;
  outline: none;
}
#mindia-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 12px 36px rgba(10,20,80,.55);
}
#mindia-btn:focus-visible { outline: 3px solid #60a5fa; outline-offset: 3px; }
#mindia-btn.izquierda { right: auto; left: 20px; }

#mindia-btn-logo {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: contain;
  display: block;
}
#mindia-btn-label {
  font-size: 9.5px; font-weight: 700;
  color: #fff; letter-spacing: .5px;
  text-transform: uppercase;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1; pointer-events: none;
}
#mindia-badge {
  position: absolute; top: 2px; right: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #0f172a;
  animation: md-pulse 2s infinite;
}
@keyframes md-pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.4); opacity: .7; }
}

/* ── Panel / Drawer ──────────────────────────────────────── */
#mindia-box {
  position: fixed;
  bottom: 0; right: 0;
  z-index: var(--md-z);
  width: var(--md-w);
  max-width: 100vw;
  max-height: 96vh;
  background: var(--md-panel-bg);
  border-radius: var(--md-radius) var(--md-radius) 0 0;
  border-top: 1px solid rgba(59,130,246,.30);
  box-shadow: 0 -8px 40px rgba(0,0,0,.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  /* Estado cerrado */
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
  transition: opacity .28s cubic-bezier(.4,0,.2,1),
              transform .28s cubic-bezier(.4,0,.2,1);
}
#mindia-box.abierto {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}
#mindia-box.izquierda { right: auto; left: 0; }

/* Handle de arrastre */
#mindia-handle {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: rgba(59,130,246,.35);
  margin: 12px auto 0;
  flex-shrink: 0;
  cursor: pointer;
}

/* ── Header del panel ────────────────────────────────────── */
#mindia-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 18px 0;
  flex-shrink: 0;
}
#mindia-header-titulo {
  font-size: 14px; font-weight: 700;
  color: var(--md-text); letter-spacing: .3px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#mindia-cerrar {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(59,130,246,.45);
  background: rgba(15,25,60,.60);
  color: var(--md-sub);
  font-size: 18px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
#mindia-cerrar:hover { background: rgba(59,130,246,.22); color: var(--md-text); }

/* ── Orbe / Canvas ───────────────────────────────────────── */
#mindia-avatar-wrap {
  position: relative;
  width: 160px; height: 160px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#mindia-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  border-radius: 50%;
}
#mindia-glow {
  position: absolute;
  width: 100px; height: 100px;
  border-radius: 50%;
  box-shadow: 0 0 50px rgba(59,130,246,.32), 0 0 100px rgba(29,78,216,.18);
  animation: md-breathe 4.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes md-breathe { 0%,100%{transform:scale(1)} 50%{transform:scale(1.04)} }

/* Cara HTML (ojos + boca) sobre el canvas */
#mindia-face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; pointer-events: none;
}
.md-eyes { display: flex; gap: 22px; }
.md-eye {
  width: 9px; height: 16px;
  border-radius: 5px;
  background: #e0f0ff;
  animation: md-blink 5.2s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(147,197,253,.7);
}
.md-eye:nth-child(2) { animation-delay: .15s; }
@keyframes md-blink {
  0%,92%,100% { transform: scaleY(1); }
  96%          { transform: scaleY(.1); }
}
#mindia-mouth {
  width: 30px; height: 5px;
  border-radius: 5px;
  background: #93c5fd;
  transition: height .09s, border-radius .09s;
  box-shadow: 0 0 6px rgba(147,197,253,.5);
}

/* ── Wave bars ───────────────────────────────────────────── */
#mindia-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 18px;
  flex-shrink: 0;
}
#mindia-wave span {
  display: block; width: 3px; height: 4px;
  border-radius: 2px;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  transition: height .1s;
}

/* ── Status pill ─────────────────────────────────────────── */
#mindia-status {
  font-size: 10px; font-weight: 600;
  letter-spacing: .5px; text-transform: uppercase;
  padding: 3px 12px; border-radius: 20px;
  border: 1px solid rgba(59,130,246,.30);
  color: var(--md-sub);
  background: rgba(10,20,60,.55);
  transition: all .3s;
  flex-shrink: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#mindia-status.listening { border-color: #25d366; color: #25d366; background: rgba(37,211,102,.10); }
#mindia-status.speaking  { border-color: #60a5fa; color: #bfdbfe; background: rgba(29,78,216,.18); }

/* Indicador REC */
#mindia-rec {
  display: none;
  align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px;
  background: rgba(37,211,102,.14);
  border: 1px solid rgba(37,211,102,.40);
  flex-shrink: 0;
}
#mindia-rec.show { display: flex; }
#mindia-rec-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #25d366;
  animation: md-dot .7s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes md-dot { 0%,100%{opacity:1} 50%{opacity:.15} }
#mindia-rec-lbl {
  font-size: 10px; font-weight: 700;
  color: #25d366; letter-spacing: .8px; text-transform: uppercase;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Chat / Mensajes ─────────────────────────────────────── */
#mindia-mensajes {
  width: 100%; padding: 0 18px;
  flex: 1;                    /* ocupa todo el espacio disponible */
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(59,130,246,.2) transparent;
}
#mindia-mensajes::-webkit-scrollbar { width: 3px; }
#mindia-mensajes::-webkit-scrollbar-thumb { background: rgba(59,130,246,.22); border-radius: 3px; }

.md-bubble {
  max-width: 88%; padding: 8px 12px;
  border-radius: 13px;
  font-size: 12.5px; line-height: 1.5;
  word-break: break-word;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.md-bubble.user {
  align-self: flex-end;
  background: rgba(59,130,246,.20);
  border: 1px solid rgba(59,130,246,.40);
  color: var(--md-text);
  border-bottom-right-radius: 3px;
}
.md-bubble.ia {
  align-self: flex-start;
  background: rgba(29,78,216,.18);
  border: 1px solid rgba(59,130,246,.25);
  color: var(--md-text);
  border-bottom-left-radius: 3px;
}
.md-bubble.sin-servicio {
  align-self: flex-start;
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.30);
  color: #fca5a5;
  border-bottom-left-radius: 3px;
  max-width: 94%;
}
.md-sender {
  font-size: 9px; font-weight: 700;
  color: #60a5fa; margin-bottom: 3px;
  letter-spacing: .4px; text-transform: uppercase;
}
.md-sender.warn { color: #f97316; }

/* Chips de sugerencia */
.md-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.md-chip {
  font-size: 10px; padding: 3px 9px;
  border-radius: 16px;
  border: 1px solid rgba(59,130,246,.40);
  color: var(--md-sub); cursor: pointer;
  background: rgba(29,78,216,.20);
  transition: all .2s;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.md-chip:hover { border-color: #60a5fa; color: var(--md-text); background: rgba(59,130,246,.30); }

/* Typing dots */
.md-typing {
  display: flex; gap: 5px; align-items: center;
  padding: 10px 14px; align-self: flex-start;
  background: rgba(29,78,216,.18);
  border: 1px solid rgba(59,130,246,.25);
  border-radius: 13px; border-bottom-left-radius: 3px;
}
.md-typing span {
  width: 7px; height: 7px;
  background: #60a5fa; border-radius: 50%;
  animation: md-bounce .9s infinite;
}
.md-typing span:nth-child(2) { animation-delay: .15s; }
.md-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes md-bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-6px)} }

/* Cursor typewriter */
.md-cursor {
  display: inline-block; width: 2px; height: 1em;
  background: #60a5fa; margin-left: 2px;
  vertical-align: text-bottom;
  animation: md-blink-cur .7s step-end infinite;
}
@keyframes md-blink-cur { 0%,100%{opacity:1} 50%{opacity:0} }

/* Productos recomendados */
.md-productos { display: flex; flex-direction: column; gap: 5px; align-self: flex-start; width: 88%; }
.md-prod-card {
  background: rgba(29,78,216,.14);
  border: 1px solid rgba(59,130,246,.28);
  border-radius: 8px; padding: 7px 11px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--md-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.md-prod-card strong { color: #e0f0ff; }
.md-prod-card .precio { color: #60a5fa; font-weight: 700; white-space: nowrap; margin-left: 8px; }

/* ── Input row ───────────────────────────────────────────── */
#mindia-input-row {
  display: flex; gap: 8px; align-items: flex-end;
  width: 100%; padding: 0 18px;
  flex-shrink: 0;
}
#mindia-input {
  flex: 1; resize: none;
  background: rgba(255,255,255,.07);
  border: 1.5px solid rgba(59,130,246,.45);
  border-radius: 11px;
  color: var(--md-text);
  padding: 8px 11px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 12.5px; line-height: 1.5;
  min-height: 38px; max-height: 80px;
  transition: border-color .15s, background .15s;
}
#mindia-input:focus { outline: none; border-color: #60a5fa; background: rgba(255,255,255,.10); }
#mindia-input::placeholder { color: rgba(147,197,253,.50); }
#mindia-input:disabled { opacity: .45; cursor: not-allowed; }

/* ── Fila de controles ───────────────────────────────────── */
#mindia-ctrl {
  display: flex; gap: 8px; align-items: center;
  width: 100%; padding: 0 18px;
  flex-shrink: 0;
}

/* Botones mic y bocina — SIEMPRE VISIBLES */
.md-icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #1e3a8a;
  border: 2px solid #3b82f6;
  color: #bfdbfe;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .18s, border-color .18s, transform .1s, box-shadow .18s;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(59,130,246,.35);
}
.md-icon-btn svg { width: 22px; height: 22px; flex-shrink: 0; display: block; }
.md-icon-btn:hover {
  background: #2563eb;
  border-color: #60a5fa;
  color: #e0f0ff;
  box-shadow: 0 4px 16px rgba(59,130,246,.55);
}
.md-icon-btn:active { transform: scale(.92); }

/* Mic grabando — verde WhatsApp pulsante */
.md-icon-btn.recording {
  background: #065f46;
  border-color: #25d366;
  color: #25d366;
  animation: md-wa-glow 1.2s ease-in-out infinite;
}
@keyframes md-wa-glow {
  0%   { box-shadow: 0 0 0 0 rgba(37,211,102,.60); }
  70%  { box-shadow: 0 0 0 12px rgba(37,211,102,0); }
  100% { box-shadow: 0 0 0 0 rgba(37,211,102,0); }
}

/* Bocina muteada — rojo visible */
.md-icon-btn.muted {
  background: #7f1d1d;
  border-color: #f87171;
  color: #fca5a5;
}
.md-icon-btn.muted:hover { background: #991b1b; border-color: #ef4444; }

/* Botón enviar — píldora WhatsApp */
#mindia-enviar {
  flex: 1; height: 44px;
  border-radius: 22px; border: none;
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  box-shadow: 0 3px 12px rgba(29,78,216,.50);
  transition: filter .15s, transform .1s;
}
#mindia-enviar:hover { filter: brightness(1.15); box-shadow: 0 4px 18px rgba(59,130,246,.6); }
#mindia-enviar:active { transform: scale(.97); }
#mindia-enviar:disabled { opacity: .40; cursor: not-allowed; filter: none; }

/* ── Hint / Branding ─────────────────────────────────────── */
#mindia-hint {
  font-size: 10px; color: rgba(147,197,253,.50);
  text-align: center; flex-shrink: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  padding-bottom: 4px;
}
#mindia-branding {
  font-size: 10px; color: rgba(147,197,253,.35);
  text-align: center; flex-shrink: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  padding-bottom: 12px;
}
#mindia-branding a { color: #60a5fa; text-decoration: none; }

/* ── Responsive — móvil pantalla completa ────────────────── */
@media (max-width: 480px) {
  #mindia-btn { bottom: 90px; right: 14px; width: 62px; height: 62px; }
  #mindia-btn-logo { width: 34px; height: 34px; }

  #mindia-box {
    width: 100%;
    max-width: 100%;
    top: 0;
    bottom: 0;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
    border-top: none;
  }

  /* Orbe más compacto para dejar espacio al chat */
  #mindia-avatar-wrap { width: 110px; height: 110px; }
  #mindia-canvas      { width: 110px; height: 110px; }

  /* Botón cerrar más fácil de tocar en móvil */
  #mindia-cerrar { width: 38px; height: 38px; font-size: 20px; }

  /* Padding lateral más ajustado */
  #mindia-mensajes  { padding: 0 12px; }
  #mindia-input-row { padding: 0 12px; }
  #mindia-ctrl      { padding: 0 12px; }
  #mindia-hint      { font-size: 9px; }
}
