/* ============================================================
   Chat Widget — Atendimento ao vivo
   Isolado de style.css de propósito; usa os mesmos design tokens
   (:root vars já definidas em style.css) para ficar consistente.
   ============================================================ */

.cx-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: calc(24px + var(--cx-chat-bottom-offset, 0px));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: var(--shadow-gold);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), bottom 300ms var(--ease-out);
}

.cx-chat-launcher:hover {
  background: var(--accent-gold-hover);
  transform: translateY(-2px);
}

.cx-chat-launcher svg {
  width: 26px;
  height: 26px;
  stroke: var(--navy-950);
}

.cx-chat-launcher .cx-chat-close-icon {
  display: none;
}

.cx-chat-launcher.is-open .cx-chat-chat-icon {
  display: none;
}

.cx-chat-launcher.is-open .cx-chat-close-icon {
  display: block;
}

.cx-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #d64545;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--cream-50);
}

.cx-chat-badge[hidden] {
  display: none;
}

.cx-chat-panel {
  position: fixed;
  right: 24px;
  bottom: calc(96px + var(--cx-chat-bottom-offset, 0px));
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--cream-50);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-hairline);
  z-index: 999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), bottom 300ms var(--ease-out);
}

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

.cx-chat-header {
  background: var(--navy-900);
  color: var(--white);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.cx-chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-gold);
  color: var(--navy-950);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif-display);
  font-weight: 600;
  flex-shrink: 0;
}

.cx-chat-header-text {
  flex: 1;
  min-width: 0;
}

.cx-chat-header-title {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
}

.cx-chat-header-sub {
  font-family: var(--font-sans);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cx-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}

.cx-chat-status-dot.is-offline {
  background: #9ca3af;
}

/* ---- Pre-chat form ---- */
.cx-chat-form {
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.cx-chat-form p {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0 0 2px;
}

.cx-chat-field label {
  display: block;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.cx-chat-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hairline);
  background: var(--white);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
}

.cx-chat-field input:focus {
  outline: none;
  border-color: var(--accent-gold);
}

.cx-chat-form-submit {
  margin-top: 4px;
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--accent-gold);
  color: var(--navy-950);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: var(--ls-button);
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}

.cx-chat-form-submit:hover {
  background: var(--accent-gold-hover);
}

.cx-chat-form-error {
  font-family: var(--font-sans);
  font-size: 12px;
  color: #d64545;
  display: none;
}

.cx-chat-form-error.is-visible {
  display: block;
}

/* ---- Message list ---- */
.cx-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--sand-100);
}

.cx-chat-bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  word-wrap: break-word;
}

.cx-chat-bubble--out {
  align-self: flex-end;
  background: var(--navy-900);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.cx-chat-bubble--in {
  align-self: flex-start;
  background: var(--white);
  color: var(--text-primary);
  border: 1px solid var(--border-hairline);
  border-bottom-left-radius: 4px;
}

.cx-chat-bubble-time {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  opacity: 0.6;
}

/* ---- Input bar ---- */
.cx-chat-input-bar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: var(--white);
  border-top: 1px solid var(--border-hairline);
}

.cx-chat-input-bar textarea {
  flex: 1;
  resize: none;
  max-height: 90px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hairline);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
}

.cx-chat-input-bar textarea:focus {
  outline: none;
  border-color: var(--accent-gold);
}

.cx-chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent-gold);
  color: var(--navy-950);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease-out);
}

.cx-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.cx-chat-send-btn:not(:disabled):hover {
  background: var(--accent-gold-hover);
}

.cx-chat-send-btn svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 480px) {
  .cx-chat-panel {
    right: 16px;
    left: 16px;
    width: auto;
    bottom: 88px;
  }

  .cx-chat-launcher {
    right: 16px;
    bottom: 16px;
  }
}
