/* ---------- Base ---------- */
body {
  background-color: #f8f9fa;
}
h1 { font-weight: 700; }

/* ---------- Zé Maria (avatar + balão) ---------- */
/* Container fixo no canto inferior direito */
#ze-maria {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
#ze-maria img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Balão de mensagem (estado padrão, só texto) */
#ze-maria .ze-bubble {
  position: absolute;
  bottom: 90px;
  right: 0;
  background: #FFFFFF;
  color: #333;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  z-index: 10000;
  display: block;
  white-space: normal;
  word-break: break-word;

  /* largura confortável no desktop */
  width: 360px;
  max-width: 360px;
  min-width: 320px;
}

/* Triângulo do balão */
#ze-maria .ze-bubble::after {
  content: "";
  position: absolute;
  bottom: -10px;
  right: 28px;
  border-width: 10px 8px 0 8px;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent;
}

/* ---------- Responsivo ---------- */
@media (max-width: 768px) {
  #ze-maria {
    width: 55px;
    height: 55px;
    bottom: 15px;
    right: 15px;
  }
  #ze-maria .ze-bubble {
    font-size: 13px;
    padding: 10px 14px;
    bottom: 75px;
    width: 280px;
    max-width: 280px;
    min-width: 240px;
  }
  #ze-maria .ze-bubble::after { right: 22px; }
}

/* ---------- Força de largura (caso Bootstrap/terceiros tentem encolher) ---------- */
#ze-maria .ze-bubble {
  width: 360px !important;
  max-width: 360px !important;
  min-width: 320px !important;
}
@media (max-width: 768px) {
  #ze-maria .ze-bubble {
    width: 280px !important;
    max-width: 280px !important;
    min-width: 240px !important;
  }
}

/* Acessibilidade e feedback de foco no avatar */
#ze-maria[role="button"] { outline: none; }
#ze-maria:focus-visible {
  outline: 3px solid #0d6efd;
  outline-offset: 4px;
}

/* Micro animação (respeita prefers-reduced-motion) */
@media (prefers-reduced-motion: no-preference) {
  #ze-maria { transition: transform .12s ease, box-shadow .12s ease; }
  #ze-maria:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,.35); }
  #ze-maria:active { transform: translateY(0); }
}

/* ===================== MODO CHAT NA BOLHA ===================== */
/* transforma a .ze-bubble no container do chat */
#ze-maria .ze-bubble.chat {
  padding: 0;                                /* o conteúdo interno cuida do padding */
  max-height: min(70vh, 560px);              /* mais espaço visual */
  overflow-y: auto;                           /* << evita corte */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
/* Esconde o triângulo no modo chat */
#ze-maria .ze-bubble.chat::after { display: none; }

/* Cabeçalho fixo no topo da bolha */
#ze-maria .ze-bubble .ai-header {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; font-weight: 600; border-bottom: 1px solid #eee;
  background: #fff;
}

/* Botão fechar */
#ze-maria .ze-bubble .ai-close {
  border: 0; background: transparent; font-size: 18px; line-height: 1;
  cursor: pointer; padding: 2px 6px; border-radius: 8px;
}
#ze-maria .ze-bubble .ai-close:focus-visible { outline: 2px solid #0d6efd; }

/* Área de mensagens com altura flexível */
#ze-maria .ze-bubble #ai-log {
  height: auto;                 /* era fixo */
  max-height: 40vh;             /* limita o log para sobrar área para pickers */
  overflow: auto;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;
}
#ze-maria .ze-bubble #ai-log .msg { margin: 8px 0; }
#ze-maria .ze-bubble #ai-log .msg .bubble {
  display: inline-block; padding: 8px 10px; border-radius: 10px;
  white-space: pre-wrap; word-wrap: break-word; max-width: 90%;
}
#ze-maria .ze-bubble #ai-log .msg.me  { text-align: right; }
#ze-maria .ze-bubble #ai-log .msg.me  .bubble { background: #eef; }
#ze-maria .ze-bubble #ai-log .msg.bot .bubble { background: #f6f6f6; }

