/* =====================================================
   CABE Chat IA — Widget CSS
   Cores: navy #1a2744 | dourado #f0c040 | bg #f8fafc
   ===================================================== */

.cabe-chat-widget {
  --cabe-chat-height: 480px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 32px rgba(26,39,68,0.12);
  display: flex;
  flex-direction: column;
  height: var(--cabe-chat-height);
  max-width: 720px;
  margin: 32px auto;
  font-family: "Outfit", sans-serif;
}

/* --- Header --- */
.cabe-chat__header {
  background: #1a2744;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(240,192,64,0.2);
  flex-shrink: 0;
}

.cabe-chat__header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Avatar da Maria no header */
.cabe-chat__maria-avatar {
  position: relative;
  flex-shrink: 0;
}
.cabe-chat__maria-avatar img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(240,192,64,0.5);
  display: block;
  object-fit: cover;
}
.cabe-chat__status-ring {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #4ade80;
  border: 2px solid #1a2744;
  border-radius: 50%;
  animation: cabe-status-pulse 2.5s infinite;
}

/* Badge IA */
.cabe-chat__header-badge {
  display: inline-block;
  background: rgba(240,192,64,0.18);
  color: #f0c040;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  border-radius: 100px;
  border: 1px solid rgba(240,192,64,0.3);
  vertical-align: middle;
  margin-left: 4px;
}

/* Avatar nos balões de mensagem */
.cabe-chat__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 2px;
  border: 1.5px solid rgba(240,192,64,0.35);
}
.cabe-chat__avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.cabe-chat__header-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
}

.cabe-chat__header-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.cabe-chat__status-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  animation: cabe-status-pulse 2.5s infinite;
}

@keyframes cabe-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.cabe-chat__clear {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 6px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.cabe-chat__clear:hover {
  background: rgba(255,255,255,0.15);
  color: #f0c040;
}

/* --- Messages area --- */
.cabe-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

.cabe-chat__messages::-webkit-scrollbar { width: 4px; }
.cabe-chat__messages::-webkit-scrollbar-track { background: transparent; }
.cabe-chat__messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

/* --- Message rows --- */
.cabe-chat__msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 88%;
  animation: cabe-msg-in 0.22s ease;
}

@keyframes cabe-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cabe-chat__msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* --- Avatar (estilos base mantidos para fallback) --- */

/* --- Bubbles --- */
.cabe-chat__bubble {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 2px 14px 14px 14px;
  padding: 11px 15px;
  font-size: 14px;
  line-height: 1.65;
  color: #1c2333;
  word-break: break-word;
}

.cabe-chat__bubble ul {
  margin: 6px 0 4px 16px;
  padding: 0;
}

.cabe-chat__bubble li {
  margin-bottom: 4px;
}

.cabe-chat__msg--user .cabe-chat__bubble {
  background: #1a2744;
  color: #fff;
  border-color: #1a2744;
  border-radius: 14px 14px 2px 14px;
}

/* --- Typing indicator --- */
.cabe-chat__bubble--typing {
  min-width: 52px;
}

.cabe-chat__bubble--typing::after {
  content: '';
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.cabe-chat__bubble--typing::before {
  content: '';
  display: inline-block;
  width: 36px;
  height: 10px;
  background-image:
    radial-gradient(circle, #94a3b8 2px, transparent 2px),
    radial-gradient(circle, #94a3b8 2px, transparent 2px),
    radial-gradient(circle, #94a3b8 2px, transparent 2px);
  background-size: 8px 8px;
  background-position: 0 center, 14px center, 28px center;
  background-repeat: no-repeat;
  animation: cabe-dots 1.2s infinite;
}

@keyframes cabe-dots {
  0%, 100% { opacity: 0.3; }
  33%       { opacity: 1;   }
  66%       { opacity: 0.5; }
}

/* --- Input bar --- */
.cabe-chat__input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.cabe-chat__input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: "Outfit", sans-serif;
  color: #1c2333;
  background: #f8fafc;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  min-width: 0;
}

.cabe-chat__input:focus {
  border-color: #1a2744;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26,39,68,0.07);
}

.cabe-chat__input:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.cabe-chat__send {
  background: #1a2744;
  color: #f0c040;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.cabe-chat__send:hover:not(:disabled) {
  background: #0d1b35;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,39,68,0.25);
}

.cabe-chat__send:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* --- Mobile --- */
@media (max-width: 600px) {
  .cabe-chat-widget {
    margin: 16px 0;
    border-radius: 12px;
    height: 420px;
  }
}

/* =====================================================
   BOTÃO FLUTUANTE + POPUP
   ===================================================== */

/* --- Botão flutuante --- */
.cabe-float-btn {
  position: fixed;
  bottom: 214px;
  right: 28px;
  z-index: 9998;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  background: transparent;
  filter: drop-shadow(0 4px 16px rgba(26,39,68,0.35));
  transition: transform 0.25s cubic-bezier(.16,1,.3,1), filter 0.2s;
  animation: cabe-float-bounce 2.8s ease-in-out infinite;
}

@keyframes cabe-float-bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.cabe-float-btn:hover {
  animation: none;
  transform: scale(1.1);
  filter: drop-shadow(0 6px 20px rgba(26,39,68,0.45));
}

.cabe-float-btn.is-open {
  animation: none;
  transform: scale(0.92);
}

.cabe-float-btn img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: block;
  border: 3px solid #f0c040;
  object-fit: cover;
}

/* Anel pulsante ao redor do botão */
.cabe-float-btn__ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(240,192,64,0.5);
  animation: cabe-ring-pulse 2.2s ease-out infinite;
  pointer-events: none;
}

@keyframes cabe-ring-pulse {
  0%   { transform: scale(1);   opacity: 0.8; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Tooltip label */
.cabe-float-btn__label {
  position: absolute;
  right: 74px;
  top: 50%;
  transform: translateY(-50%);
  background: #1a2744;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: "Outfit", sans-serif;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.cabe-float-btn__label::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right: none;
  border-left-color: #1a2744;
}

.cabe-float-btn:hover .cabe-float-btn__label {
  opacity: 1;
}

/* --- Popup --- */
.cabe-float-popup {
  position: fixed;
  bottom: 292px;
  right: 28px;
  z-index: 9999;
  width: 360px;
  height: 500px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 48px rgba(26,39,68,0.22), 0 2px 12px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Animação de entrada */
  transform: scale(0.85) translateY(24px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(.16,1,.3,1), opacity 0.22s ease;
}

.cabe-float-popup.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Fechar popup */
.cabe-chat__close {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  padding: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.cabe-chat__close:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* Popup: área de mensagens ocupa o espaço restante */
.cabe-float-popup .cabe-chat__messages {
  flex: 1;
  overflow-y: auto;
}

/* Mobile */
@media (max-width: 480px) {
  .cabe-float-popup {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 286px;
    height: 440px;
  }
  .cabe-float-btn {
    right: 16px;
    bottom: 204px;
  }
}
