/* =========================================================
   DOMUS WIDGET — Chat flutuante da Domi
   Compatível com a paleta do site principal
   ========================================================= */

:root {
  --domi-gold: #D69C31;
  --domi-gold-light: #F3D68B;
  --domi-gold-soft: rgba(214, 156, 49, 0.12);
  --domi-black: #0A0A0A;
  --domi-soft: #1E1E1E;
  --domi-cream: #F5F1E8;
  --domi-white: #FFFFFF;
  --domi-gray-300: #BFBFBF;
  --domi-gray-500: #7E7E7E;
  --domi-gray-700: #404040;
  --domi-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --domi-shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.18);
  --domi-radius: 16px;
  --domi-radius-bubble: 18px;
  --domi-z: 9999;
}

/* ----- Container principal ----- */
.domi-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--domi-z);
  font-family: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--domi-black);
}

/* ----- Botão flutuante fechado ----- */
.domi-launcher {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--domi-gold);
  border: none;
  cursor: pointer;
  box-shadow: var(--domi-shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
              box-shadow 0.25s ease;
  position: relative;
  outline: none;
}

.domi-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 10px 35px rgba(214, 156, 49, 0.4);
}

.domi-launcher:active { transform: scale(0.96); }

.domi-launcher svg {
  width: 30px;
  height: 30px;
  stroke: var(--domi-black);
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Badge "online" */
.domi-launcher::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: #22C55E;
  border-radius: 50%;
  border: 3px solid var(--domi-cream);
  bottom: 0;
  right: 0;
}

/* Pulso sutil pra chamar atenção (não-intrusivo) */
.domi-launcher::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--domi-gold);
  opacity: 0.3;
  animation: domi-pulse 2.5s ease-in-out infinite;
  z-index: -1;
}

@keyframes domi-pulse {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.15); opacity: 0; }
}

/* ----- Pré-mensagem rica (cartão de boas-vindas da Domi) ----- */
.domi-tip {
  position: absolute;
  right: 0;
  bottom: 84px;
  width: 300px;
  max-width: calc(100vw - 48px);
  background: var(--domi-white);
  color: var(--domi-black);
  border-radius: 18px 18px 6px 18px;
  border: 1px solid rgba(214, 156, 49, 0.22);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
  overflow: hidden;
}

.domi-tip.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  animation: domi-tip-bob 3s 1.2s ease-in-out infinite;
}

@keyframes domi-tip-bob {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-4px) scale(1.012); }
}

.domi-tip:hover {
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.22);
}

/* Cabeçalho com avatar + nome + status */
.domi-tip-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 6px;
}

.domi-tip-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--domi-gold);
  color: var(--domi-black);
  font-family: 'Lexend Zetta', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}
.domi-tip-avatar::after {
  content: '';
  position: absolute;
  width: 11px;
  height: 11px;
  background: #22C55E;
  border-radius: 50%;
  border: 2px solid var(--domi-white);
  bottom: -1px;
  right: -1px;
}

.domi-tip-meta { line-height: 1.25; }
.domi-tip-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--domi-black);
}
.domi-tip-status {
  font-size: 11px;
  color: #1E9F4D;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}
.domi-tip-status-dot {
  width: 6px;
  height: 6px;
  background: #22C55E;
  border-radius: 50%;
  animation: domi-blink 2s ease-in-out infinite;
}
@keyframes domi-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* Corpo da mensagem */
.domi-tip-body {
  padding: 4px 16px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--domi-black);
  font-weight: 400;
}
.domi-tip-body strong {
  font-weight: 600;
}

/* CTA dourado embaixo */
.domi-tip-cta {
  background: var(--domi-gold-soft);
  color: var(--domi-black);
  font-weight: 600;
  text-align: center;
  padding: 11px 14px;
  font-size: 13px;
  border-top: 1px solid rgba(214, 156, 49, 0.22);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s;
}
.domi-tip:hover .domi-tip-cta {
  background: rgba(214, 156, 49, 0.22);
}

