/* ═══════════════════════════════════════════════════════════════
   Victoria Widget — ZonaTel Telecomunicaciones
   Chat con IA · Sin branding de terceros
   ═══════════════════════════════════════════════════════════════ */

#victoria-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 99999;
  font-family: 'Barlow', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Botón flotante ─────────────────────────────────────────── */
#victoria-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3DAEE9 0%, #2B9DD8 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 22px rgba(61,174,233,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: transform 0.22s, box-shadow 0.22s;
  position: relative;
}
#victoria-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(61,174,233,0.7);
}
#victoria-btn svg { color: #fff; display: block; }

/* Notificación punto verde */
#victoria-btn::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #5EC44C;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: vc-pulse 2.5s ease-in-out infinite;
}
@keyframes vc-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.15); opacity: 0.75; }
}

/* ── Panel principal ────────────────────────────────────────── */
#victoria-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  background: #fff;
  border-radius: 1.375rem;
  box-shadow: 0 16px 56px rgba(11,22,56,0.22), 0 2px 8px rgba(11,22,56,0.1);
  border: 1px solid rgba(61,174,233,0.12);
  overflow: hidden;
  display: none;
  flex-direction: column;
  transform-origin: bottom right;
  animation: vc-open 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
#victoria-panel.open { display: flex; }

@keyframes vc-open {
  from { opacity: 0; transform: scale(0.88) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Header ─────────────────────────────────────────────────── */
#victoria-header {
  background: linear-gradient(135deg, #0B1638 0%, #132059 100%);
  padding: 1rem 1.125rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#victoria-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3DAEE9, #5EC44C);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
  letter-spacing: -0.02em;
}

#victoria-info { flex: 1; min-width: 0; }
#victoria-name {
  font-weight: 700;
  color: #F0F7FF;
  font-size: 0.9rem;
  margin: 0 0 3px;
  letter-spacing: -0.02em;
}
#victoria-status {
  font-size: 0.7rem;
  color: #5EC44C;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
}
#victoria-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5EC44C;
  flex-shrink: 0;
  animation: vc-dot 2s ease-in-out infinite;
}
@keyframes vc-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

#victoria-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(240,247,255,0.45);
  padding: 0.3rem;
  line-height: 1;
  border-radius: 0.375rem;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#victoria-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

/* ── Mensajes ────────────────────────────────────────────────── */
#victoria-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  min-height: 220px;
  max-height: 300px;
  background: #F4F8FC;
  scroll-behavior: smooth;
}
#victoria-messages::-webkit-scrollbar { width: 4px; }
#victoria-messages::-webkit-scrollbar-track { background: transparent; }
#victoria-messages::-webkit-scrollbar-thumb { background: rgba(61,174,233,0.25); border-radius: 4px; }

.vc-msg {
  max-width: 85%;
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
  animation: vc-msg-in 0.18s ease;
}
@keyframes vc-msg-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.vc-msg.user {
  background: #3DAEE9;
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 0.25rem;
  box-shadow: 0 2px 8px rgba(61,174,233,0.25);
}

.vc-msg.agent {
  background: #fff;
  color: #0B1638;
  margin-right: auto;
  border: 1px solid #DDE9F5;
  border-bottom-left-radius: 0.25rem;
  box-shadow: 0 1px 4px rgba(11,22,56,0.06);
}

.vc-msg.system {
  background: none;
  color: #A0AABA;
  font-size: 0.7rem;
  text-align: center;
  margin: 0 auto;
  padding: 0.2rem 0.5rem;
  max-width: 100%;
}

/* Typing indicator */
.vc-typing {
  display: flex;
  gap: 4px;
  padding: 0.7rem 0.875rem;
  background: #fff;
  border: 1px solid #DDE9F5;
  border-radius: 1rem;
  border-bottom-left-radius: 0.25rem;
  width: fit-content;
  box-shadow: 0 1px 4px rgba(11,22,56,0.06);
  animation: vc-msg-in 0.18s ease;
}
.vc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3DAEE9;
  animation: vc-bounce 1.2s infinite;
}
.vc-typing span:nth-child(2) { animation-delay: 0.18s; }
.vc-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes vc-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* ── Input ───────────────────────────────────────────────────── */
#victoria-input-area {
  padding: 0.75rem 0.875rem;
  background: #fff;
  border-top: 1px solid #E8F0F8;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#victoria-input {
  flex: 1;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid #D4E6F5;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  color: #0B1638;
  background: #F6FAFE;
  transition: border-color 0.2s;
}
#victoria-input:focus { border-color: #3DAEE9; background: #fff; }
#victoria-input::placeholder { color: #A0AABA; }
#victoria-input:disabled { opacity: 0.6; cursor: not-allowed; }

#victoria-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #3DAEE9;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}
#victoria-send:hover:not(:disabled) { background: #2B9DD8; transform: scale(1.07); }
#victoria-send:disabled { background: #C8DCF0; cursor: not-allowed; }
#victoria-send svg { color: #fff; }

/* ── Footer ─────────────────────────────────────────────────── */
#victoria-footer {
  padding: 0.45rem 1rem;
  background: #fff;
  text-align: center;
  font-size: 0.65rem;
  color: #C8D4E0;
  border-top: 1px solid #F0F6FC;
  letter-spacing: 0.04em;
}

/* ── Pre-chat form ───────────────────────────────────────────── */
#victoria-prechat {
  padding: 1.375rem 1.25rem 1.25rem;
  background: #F4F8FC;
  display: flex;
  flex-direction: column;
  gap: 0;
}

#victoria-prechat-intro {
  font-size: 0.8rem;
  color: #4A6789;
  margin-bottom: 1.125rem;
  line-height: 1.5;
}

.vc-field {
  margin-bottom: 0.75rem;
}
.vc-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #0B1638;
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.vc-field input {
  width: 100%;
  padding: 0.65rem 0.875rem;
  border: 1.5px solid #D4E6F5;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  color: #0B1638;
  background: #fff;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.vc-field input:focus  { border-color: #3DAEE9; }
.vc-field input.error  { border-color: #EF4444; }
.vc-field input::placeholder { color: #A0AABA; }

#victoria-prechat-btn {
  width: 100%;
  padding: 0.8rem;
  background: #3DAEE9;
  color: #fff;
  border: none;
  border-radius: 0.625rem;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 0.375rem;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 4px 14px rgba(61,174,233,0.35);
}
#victoria-prechat-btn:hover {
  background: #2B9DD8;
  transform: translateY(-1px);
}

.vc-prechat-note {
  font-size: 0.68rem;
  color: #A0AABA;
  text-align: center;
  margin-top: 0.625rem;
}

/* ── Animación de atención (salta antes de abrirse) ─────────── */
@keyframes vc-attention {
  0%   { transform: scale(1) rotate(0deg); }
  15%  { transform: scale(1.15) rotate(-8deg); }
  30%  { transform: scale(1.15) rotate(8deg); }
  45%  { transform: scale(1.1) rotate(-5deg); }
  60%  { transform: scale(1.1) rotate(5deg); }
  75%  { transform: scale(1.05) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); }
}
#victoria-btn.vc-shake {
  animation: vc-attention 0.7s ease-in-out;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 420px) {
  #victoria-widget { bottom: 1rem; right: 1rem; }
  #victoria-panel  { width: calc(100vw - 2rem); right: -0.5rem; bottom: 68px; }
}