/* Formulário “grudado” no rodapé da bolha */
#ze-maria .ze-bubble #ai-form {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; gap: 8px; padding: 10px;
  background: #fff; border-top: 1px solid #eee;
}
#ze-maria .ze-bubble #ai-input {
  flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 10px;
}
#ze-maria .ze-bubble #ai-form button {
  padding: 10px 14px; border-radius: 10px; border: 0; background: #111; color: #fff;
}

/* Picker de perfil / nome dentro da bolha */
#ze-maria .ze-bubble #ai-profile-picker,
#ze-maria .ze-bubble #ai-name-picker { padding: 12px; }
#ze-maria .ze-bubble #ai-profile-picker .picker-btn {
  width: 100%; text-align: left; padding: 10px; border: 1px solid #ddd;
  border-radius: 10px; background: #f9f9f9; cursor: pointer;
}
#ze-maria .ze-bubble #ai-profile-picker .picker-btn:hover { background: #f0f0f0; }
#ze-maria .ze-bubble #ai-name-picker input {
  width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 10px;
}

/* Mobile: mais área útil */
@media (max-width: 768px) {
  #ze-maria .ze-bubble.chat { max-height: 80vh; }
  #ze-maria .ze-bubble #ai-log { max-height: 35vh; }
}

/* Alto contraste aplicado à bolha */
body.high-contrast #ze-maria .ze-bubble.chat,
body.high-contrast #ze-maria .ze-bubble #ai-log,
body.high-contrast #ze-maria .ze-bubble #ai-form,
body.high-contrast #ze-maria .ze-bubble #ai-input,
body.high-contrast #ze-maria .ze-bubble .ai-header {
  background: #000 !important; color: #fff !important; border-color: #fff !important;
}
body.high-contrast #ze-maria .ze-bubble #ai-form button { background:#fff !important; color:#000 !important; }

/* ====== (Opcional) Blocos antigos da janela flutuante #ai-avatar-box — não usados no modo bolha ====== */
#ai-avatar-box {
  position: fixed;
  right: 16px;
  bottom: 96px;
  width: 360px;
  max-width: 92vw;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
  overflow: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  z-index: 10000;
}
#ai-avatar-box .ai-header { padding: 10px 12px; font-weight: 600; display:flex; align-items:center; justify-content:space-between; }
#ai-avatar-box .ai-close  { border:0; background:transparent; font-size:20px; line-height:1; padding:4px 8px; cursor:pointer; }
#ai-avatar-box .ai-close:focus-visible { outline: 2px solid #0d6efd; border-radius: 6px; }
#ai-log { /* só afeta o modo antigo */ }

/* =================== Dropdown fix (hover + clique) =================== */
/* estado padrão fechado */
.nav-dropdown{
  visibility: hidden;
  opacity: 0;
  transform: scale(.98);
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
}

