/* ===================== PALETA MUSEU DO IMPERADOR ===================== */
:root{
  --mi-bg:           #f5f5dc; /* bege de fundo */
  --mi-bg-muted:     #eae6d9; /* bege mais escuro (faixas/gradientes) */
  --mi-text:         #3E2C1B; /* marrom principal do texto */
  --mi-card:         #fffdf5; /* branco levemente quente p/ cartões/bolhas */
  --mi-accent:       #B8860B; /* dourado (links/botões/bordas) */
  --mi-accent-dark:  #8B6508; /* dourado escuro (hover/active) */

  /* tons suaves para bolhas de chat */
  --mi-bubble-me:    #f3e7c8; /* dourado bem claro */
  --mi-bubble-bot:   var(--mi-bg-muted);
}

/* ---------- Base ---------- */
body {
  background-color: var(--mi-bg);
  color: var(--mi-text);
}
h1 { font-weight: 700; }

/* Links globais (sem conflitar com Tailwind das páginas) */
a { color: var(--mi-accent); }
a:hover { color: var(--mi-accent-dark); }

/* Blockquotes e elementos com borda de destaque, opcional */
blockquote { border-left: 4px solid var(--mi-accent); }

/* ===================== 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: var(--mi-card);
  box-shadow: 0 4px 10px rgba(0,0,0,0.30);
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none; /* combinado com :focus-visible abaixo */
}
#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: var(--mi-card);
  color: var(--mi-text);
  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;
  border: 1px solid color-mix(in oklab, var(--mi-accent) 25%, transparent);

  /* 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: var(--mi-card) 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 var(--mi-accent);
  outline-offset: 4px;
  border-radius: 50%;
}

/* 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;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border: 1px solid color-mix(in oklab, var(--mi-accent) 30%, transparent);
}
/* 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 color-mix(in oklab, var(--mi-accent) 35%, #ddd);
  background: var(--mi-card);
  color: var(--mi-text);
}

/* 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; color: var(--mi-text);
}
#ze-maria .ze-bubble .ai-close:focus-visible { outline: 2px solid var(--mi-accent); }

/* Área de mensagens */
#ze-maria .ze-bubble #ai-log {
  height: auto;
  max-height: 40vh;
  overflow: auto;
  padding: 10px;
  background: var(--mi-card);
  border-top: 1px solid color-mix(in oklab, var(--mi-accent) 25%, #eee);
  border-bottom: 1px solid color-mix(in oklab, var(--mi-accent) 25%, #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%;
  border: 1px solid color-mix(in oklab, var(--mi-accent) 20%, transparent);
}
#ze-maria .ze-bubble #ai-log .msg.me  { text-align: right; }
#ze-maria .ze-bubble #ai-log .msg.me  .bubble { background: var(--mi-bubble-me); }
#ze-maria .ze-bubble #ai-log .msg.bot .bubble { background: var(--mi-bubble-bot); }

/* 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: var(--mi-card); border-top: 1px solid color-mix(in oklab, var(--mi-accent) 35%, #eee);
}
#ze-maria .ze-bubble #ai-input {
  flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 10px;
  background: #fff; color: var(--mi-text);
}
#ze-maria .ze-bubble #ai-form button {
  padding: 10px 14px; border-radius: 10px; border: 0;
  background: var(--mi-accent); color: #fff;
}
#ze-maria .ze-bubble #ai-form button:hover { background: var(--mi-accent-dark); }

/* Picker de perfil / nome dentro da bolha */
#ze-maria .ze-bubble #ai-profile-picker,
#ze-maria .ze-bubble #ai-name-picker { padding: 12px; background: var(--mi-card); color: var(--mi-text); }
#ze-maria .ze-bubble #ai-profile-picker .picker-btn {
  width: 100%; text-align: left; padding: 10px; border: 1px solid #ddd;
  border-radius: 10px; background: var(--mi-bg-muted); cursor: pointer; color: var(--mi-text);
}
#ze-maria .ze-bubble #ai-profile-picker .picker-btn:hover { background: color-mix(in oklab, var(--mi-bg-muted) 70%, white); }
#ze-maria .ze-bubble #ai-name-picker input {
  width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 10px;
  background: #fff; color: var(--mi-text);
}

/* 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 — compatibilidade ====== */
#ai-avatar-box {
  position: fixed;
  right: 16px;
  bottom: 96px;
  width: 360px;
  max-width: 92vw;
  background: var(--mi-card);
  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;
  color: var(--mi-text);
}
#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; color: var(--mi-text); }
#ai-avatar-box .ai-close:focus-visible { outline: 2px solid var(--mi-accent); border-radius: 6px; }

/* ===================== FIM ===================== */
/* =================== Dropdown (hover + clique) =================== */
.nav-dropdown{
  visibility: hidden;
  opacity: 0;
  transform: scale(.98);
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
}
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;
}
/* “gap” anti-buraco entre botão e menu */
li[data-dropdown] > .nav-dropdown::before{
  content:"";
  position:absolute;
  top:-8px; left:0; right:0; height:8px;
}
/* acessibilidade básica */
li[data-dropdown] > [data-toggle]{ cursor: pointer; }

/* =================== Acessibilidade: modo P&B global =================== */
html.a11y-grayscale {
  -webkit-filter: grayscale(1) !important;
          filter: grayscale(1) !important;
}
html.a11y-grayscale [data-no-grayscale] {
  -webkit-filter: none !important;
          filter: none !important;
}

/* =================== Alto contraste global (site inteiro) =================== */
html.a11y-hc,
html.a11y-hc body {
  background: #000 !important;
  color: #f5f7fa !important;
}

/* 1) Texto claro em todo o site */
html.a11y-hc body,
html.a11y-hc body * {
  color: #f5f7fa !important;
}

/* 2) Fundos claros viram escuros (vence utilities comuns) */
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 bem perceptíveis (usa o dourado do Museu) */
html.a11y-hc a {
  color: var(--mi-accent) !important;
  text-decoration: underline !important;
  text-underline-offset: 2px;
}

/* 4) Títulos destacados */
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: var(--mi-accent) !important;
  color: #000 !important;
  padding: .15em .35em;
  border-radius: 6px;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.2;
  display: inline-block;
}

/* 5) Botões/controles invertidos e com o dourado no foco */
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;
}
html.a11y-hc :focus-visible {
  outline: 3px solid var(--mi-accent) !important;
  outline-offset: 2px !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 */
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) Tons “muted” 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 e divisores visíveis */
html.a11y-hc *,
html.a11y-hc hr {
  border-color: #fff !important;
}

/* 10) Tabelas e listas */
html.a11y-hc table { color: #f5f7fa !important; border-color: #fff !important; }
html.a11y-hc th, html.a11y-hc td { border-color: #fff !important; }
html.a11y-hc li { margin-bottom: .25rem; }

/* 11) Escapes para “furar” o HC em pontos específicos */
html.a11y-hc [data-no-hc-bg] { background: unset !important; }
html.a11y-hc [data-no-hc-color] { color: unset !important; }
