/* ==========================================================================
   FLANDÃO - Assistente Virtual da Prime Pintura
   Estilos totalmente escopados em .flandao
   ========================================================================== */

:root {
  --flandao-orange: #e8641c;
  --flandao-orange-light: #ff8a42;
  --flandao-yellow: #f2b705;
  --flandao-yellow-light: #ffd23f;
  --flandao-bg: #0e0e10;
  --flandao-surface: #17171a;
  --flandao-surface-card: #202025;
  --flandao-surface-user: #2d2621;
  --flandao-border: rgba(255, 255, 255, 0.1);
  --flandao-text: #f5f1ea;
  --flandao-text-muted: #b0ada8;
  --flandao-whatsapp: #25D366;
  --flandao-whatsapp-hover: #1ebd5a;
  
  /* Posicionamento do botão flutuante para conviver com os outros botões */
  /* No site, o container de botões flutuantes fica no canto inferior direito.
     O Flandão fica logo acima do grupo ou alinhado de forma acessível. */
  --flandao-fab-right: clamp(0.9rem, 3vw, 1.6rem);
  --flandao-fab-bottom: calc(clamp(0.9rem, 3vw, 1.6rem) + 120px);
  --flandao-fab-size: 56px;
  --flandao-z-fab: 98;
  --flandao-z-panel: 150;
  --flandao-font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --flandao-font-display: "Anton", "Arial Narrow", sans-serif;
}

/* Container raiz */
.flandao {
  font-family: var(--flandao-font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--flandao-text);
  box-sizing: border-box;
}

.flandao *,
.flandao *::before,
.flandao *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Botão Flutuante (FAB) */
.flandao-fab {
  position: fixed;
  right: var(--flandao-fab-right);
  bottom: var(--flandao-fab-bottom);
  width: var(--flandao-fab-size);
  height: var(--flandao-fab-size);
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--flandao-yellow) 0%, var(--flandao-orange) 100%);
  color: #0e0e10;
  cursor: pointer;
  z-index: var(--flandao-z-fab);
  box-shadow: 0 8px 24px -4px rgba(232, 100, 28, 0.45), 0 4px 12px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.2, 1, 0.3, 1), box-shadow 0.25s ease;
  touch-action: manipulation;
}

.flandao-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 28px -2px rgba(232, 100, 28, 0.6), 0 6px 16px rgba(0, 0, 0, 0.6);
}

.flandao-fab:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.flandao-fab-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease;
}

.flandao-fab-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.flandao-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #25D366;
  border: 2px solid #0e0e10;
  border-radius: 50%;
}

/* Painel de Conversa */
.flandao-panel {
  position: fixed;
  right: clamp(0.9rem, 3vw, 1.6rem);
  bottom: clamp(0.9rem, 3vw, 1.6rem);
  width: min(400px, calc(100vw - 1.8rem));
  height: min(620px, calc(100vh - 2.5rem));
  background: var(--flandao-bg);
  border: 1px solid var(--flandao-border);
  border-radius: 16px;
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: var(--flandao-z-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.2, 1, 0.3, 1), visibility 0.25s ease;
}

.flandao-panel.flandao-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Cabeçalho */
.flandao-header {
  padding: 14px 16px;
  background: var(--flandao-surface);
  border-bottom: 1px solid var(--flandao-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.flandao-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.flandao-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--flandao-yellow) 0%, var(--flandao-orange) 100%);
  color: #0e0e10;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.flandao-title-wrap {
  min-width: 0;
}

