/* ============================================================
   chat-widget.css — Widget de Chat IA · Odontis Dental
   Autor: Antigravity AI
   Fecha: 2026-03-16
   Descripción: Estilos del agente de chat flotante con
   integración al webhook n8n.
   ============================================================ */

/* ─── Botón flotante ─── */
#od-chat-btn {
  position: fixed !important;
  bottom: 28px !important;
  right: 28px !important;
  z-index: 2147483647 !important;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0084BD 0%, #005a8a 100%);
  box-shadow: 0 8px 32px rgba(0, 132, 189, 0.50);
  border: none;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(.16,1,.3,1), box-shadow 0.3s;
  outline: none;
}
#od-chat-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 14px 44px rgba(0, 132, 189, 0.60);
}

/* Pulse ring */
#od-chat-btn::before {
  content: '';
  position: absolute;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(0, 132, 189, 0.30);
  animation: od-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes od-pulse {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.85); opacity: 0; }
}

/* Badge "IA" */
#od-chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #fff;
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, sans-serif;
  pointer-events: none;
  letter-spacing: -0.5px;
}

/* ─── Panel ─── */
#od-chat-panel {
  position: fixed !important;
  bottom: 104px !important;
  right: 28px !important;
  z-index: 2147483646 !important;
  width: 375px;
  max-width: calc(100vw - 36px);
  background: #fff;
  border-radius: 24px;
  box-shadow:
    0 24px 80px rgba(2, 29, 58, 0.18),
    0 4px 16px rgba(2, 29, 58, 0.10);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.4s cubic-bezier(.16,1,.3,1),
    opacity   0.4s cubic-bezier(.16,1,.3,1);
}
#od-chat-panel.od-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ── */
#od-chat-header {
  background: linear-gradient(135deg, #021D3A 0%, #0B3D62 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.od-hdr-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(0,132,189,0.5);
  background: linear-gradient(135deg, #0084BD, #005a8a);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.od-hdr-title { flex: 1; }
.od-hdr-title p:first-child {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  margin: 0;
  line-height: 1.2;
  font-family: system-ui, sans-serif;
}
.od-hdr-title p:last-child {
  color: rgba(255,255,255,0.50);
  font-size: 11px;
  margin: 2px 0 0;
  font-family: system-ui, sans-serif;
}
.od-online-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #021D3A;
  flex-shrink: 0;
  animation: od-blink 2s ease-in-out infinite;
}
@keyframes od-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}
#od-chat-close-btn {
  background: rgba(255,255,255,0.10);
  border: none;
  cursor: pointer;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
  outline: none;
}
#od-chat-close-btn:hover { background: rgba(255,255,255,0.22); }

/* ── Quick actions ── */
#od-chat-quick {
  padding: 10px 14px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: #F0F7FB;
  border-bottom: 1px solid #d9ecf7;
  flex-shrink: 0;
}
.od-qbtn {
  background: #fff;
  border: 1.5px solid #cce4f5;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11.5px;
  color: #0084BD;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: system-ui, sans-serif;
  outline: none;
  line-height: 1.4;
}
.od-qbtn:hover {
  background: #0084BD;
  color: #fff;
  border-color: #0084BD;
}

/* ── Messages ── */
#od-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 240px;
  max-height: 320px;
  scroll-behavior: smooth;
  background: #FAFCFE;
}
#od-chat-msgs::-webkit-scrollbar { width: 4px; }
#od-chat-msgs::-webkit-scrollbar-track { background: transparent; }
#od-chat-msgs::-webkit-scrollbar-thumb { background: #c8e4f5; border-radius: 4px; }

.od-msg-row {
  display: flex;
  gap: 8px;
  max-width: 90%;
}
.od-msg-row.od-is-user {
  margin-left: auto;
  flex-direction: row-reverse;
}
.od-msg-bubble-wrap {
  display: flex; flex-direction: column; gap: 3px;
}
.od-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  font-family: system-ui, sans-serif;
  word-break: break-word;
}
.od-is-bot .od-bubble {
  background: #fff;
  border: 1px solid #e0eef8;
  color: #021D3A;
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 2px 8px rgba(2,29,58,0.06);
}
.od-is-user .od-bubble {
  background: linear-gradient(135deg, #0084BD, #0062a3);
  color: #fff;
  border-radius: 16px 4px 16px 16px;
}
.od-avatar-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  background: linear-gradient(135deg, #0084BD, #005a8a);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Typing indicator */
.od-typing-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.od-typing-dots {
  background: #fff;
  border: 1px solid #e0eef8;
  border-radius: 4px 16px 16px 16px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 2px 8px rgba(2,29,58,0.06);
}
.od-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #0084BD;
  animation: od-dots 1.2s ease-in-out infinite;
}
.od-dot:nth-child(2) { animation-delay: 0.18s; }
.od-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes od-dots {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50%       { transform: translateY(-5px); opacity: 1; }
}

/* ── Input area ── */
#od-chat-input-area {
  padding: 11px 13px;
  border-top: 1px solid #e0eef8;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
  flex-shrink: 0;
}
#od-chat-input {
  flex: 1;
  border: 1.5px solid #cce4f5;
  border-radius: 14px;
  padding: 10px 13px;
  font-size: 13px;
  resize: none;
  outline: none;
  line-height: 1.4;
  font-family: system-ui, sans-serif;
  color: #021D3A;
  background: #FAFCFE;
  max-height: 100px;
  transition: border-color 0.2s, background 0.2s;
  overflow-y: auto;
}
#od-chat-input:focus {
  border-color: #0084BD;
  background: #fff;
}
#od-chat-input::placeholder { color: #9db8cc; }
#od-chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #0084BD, #005a8a);
  border: none;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 4px 14px rgba(0,132,189,0.40);
  outline: none;
}
#od-chat-send-btn:hover:not(:disabled) {
  transform: scale(1.09);
  box-shadow: 0 6px 20px rgba(0,132,189,0.50);
}
#od-chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Footer del chat ── */
#od-chat-footer-bar {
  padding: 6px;
  text-align: center;
  font-size: 10.5px;
  color: #9db8cc;
  background: #F0F7FB;
  border-top: 1px solid #d9ecf7;
  font-family: system-ui, sans-serif;
  flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  #od-chat-panel { width: calc(100vw - 20px); right: 10px; bottom: 88px; }
  #od-chat-btn   { bottom: 16px; right: 16px; width: 56px; height: 56px; }
  #od-chat-btn::before { width: 56px; height: 56px; }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  #od-chat-btn::before { animation: none; }
  .od-online-dot       { animation: none; }
  .od-dot              { animation: none; }
  #od-chat-panel       { transition: opacity 0.2s; }
}

/* Retry button (v2) */
.od-retry-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #0084BD;
  background: rgba(0, 132, 189, 0.08);
  border: 1px solid rgba(0, 132, 189, 0.25);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.od-retry-btn:hover {
  background: #0084BD;
  color: #fff;
  border-color: #0084BD;
}
.od-retry-btn:active { transform: scale(0.96); }
.od-bubble a { color: #0084BD; text-decoration: underline; }
.od-bubble a:hover { color: #021D3A; }