/* Botão X discreto */
.domi-tip-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--domi-gray-700);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
  z-index: 2;
}
.domi-tip-close:hover {
  background: rgba(0, 0, 0, 0.12);
  color: var(--domi-black);
}

/* Mobile: tip ocupa largura útil */
@media (max-width: 480px) {
  .domi-tip {
    width: calc(100vw - 32px);
    right: -16px;
    bottom: 80px;
  }
}

/* ----- Janela do chat aberta ----- */
.domi-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--domi-cream);
  border-radius: var(--domi-radius);
  box-shadow: var(--domi-shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(8px);
  transform-origin: bottom right;
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
              opacity 0.25s ease;
}

.domi-widget.open .domi-window {
  display: flex;
  transform: scale(1) translateY(0);
  opacity: 1;
}

.domi-widget.open .domi-launcher::before {
  display: none; /* pausa pulso quando aberto */
}

/* Mobile: fullscreen com safe-area + dynamic viewport (corrige notch + teclado) */
@media (max-width: 480px) {
  .domi-widget.open {
    inset: 0;
  }
  .domi-widget.open .domi-launcher { display: none; }

  .domi-window {
    width: 100vw;
    /* Fallback pra navegadores antigos */
    height: 100vh;
    max-height: 100vh;
    /* svh = small viewport height: encolhe quando o teclado abre (iOS 15.4+) */
    height: 100svh;
    max-height: 100svh;
    border-radius: 0;
    bottom: 0;
    right: 0;
    /* Quando teclado abre/fecha, transição suave */
    transition: height 0.2s ease;
  }

  /* Header com safe-area pro notch / Dynamic Island */
  .domi-header {
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
  }

  /* Input com safe-area pro home indicator do iPhone */
  .domi-input-area {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
    padding-right: calc(12px + env(safe-area-inset-right, 0px));
  }

  /* Footer pode sumir em mobile fullscreen (economia de espaço) */
  .domi-footer {
    padding: 2px 0 4px;
    font-size: 10px;
  }

  /* Mensagens scrolláveis ocupam o resto */
  .domi-messages {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
}

/* ----- Header do chat ----- */
.domi-header {
  background: var(--domi-black);
  color: var(--domi-white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(214, 156, 49, 0.2);
}

.domi-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--domi-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Lexend Zetta', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--domi-black);
  letter-spacing: 0.5px;
  position: relative;
}

.domi-avatar::after {
  content: '';
  position: absolute;
  width: 11px;
  height: 11px;
  background: #22C55E;
  border-radius: 50%;
  border: 2px solid var(--domi-black);
  bottom: -2px;
  right: -2px;
}

.domi-header-info { flex: 1; }
.domi-header-name {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.3px;
}
.domi-header-status {
  font-size: 12px;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 6px;
}
.domi-close {
  background: transparent;
  border: none;
  color: var(--domi-white);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.domi-close:hover { background: rgba(255,255,255,0.1); }

/* ----- Lista de mensagens ----- */
.domi-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--domi-cream);
  scroll-behavior: smooth;
}

.domi-messages::-webkit-scrollbar { width: 6px; }
.domi-messages::-webkit-scrollbar-thumb { background: var(--domi-gray-300); border-radius: 3px; }
.domi-messages::-webkit-scrollbar-track { background: transparent; }

.domi-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: var(--domi-radius-bubble);
  word-wrap: break-word;
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.45;
  animation: domi-fade-in 0.25s ease-out;
}