.flandao-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flandao-subtitle {
  font-size: 12px;
  color: var(--flandao-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.flandao-status-dot {
  width: 7px;
  height: 7px;
  background: #25D366;
  border-radius: 50%;
  display: inline-block;
}

.flandao-close-btn {
  background: transparent;
  border: none;
  color: var(--flandao-text-muted);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
  flex-shrink: 0;
}

.flandao-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.flandao-close-btn:focus-visible {
  outline: 2px solid var(--flandao-orange);
}

/* Área de Mensagens */
.flandao-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.flandao-messages::-webkit-scrollbar {
  width: 6px;
}
.flandao-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Balões de Mensagem */
.flandao-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.flandao-msg-assistant {
  align-self: flex-start;
  background: var(--flandao-surface-card);
  color: var(--flandao-text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.flandao-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #e8641c 0%, #cf4f0e 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.flandao-msg-error {
  align-self: flex-start;
  background: #2a1b1b;
  color: #f7b2b2;
  border: 1px solid rgba(255, 80, 80, 0.25);
  border-bottom-left-radius: 4px;
}

/* Indicador de Digitando */
.flandao-typing {
  align-self: flex-start;
  background: var(--flandao-surface-card);
  padding: 10px 14px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: none;
  align-items: center;
  gap: 5px;
  width: fit-content;
}

.flandao-typing.flandao-visible {
  display: flex;
}

.flandao-dot {
  width: 6px;
  height: 6px;
  background: var(--flandao-orange-light);
  border-radius: 50%;
  animation: flandaoBounce 1.2s infinite ease-in-out;
}

.flandao-dot:nth-child(2) { animation-delay: 0.2s; }
.flandao-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes flandaoBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* Sugestões Rápidas */
.flandao-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.flandao-suggestions-title {
  font-size: 12px;
  color: var(--flandao-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.flandao-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--flandao-text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.flandao-chip:hover {
  background: rgba(232, 100, 28, 0.15);
  border-color: var(--flandao-orange);
  color: #fff;
  transform: translateX(2px);
}

.flandao-chip:focus-visible {
  outline: 2px solid var(--flandao-orange);
}

/* Barra Fixa WhatsApp no Painel */
.flandao-cta-bar {
  padding: 9px 14px;
  background: var(--flandao-surface);
  border-top: 1px solid var(--flandao-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.flandao-whatsapp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  background: var(--flandao-whatsapp);
  color: #ffffff;
  font-weight: 600;
  font-size: 13.5px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.15s ease;
}

.flandao-whatsapp-btn:hover {
  background: var(--flandao-whatsapp-hover);
  transform: translateY(-1px);
}

.flandao-whatsapp-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.flandao-whatsapp-btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

/* Área de Input */
.flandao-form {
  padding: 12px 14px;
  background: var(--flandao-bg);
  border-top: 1px solid var(--flandao-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.flandao-input {
  flex: 1;
  background: var(--flandao-surface-card);
  border: 1px solid var(--flandao-border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--flandao-text);
  font-size: 16px; /* Evita zoom automático no iOS em inputs menores que 16px */
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

.flandao-input::placeholder {
  color: var(--flandao-text-muted);
  font-size: 14px;
}

.flandao-input:focus {
  border-color: var(--flandao-orange);
}

.flandao-send-btn {
  background: linear-gradient(135deg, var(--flandao-yellow) 0%, var(--flandao-orange) 100%);
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  color: #0e0e10;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

.flandao-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
}

.flandao-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.flandao-send-btn:focus-visible {
  outline: 2px solid #fff;
}

.flandao-send-btn svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

/* Responsividade Mobile (375px e telas menores) */
@media (max-width: 480px) {
  :root {
    --flandao-fab-bottom: calc(clamp(0.9rem, 3vw, 1.6rem) + 115px);
    --flandao-fab-size: 50px;
  }

  .flandao-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .flandao-header {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }

  .flandao-form {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

/* Preferência por movimento reduzido */
@media (prefers-reduced-motion: reduce) {
  .flandao-fab,
  .flandao-panel,
  .flandao-chip,
  .flandao-send-btn,
  .flandao-whatsapp-btn {
    transition: none !important;
  }

  .flandao-dot {
    animation: none !important;
    opacity: 0.8 !important;
  }
}
