/* ============================================================
   RESINSUR CHAT WIDGET
   Colores: #03C4EB (primario), #111 (oscuro), #666 (texto)
   ============================================================ */

:root {
  --chat-primary:   #03C4EB;
  --chat-primary-dk:#0099ba;
  --chat-dark:      #111111;
  --chat-text:      #444444;
  --chat-muted:     #888888;
  --chat-bg:        #f5f5f5;
  --chat-white:     #ffffff;
  --chat-radius:    12px;
  --chat-shadow:    0 8px 32px rgba(0,0,0,0.18);
}

/* ── BURBUJA FLOTANTE ──────────────────────────────────────── */
#resinsur-chat-bubble {
  position: fixed;
  bottom: 80px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: var(--chat-primary);
  border-radius: 50%;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(3,196,235,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  border: none;
  outline: none;
}

#resinsur-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(3,196,235,0.5);
}

#resinsur-chat-bubble svg {
  width: 28px;
  height: 28px;
  fill: white;
  transition: opacity 0.2s;
}

#resinsur-chat-bubble .chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e74c3c;
  color: white;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Open Sans', sans-serif;
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ── VENTANA DEL CHAT ──────────────────────────────────────── */
#resinsur-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 420px;
  max-width: calc(100vw - 48px);
  height: 620px;
  max-height: calc(100vh - 120px);
  background: var(--chat-white);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s;
  font-family: 'Open Sans', sans-serif;
}

#resinsur-chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── HEADER ────────────────────────────────────────────────── */
#resinsur-chat-header {
  background: var(--chat-dark);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#resinsur-chat-header .chat-avatar {
  width: 45px;
  height: 45px;
  /* background: var(--chat-primary); */
  /* border-radius: 50%; */
  display: flex;
  align-items: center;
  justify-content: center;
  /* font-size: 18px; */
  flex-shrink: 0;
  overflow: hidden;
  padding: 0;
}

#resinsur-chat-header .chat-info {
  flex: 1;
}

#resinsur-chat-header .chat-name {
  font-family: 'Raleway', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: white;
  letter-spacing: 0.5px;
}

#resinsur-chat-header .chat-status {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  gap: 4px;
}

#resinsur-chat-header .chat-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #2ecc71;
  border-radius: 50%;
  display: inline-block;
}

#resinsur-chat-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
  flex-shrink: 0;
}

#resinsur-chat-close:hover { color: white; }

/* ── MENSAJES ──────────────────────────────────────────────── */
#resinsur-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  background: var(--chat-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#resinsur-chat-messages::-webkit-scrollbar { width: 4px; }
#resinsur-chat-messages::-webkit-scrollbar-track { background: transparent; }
#resinsur-chat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: msgIn 0.2s ease both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg.bot  { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; }

.chat-msg .bubble {
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--chat-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.bot .bubble {
  background: white;
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.chat-msg.user .bubble {
  background: var(--chat-primary);
  color: white;
  border-radius: 16px 4px 16px 16px;
}

.chat-msg .bubble a {
  color: var(--chat-primary);
  text-decoration: underline;
  word-break: break-all;
}

.chat-msg.user .bubble a { color: white; }

/* negrita tipo WhatsApp */
.chat-msg .bubble strong { font-weight: 700; }

/* ── TYPING INDICATOR ──────────────────────────────────────── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: white;
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  width: fit-content;
  align-self: flex-start;
}

.chat-typing span {
  width: 7px;
  height: 7px;
  background: var(--chat-muted);
  border-radius: 50%;
  animation: typing 1.2s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── INPUT ─────────────────────────────────────────────────── */
#resinsur-chat-input-area {
  padding: 10px 12px;
  background: white;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

#resinsur-chat-input {
  flex: 1;
  border: 1.5px solid #e0e0e0;
  border-radius: 22px;
  padding: 9px 14px;
  font-family: 'Open Sans', sans-serif;
  font-size: 16px;
  /* ← mínimo 16px para evitar zoom en iOS */
  color: var(--chat-text);
  outline: none;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
  transition: border-color 0.2s;
  -webkit-text-size-adjust: 100%;
}

#resinsur-chat-input:focus { border-color: var(--chat-primary); }
#resinsur-chat-input::placeholder { color: #bbb; }

#resinsur-chat-send {
  width: 38px;
  height: 38px;
  background: var(--chat-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}

#resinsur-chat-send:hover  { background: var(--chat-primary-dk); }
#resinsur-chat-send:active { transform: scale(0.95); }

#resinsur-chat-send svg {
  width: 17px;
  height: 17px;
  fill: white;
}

/* ── FOOTER DEL CHAT ───────────────────────────────────────── */
#resinsur-chat-footer {
  text-align: center;
  padding: 5px 12px 8px;
  font-size: 10px;
  color: #bbb;
  background: white;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}

/* ── RESPONSIVE MÓVIL ──────────────────────────────────────── */
@media (max-width: 480px) {
  #resinsur-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 70vh;
    border-radius: var(--chat-radius) var(--chat-radius) 0 0;
  }

  #resinsur-chat-bubble {
    bottom: 16px;
    right: 16px;
  }
}

/* ── FIX TECLADO MÓVIL ─────────────────────────────────────────── */
@media (max-width: 480px) {
  #resinsur-chat-window {
    bottom: 0 !important;
    left: 0;
    right: 0;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    transition: height 0.15s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s !important;
  }
}

/* ── FIX ANDROID SCROLL ────────────────────────────────────── */
html {
  overflow-x: hidden;
}

#resinsur-chat-bubble,
#resinsur-chat-window {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
}