/* abre por hover OU por clique (data-open="true") */
li[data-dropdown][data-open="true"] > .nav-dropdown,
li.group:hover > .nav-dropdown,
li.group:focus-within > .nav-dropdown{
  visibility: visible;
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* evita “gap” visual entre botão e menu (opcional): 
   cria uma pequena área de 8px que mantém o hover ao passar o mouse */
li[data-dropdown] > .nav-dropdown::before{
  content:"";
  position:absolute;
  top:-8px; left:0; right:0; height:8px;
}

/* acessibilidade (cursor e focos) */
li[data-dropdown] > [data-toggle]{ cursor: pointer; }

/* ===== Acessibilidade: modo P&B global ===== */
html.a11y-grayscale {
  -webkit-filter: grayscale(1) !important;
          filter: grayscale(1) !important;
}
/* (Opcional) Permitir escapar do P&B em elementos específicos */
html.a11y-grayscale [data-no-grayscale] {
  -webkit-filter: none !important;
          filter: none !important;
}

/* ===== Alto contraste global (site inteiro) — versão reforçada ===== */
html.a11y-hc,
html.a11y-hc body {
  background: #000 !important;
  color: #f5f7fa !important; /* texto base claro */
}

/* 1) DEIXA TODO TEXTO CLARO (vence utilities do Tailwind) */
html.a11y-hc body,
html.a11y-hc body * {
  color: #f5f7fa !important;
}

/* 2) FUNDOS CLAROS VÃO PARA ESCURO (vence bg-white, bg-slate-50, etc.) */
html.a11y-hc .bg-white,
html.a11y-hc .bg-slate-50,
html.a11y-hc .bg-slate-100,
html.a11y-hc .bg-gray-50,
html.a11y-hc .bg-gray-100,
html.a11y-hc .backdrop-blur,
html.a11y-hc .shadow,
html.a11y-hc .shadow-soft,
html.a11y-hc [class*="bg-"] {
  background: #111 !important;
}

/* 3) LINKS: amarelo forte e perceptível */
html.a11y-hc a {
  color: #ffeb3b !important;
  text-decoration: underline !important;
  text-underline-offset: 2px;
}

/* 4) TÍTULOS DESTACADOS (fundo amarelo + texto preto) */
html.a11y-hc h1:not([data-no-hc-highlight]),
html.a11y-hc h2:not([data-no-hc-highlight]),
html.a11y-hc h3:not([data-no-hc-highlight]) {
  background: #ffeb3b !important;
  color: #000 !important;        /* reimpõe preto */
  padding: .15em .35em;
  border-radius: 6px;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.2;
  display: inline-block;
}

/* 5) BOTÕES / CONTROLES: alto contraste invertido */
html.a11y-hc button,
html.a11y-hc [role="button"],
html.a11y-hc input[type="button"],
html.a11y-hc input[type="submit"],
html.a11y-hc .btn {
  background: #fff !important;
  color: #000 !important;
  border: 2px solid #fff !important;
}

/* 6) FORMULÁRIOS E PLACEHOLDER */
html.a11y-hc input,
html.a11y-hc select,
html.a11y-hc textarea {
  background: #000 !important;
  color: #f5f7fa !important;
  border: 2px solid #fff !important;
}
html.a11y-hc ::placeholder {
  color: #e3e8f2 !important;
  opacity: 1 !important;
}
html.a11y-hc :disabled {
  color: #cfd7e3 !important;
}

/* 7) SVGs / ícones em linha (stroke/fill) */
html.a11y-hc svg { color: #f5f7fa !important; }
html.a11y-hc svg [stroke] { stroke: #f5f7fa !important; }
html.a11y-hc svg [fill]:not([fill="none"]) { fill: #f5f7fa !important; }

/* 8) “Muted” do Tailwind continuam claros */
html.a11y-hc .text-slate-500,
html.a11y-hc .text-gray-500,
html.a11y-hc .text-neutral-500,
html.a11y-hc small,
html.a11y-hc .text-xs {
  color: #e9edf5 !important;
}

/* 9) Bordas, divisores e foco bem visíveis */
html.a11y-hc *,
html.a11y-hc hr {
  border-color: #fff !important;
}
html.a11y-hc :focus-visible {
  outline: 3px solid #ffeb3b !important;
  outline-offset: 2px !important;
}

/* 10) Tabelas */
html.a11y-hc table { color: #f5f7fa !important; border-color: #fff !important; }
html.a11y-hc th, html.a11y-hc td { border-color: #fff !important; }

/* 11) Listas mais legíveis */
html.a11y-hc li { margin-bottom: .25rem; }

/* ===== Escapes úteis (caso precise “furar” o HC em pontos específicos) ===== */
/* exemplo: <div data-no-hc-bg> mantém o background original mesmo no HC */
html.a11y-hc [data-no-hc-bg] { background: unset !important; }
html.a11y-hc [data-no-hc-color] { color: unset !important; }
