/* ═══════════════════════════════════════════════════
   Lumia Chat Widget — Brainbow
   ═══════════════════════════════════════════════════ */
:root {
  --lw-brand:    #7c3aed;
  --lw-brand2:   #4f46e5;
  --lw-bg:       #0f172a;
  --lw-surface:  #1e293b;
  --lw-border:   rgba(255,255,255,.08);
  --lw-text:     #e2e8f0;
  --lw-muted:    #94a3b8;
  --lw-radius:   16px;
  --lw-shadow:   0 24px 80px rgba(0,0,0,.5), 0 0 0 1px rgba(124,58,237,.2);
  --lw-z:        9999;
}

/* ── Burbuja flotante ───────────────────────────────── */
#lw-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--lw-brand), var(--lw-brand2));
  box-shadow: 0 8px 32px rgba(124,58,237,.5), 0 2px 8px rgba(0,0,0,.3);
  cursor: pointer;
  z-index: var(--lw-z);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
  border: none;
  outline: none;
  padding: 0;
}
#lw-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(124,58,237,.65), 0 2px 8px rgba(0,0,0,.3);
}
#lw-bubble img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}
#lw-bubble .lw-icon-close {
  display: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  font-weight: 300;
}
#lw-bubble.is-open img             { display: none; }
#lw-bubble.is-open .lw-icon-close  { display: block; }

/* Badge de notificación */
#lw-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
  animation: lw-badge-pop .3s ease;
}
#lw-badge.visible { display: block; }
@keyframes lw-badge-pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* ── Ventana del chat ───────────────────────────────── */
#lw-window {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--lw-bg);
  border-radius: var(--lw-radius);
  box-shadow: var(--lw-shadow);
  z-index: var(--lw-z);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--lw-border);
  opacity: 0;
  transform: translateY(16px) scale(.96);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
#lw-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ─────────────────────────────────────────── */
#lw-header {
  background: linear-gradient(135deg, rgba(124,58,237,.25), rgba(79,70,229,.15));
  border-bottom: 1px solid var(--lw-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#lw-header img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(124,58,237,.5);
  object-fit: cover;
  flex-shrink: 0;
}
.lw-header-info   { flex: 1; min-width: 0; }
.lw-header-name   { font-weight: 700; color: #f1f5f9; font-size: 15px; margin: 0; }
.lw-header-status {
  font-size: 12px; color: var(--lw-muted);
  display: flex; align-items: center; gap: 5px; margin-top: 2px;
}
.lw-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e;
  animation: lw-pulse 2s infinite;
}
@keyframes lw-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .4; }
}
#lw-header-close {
  background: none; border: none; color: var(--lw-muted);
  cursor: pointer; padding: 4px; border-radius: 6px;
  font-size: 18px; line-height: 1;
  transition: color .15s, background .15s;
}
#lw-header-close:hover { color: #f1f5f9; background: rgba(255,255,255,.08); }

/* ── Área de mensajes ───────────────────────────────── */
#lw-messages {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
#lw-messages::-webkit-scrollbar       { width: 4px; }
#lw-messages::-webkit-scrollbar-track { background: transparent; }
#lw-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.lw-msg {
  display: flex; gap: 8px;
  max-width: 88%;
  animation: lw-fadeIn .2s ease;
}
@keyframes lw-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.lw-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.lw-msg.bot  { align-self: flex-start; }

.lw-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%; flex-shrink: 0;
  object-fit: cover; margin-top: 2px;
}
.lw-msg-avatar.user-avatar {
  background: linear-gradient(135deg, var(--lw-brand), var(--lw-brand2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff; font-weight: 700;
}
.lw-msg-bubble {
  padding: 10px 14px; border-radius: 14px;
  font-size: 14px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.lw-msg.user .lw-msg-bubble {
  background: linear-gradient(135deg, var(--lw-brand), var(--lw-brand2));
  color: #fff; border-bottom-right-radius: 4px;
}
.lw-msg.bot .lw-msg-bubble {
  background: var(--lw-surface); color: var(--lw-text);
  border: 1px solid var(--lw-border); border-bottom-left-radius: 4px;
}

/* Typing indicator */
.lw-typing .lw-msg-bubble {
  display: flex; gap: 5px; align-items: center; padding: 12px 16px;
}
.lw-typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--lw-muted);
  animation: lw-bounce 1.2s infinite;
}
.lw-typing-dot:nth-child(2) { animation-delay: .2s; }
.lw-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes lw-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-6px); }
}

/* Mensaje de sistema */
.lw-sys-msg {
  text-align: center; font-size: 12px; color: #818cf8;
  padding: 4px 12px; margin: 0 auto; max-width: 90%;
  background: rgba(99,102,241,.1); border-radius: 8px;
  animation: lw-fadeIn .3s ease;
}

/* ── Input ──────────────────────────────────────────── */
#lw-input-area {
  padding: 12px 16px; border-top: 1px solid var(--lw-border);
  display: flex; gap: 8px; align-items: flex-end;
  flex-shrink: 0; background: var(--lw-bg);
}
#lw-input {
  flex: 1; background: var(--lw-surface);
  border: 1px solid var(--lw-border); border-radius: 10px;
  padding: 10px 14px; color: var(--lw-text);
  font-size: 14px; resize: none;
  max-height: 100px; min-height: 40px;
  outline: none; font-family: inherit;
  transition: border-color .15s; line-height: 1.4;
}
#lw-input::placeholder { color: var(--lw-muted); }
#lw-input:focus        { border-color: rgba(124,58,237,.6); }

#lw-send {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--lw-brand), var(--lw-brand2));
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: #fff;
  transition: opacity .15s, transform .15s;
}
#lw-send:hover:not(:disabled) { opacity: .9; transform: scale(1.05); }
#lw-send:disabled              { opacity: .4; cursor: not-allowed; }
#lw-send svg { width: 18px; height: 18px; fill: currentColor; }

/* ── Footer ─────────────────────────────────────────── */
#lw-footer {
  text-align: center; padding: 6px 16px 10px;
  font-size: 11px; color: #475569; flex-shrink: 0;
}
#lw-footer a { color: #6366f1; text-decoration: none; }

/* ── Responsive móvil ───────────────────────────────── */
@media (max-width: 440px) {
  #lw-window {
    bottom: 0; right: 0; left: 0;
    width: 100%; max-width: 100%;
    height: 100dvh; max-height: 100dvh;
    border-radius: 0;
  }
  #lw-bubble { bottom: 20px; right: 20px; }
}