@keyframes domi-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.domi-bubble.bot {
  background: var(--domi-white);
  color: var(--domi-black);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.domi-bubble.user {
  background: var(--domi-gold);
  color: var(--domi-black);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.domi-bubble.error {
  background: #FEE2E2;
  color: #991B1B;
  align-self: stretch;
  text-align: center;
  font-size: 13px;
}

/* Indicador "digitando..." */
.domi-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  background: var(--domi-white);
  border-radius: var(--domi-radius-bubble);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  animation: domi-fade-in 0.2s ease-out;
}
.domi-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--domi-gray-500);
  border-radius: 50%;
  animation: domi-typing 1.2s infinite;
}
.domi-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.domi-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes domi-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ----- Input ----- */
.domi-input-area {
  padding: 12px;
  background: var(--domi-cream);
  border-top: 1px solid rgba(0,0,0,0.05);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.domi-input {
  flex: 1;
  border: 1.5px solid rgba(0,0,0,0.08);
  border-radius: 22px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 15px;
  background: var(--domi-white);
  color: var(--domi-black);
  resize: none;
  max-height: 100px;
  min-height: 22px;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.4;
}

.domi-input:focus {
  border-color: var(--domi-gold);
}

.domi-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--domi-gold);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.15s;
  flex-shrink: 0;
}

.domi-send:hover { transform: scale(1.05); }
.domi-send:active { transform: scale(0.94); }
.domi-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.domi-send svg {
  width: 18px;
  height: 18px;
  fill: var(--domi-black);
}

/* Footer discreto */
.domi-footer {
  text-align: center;
  font-size: 11px;
  color: var(--domi-gray-500);
  padding: 4px 0 8px;
  background: var(--domi-cream);
}
.domi-footer a {
  color: var(--domi-gray-700);
  text-decoration: none;
}

/* =========================================================
   Card formal de captura de WhatsApp
   Renderizado dentro de .domi-messages quando backend pede
   ========================================================= */

.domi-whats-card {
  align-self: stretch;
  background: var(--domi-white);
  border: 1.5px solid rgba(214, 156, 49, 0.45);
  border-radius: 18px;
  padding: 18px 18px 16px;
  margin: 4px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(214, 156, 49, 0.08);
  animation: domi-whats-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes domi-whats-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.domi-whats-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #25D366;
  color: var(--domi-white);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: -2px;
}

.domi-whats-label {
  font-weight: 600;
  font-size: 15px;
  color: var(--domi-black);
}

.domi-whats-hint {
  font-size: 13px;
  color: var(--domi-gray-500);
  line-height: 1.45;
  margin-top: -4px;
}

.domi-whats-input {
  width: 100%;
  border: 1.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 17px; /* >=16 evita zoom iOS */
  font-weight: 500;
  background: var(--domi-cream);
  color: var(--domi-black);
  letter-spacing: 0.3px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  box-sizing: border-box;
}

.domi-whats-input:focus {
  border-color: var(--domi-gold);
  background: var(--domi-white);
}

.domi-whats-input::placeholder {
  color: rgba(0, 0, 0, 0.3);
  font-weight: 400;
}

.domi-whats-error {
  font-size: 12px;
  color: #C53030;
  min-height: 14px;
  margin-top: -4px;
  font-weight: 500;
}

.domi-whats-error:empty {
  display: none;
}

.domi-whats-submit {
  background: var(--domi-gold);
  color: var(--domi-black);
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.2s, transform 0.15s, opacity 0.2s;
  margin-top: 4px;
}

.domi-whats-submit:hover:not(:disabled) {
  background: var(--domi-gold-light);
  transform: translateY(-1px);
}

.domi-whats-submit:active:not(:disabled) {
  transform: translateY(0);
}

.domi-whats-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--domi-gray-300);
}

/* =========================================================
   Bridge card — botão pra cliente abrir conversa no WhatsApp
   (Caminho A: cliente escolheu continuar no zap)
   ========================================================= */

.domi-bridge-card {
  align-self: stretch;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: var(--domi-white);
  border-radius: 18px;
  padding: 20px;
  margin: 4px 0 8px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.25);
  animation: domi-bridge-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes domi-bridge-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.domi-bridge-title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 6px;
  color: var(--domi-white);
}

.domi-bridge-text {
  font-size: 14px;
  opacity: 0.95;
  margin-bottom: 14px;
  line-height: 1.5;
}

.domi-bridge-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--domi-white);
  color: #128C7E;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.2s;
}

.domi-bridge-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

.domi-bridge-btn:active { transform: translateY(0); }
