/* ── Variables Antel ──────────────────────────────────────────────────────── */
:root {
  --antel-blue:         #1A3C8F;
  --antel-yellow:       #FFB800;
  --antel-white:        #FFFFFF;
  --antel-bg:           #F0F2F5;
  --antel-text:         #1A1A18;
  --antel-border:       #E0DDD8;
  --antel-bubble-ana:   #FFFFFF;
  --antel-bubble-user:  #1A3C8F;
  --antel-online:       #25D366;
  --shadow:             0 4px 24px rgba(26, 60, 143, 0.18);
  --radius:             16px;
  --radius-sm:          8px;
  --font:               'Nunito', 'Segoe UI', system-ui, sans-serif;
}

/* ── Widget flotante (FAB) ─────────────────────────────────────────────────── */
#chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--antel-blue);
  border: 3px solid var(--antel-yellow);
  color: var(--antel-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  z-index: 9998;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#chat-bubble:hover { transform: scale(1.08); }
#chat-bubble svg { width: 28px; height: 28px; }

/* ── Ventana del chat ──────────────────────────────────────────────────────── */
#chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 390px;
  max-width: calc(100vw - 40px);
  height: 580px;
  max-height: calc(100vh - 130px);
  background: var(--antel-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  font-family: var(--font);
  transition: opacity 0.2s, transform 0.2s;
}
#chat-window.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(0.97);
}

/* ── Header ────────────────────────────────────────────────────────────────── */
#chat-header {
  background: var(--antel-blue);
  color: var(--antel-white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#chat-header .avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--antel-yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font);
  font-weight: 800;
  font-size: 18px;
  color: var(--antel-blue);
}
#chat-header .avatar .online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--antel-online);
  border: 2px solid var(--antel-blue);
}
#chat-header .info { flex: 1; }
#chat-header .name {
  font-weight: 700;
  font-size: 15px;
  font-family: var(--font);
}
#chat-header .status {
  font-size: 11px;
  opacity: 0.75;
  font-family: var(--font);
}
.header-antel-logo {
  font-family: var(--font);
  font-weight: 800;
  font-size: 15px;
  color: var(--antel-white);
  position: relative;
  margin-right: 4px;
}
.header-antel-logo .logo-dot {
  color: var(--antel-yellow);
  font-size: 0.55em;
  vertical-align: super;
  line-height: 0;
}
#chat-close {
  background: none;
  border: none;
  color: var(--antel-white);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
  transition: opacity 0.2s;
}
#chat-close:hover { opacity: 1; }

/* ── Mensajes ──────────────────────────────────────────────────────────────── */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--antel-bg);
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-thumb {
  background: var(--antel-border);
  border-radius: 2px;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: fadeUp 0.2s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.msg-bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font);
}
.msg.user .msg-bubble {
  background: var(--antel-bubble-user);
  color: var(--antel-white);
  border-radius: 12px 2px 12px 12px;
}
.msg.bot .msg-bubble {
  background: var(--antel-bubble-ana);
  color: var(--antel-text);
  border: 1px solid var(--antel-border);
  border-radius: 2px 12px 12px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.msg-time {
  font-size: 10px;
  color: #888888;
  margin-top: 3px;
  padding: 0 4px;
  font-family: var(--font);
}

/* ── Typing indicator ──────────────────────────────────────────────────────── */
#typing-indicator {
  display: none;
  align-self: flex-start;
  background: var(--antel-white);
  padding: 10px 16px;
  border-radius: 2px 12px 12px 12px;
  border: 1px solid var(--antel-border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
#typing-indicator.visible { display: flex; gap: 5px; align-items: center; }
#typing-indicator span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #ccc;
  animation: bounce 1.2s infinite;
}
#typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
#typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(1); background: #ccc; }
  40%            { transform: scale(1.3); background: var(--antel-blue); }
}

/* ── Botón escalada ────────────────────────────────────────────────────────── */
#escalation-btn {
  display: none;
  margin: 0 14px 10px;
  padding: 10px 16px;
  background: var(--antel-yellow);
  color: var(--antel-blue);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background 0.2s, transform 0.1s;
}
#escalation-btn:hover { background: #e6a600; }
#escalation-btn:active { transform: scale(0.97); }
#escalation-btn.visible { display: block; }

/* ── Área de adjuntar documentos ───────────────────────────────────────────── */
#attach-area {
  display: none;
  padding: 8px 14px 4px;
  background: var(--antel-bg);
  border-top: 1px solid var(--antel-border);
  flex-direction: column;
  gap: 6px;
}
#attach-area.visible { display: flex; }
.attach-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--antel-blue);
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.attach-type-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.attach-type-btn {
  background: var(--antel-white);
  border: 1.5px solid var(--antel-blue);
  color: var(--antel-blue);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.attach-type-btn:hover {
  background: var(--antel-blue);
  color: var(--antel-white);
}
#file-previews {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.file-preview {
  font-size: 12px;
  color: var(--antel-blue);
  font-family: var(--font);
  background: var(--antel-white);
  border: 1px solid var(--antel-border);
  border-radius: 6px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.file-preview.uploading { opacity: 0.6; }
.file-preview.error { color: #c62828; border-color: #c62828; }
.file-preview.ok { color: #2e7d32; border-color: #2e7d32; }

/* ── Input area ────────────────────────────────────────────────────────────── */
#chat-input-area {
  padding: 10px 14px 12px;
  background: var(--antel-white);
  border-top: 1px solid var(--antel-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  border: 1.5px solid var(--antel-border);
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 14px;
  font-family: var(--font);
  background: var(--antel-bg);
  outline: none;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.2s;
  line-height: 1.4;
  color: var(--antel-text);
}
#chat-input::placeholder { color: #9e9e9e; }
#chat-input:focus { border-color: var(--antel-blue); background: var(--antel-white); }
#chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--antel-blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}
#chat-send:hover { background: #1530A0; }
#chat-send:active { transform: scale(0.92); }
#chat-send svg { width: 20px; height: 20px; fill: var(--antel-white); }
#chat-send:disabled { background: #ccc; cursor: not-allowed; }

/* ── Footer ────────────────────────────────────────────────────────────────── */
#chat-footer {
  text-align: center;
  font-size: 11px;
  color: #aaa;
  padding: 5px 0 9px;
  background: var(--antel-white);
  font-family: var(--font);
}

/* ── Responsive mobile ─────────────────────────────────────────────────────── */
@media (max-width: 440px) {
  #chat-window {
    bottom: 0; right: 0; left: 0;
    width: 100%; max-width: 100%;
    height: 100dvh; max-height: 100dvh;
    border-radius: 0;
  }
  #chat-bubble { bottom: 16px; right: 16px; }
}
