/* ── CEC Chat — Botão flutuante + painel ────────────────────────────────────
   Inspirado em chat de suporte humano (Intercom / Crisp style)
──────────────────────────────────────────────────────────────────────────── */

/* Botão flutuante */
#cec-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0a2540;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(10,37,64,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, box-shadow .2s;
}

#cec-chat-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 28px rgba(10,37,64,.45);
}

#cec-chat-btn svg {
  width: 26px;
  height: 26px;
  stroke: #fff;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity .15s;
}

#cec-chat-btn .icon-close { display: none; }

#cec-chat-btn.is-open .icon-chat  { display: none; }
#cec-chat-btn.is-open .icon-close { display: block; }

/* Bolinha de notificação */
#cec-chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #22c55e;
  border: 2px solid #fff;
  border-radius: 50%;
}

/* Painel do chat */
#cec-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 9998;
  width: 360px;
  max-width: calc(100vw - 32px);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 40px rgba(0,0,0,.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(.92) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), opacity .18s ease;
  transform-origin: bottom right;
  max-height: calc(100vh - 120px);
}

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

/* Header do painel */
.cec-panel-header {
  background: #0a2540;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.cec-panel-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e5fa8 0%, #0a2540 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Sora', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.2);
}

.cec-panel-info { flex: 1; }

.cec-panel-name {
  font-family: 'Sora', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.cec-panel-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
}

.cec-panel-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  flex-shrink: 0;
}

.cec-panel-status-text {
  font-size: .72rem;
  color: rgba(255,255,255,.75);
}

/* Mensagens */
.cec-panel-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 240px;
  max-height: 340px;
  scroll-behavior: smooth;
  background: #f8fafc;
}

.cec-panel-msgs::-webkit-scrollbar { width: 3px; }
.cec-panel-msgs::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

/* Bolhas */
.cec-bubble {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}

.cec-bubble--helena { align-self: flex-start; }
.cec-bubble--user   { align-self: flex-end; }

.cec-bubble__text {
  padding: 9px 13px;
  border-radius: 16px;
  font-size: .845rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.cec-bubble--helena .cec-bubble__text {
  background: #fff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

.cec-bubble--user .cec-bubble__text {
  background: #0a2540;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.cec-bubble__meta {
  font-size: .65rem;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 3px;
}

.cec-bubble--user .cec-bubble__meta { text-align: right; }

/* Typing */
.cec-typing-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cec-typing-name {
  font-size: .72rem;
  color: #64748b;
}

.cec-typing-dots {
  display: flex;
  gap: 3px;
}

.cec-typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #94a3b8;
  animation: cec-pulse .9s infinite;
}

.cec-typing-dots span:nth-child(2) { animation-delay: .15s; }
.cec-typing-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes cec-pulse {
  0%, 60%, 100% { transform: translateY(0); opacity: .6; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* Chips de sugestão */
.cec-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  padding-left: 2px;
}

.cec-chip {
  font-size: .74rem;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1.5px solid #0a2540;
  color: #0a2540;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  white-space: nowrap;
}

.cec-chip:hover {
  background: #0a2540;
  color: #fff;
}

/* Input */
.cec-panel-input {
  padding: 10px 12px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
  flex-shrink: 0;
}

.cec-panel-textarea {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: .845rem;
  font-family: inherit;
  resize: none;
  line-height: 1.45;
  min-height: 38px;
  max-height: 100px;
  outline: none;
  color: #1e293b;
  transition: border-color .15s;
  background: #f8fafc;
}

.cec-panel-textarea:focus { border-color: #0a2540; background: #fff; }
.cec-panel-textarea::placeholder { color: #94a3b8; }

.cec-panel-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: #0a2540;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, opacity .15s;
  padding: 0;
}

.cec-panel-send:hover:not(:disabled) { background: #163d6b; }
.cec-panel-send:disabled { opacity: .35; cursor: default; }

.cec-panel-send svg {
  width: 16px;
  height: 16px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-left: 2px;
}

@media (max-width: 400px) {
  #cec-chat-panel { right: 12px; bottom: 84px; }
  #cec-chat-btn   { right: 16px; bottom: 16px; }
}
