/* Meu Parceiro: identidade Global Minds (petróleo), claro/escuro conforme o aparelho.
   Usado também pelo painel (admin.css) e pela página de autorização do ChatGPT. */

@font-face { font-family: "Inter"; src: url("/fontes/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Sora"; src: url("/fontes/sora.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

/* O atributo hidden sempre esconde, mesmo em elementos com display próprio. */
[hidden] { display: none !important; }

:root {
  --fundo: #f6f7f7;
  --cartao: #ffffff;
  --texto: #14201f;
  --suave: #5a6b6a;
  --borda: #dde3e2;
  --destaque: #0b4a5c;       /* petróleo Global Minds */
  --destaque-2: #2a8c8a;     /* verde-água: brilho do selo e da esfera */
  --destaque-texto: #ffffff;
  --balao: #e6eeee;          /* balão do empresário */
  --erro: #a3261c;
  --voz-fundo: #0a1416;
  --voz-texto: #e8f1f0;
  --f-titulo: "Sora", "Segoe UI", system-ui, sans-serif;
  --f-texto: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #0f1415;
    --cartao: #172022;
    --texto: #e6eded;
    --suave: #93a5a4;
    --borda: #263234;
    --destaque: #4fb3b8;
    --destaque-2: #7fd6c9;
    --destaque-texto: #06191c;
    --balao: #1d2a2c;
    --erro: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font: 16px/1.6 var(--f-texto);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
main { max-width: 30rem; margin: 0 auto; padding: 2rem max(16px, env(safe-area-inset-right)) 3rem max(16px, env(safe-area-inset-left)); }
h1, h2 { font-family: var(--f-titulo); font-weight: 600; letter-spacing: -.02em; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.6rem; margin: 0 0 .35rem; }
h2 { font-size: 1.2rem; }
.aviso-teste, .pequeno { color: var(--suave); font-size: .9rem; }
a { color: var(--destaque); }
section { background: var(--cartao); border: 1px solid var(--borda); border-radius: 20px; padding: 1.5rem; margin-top: 1rem; }
label { display: block; margin-bottom: 1rem; font-weight: 500; font-size: .92rem; }
input, select {
  display: block; width: 100%; margin-top: .35rem; padding: .75rem .85rem;
  font: inherit; font-size: 16px; color: inherit; background: var(--fundo);
  border: 1px solid var(--borda); border-radius: 12px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--destaque); box-shadow: 0 0 0 3px color-mix(in srgb, var(--destaque) 20%, transparent); }
button {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 12px;
  padding: .8rem 1.1rem; background: var(--destaque); color: var(--destaque-texto); width: 100%;
  transition: filter .15s, background-color .15s, transform .1s;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:active:not(:disabled) { transform: scale(.98); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--destaque); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secundario { background: transparent; color: var(--destaque); border: 1px solid var(--borda); margin-top: .6rem; }
button.link { background: none; color: var(--destaque); padding: 0; width: auto; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
details { margin-top: 1rem; }
.erro { color: var(--erro); font-weight: 600; min-height: 1.5em; margin: .75rem 0 0; }

/* Marca: selo redondo com brilho + nome */
.marca { display: flex; align-items: center; gap: .6rem; font-family: var(--f-titulo); font-weight: 600; font-size: 1rem; letter-spacing: -.01em; }
.selo {
  display: inline-block; flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--destaque-2), var(--destaque) 70%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--destaque) 14%, transparent);
}

/* Cartões de entrada */
.cartao-entrada { margin-top: 6vh; display: flex; flex-direction: column; gap: .5rem; }
.cartao-entrada .marca { margin-bottom: .75rem; }
.cartao-entrada form { margin-top: .75rem; }
.cartao-entrada > button { margin-top: .5rem; }
#texto-consentimento { line-height: 1.65; }

/* Campo de senha com botão Mostrar/Ocultar */
.campo-senha { display: flex; gap: .4rem; align-items: stretch; margin-top: .35rem; }
.campo-senha input { margin-top: 0; flex: 1; min-width: 0; }
button.ver-senha {
  width: auto; flex: none; padding: 0 .85rem; font-size: .85rem;
  background: transparent; color: var(--destaque); border: 1px solid var(--borda); border-radius: 12px;
}

/* ---------- Chat ----------
   A tela do chat ocupa exatamente a área visível (--altura vem do app.js quando o teclado abre).
   Só a lista de mensagens rola; o topo e a caixa de escrever ficam fixos. */
body.modo-chat { overflow: hidden; position: fixed; inset: 0; }
body.modo-chat main {
  max-width: none; padding: 0; margin: 0;
  height: var(--altura, 100dvh); display: flex; flex-direction: column;
  transform: translateY(var(--deslocamento, 0px));
}
body.modo-chat main > .erro { display: none; }
section.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0; border: 0; border-radius: 0; padding: 0; background: var(--fundo); }

.chat-topo {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(.6rem + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) .6rem max(16px, env(safe-area-inset-left));
}
.topo-acoes { display: flex; align-items: center; gap: .25rem; }
.menu { position: relative; margin: 0; }
.faixa-leitura {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .8rem;
  margin: 0 max(16px, env(safe-area-inset-right)) .4rem max(16px, env(safe-area-inset-left));
  padding: .55rem .8rem; border-radius: 12px; background: var(--balao); font-size: .9rem;
}
.dialogo { border: 1px solid var(--borda); border-radius: 20px; padding: 1.4rem; width: min(26rem, calc(100vw - 32px));
  background: var(--cartao); color: var(--texto); box-shadow: 0 24px 60px -20px rgb(0 0 0 / .45); }
.dialogo::backdrop { background: rgb(0 0 0 / .35); }
.dialogo h2 { margin: 0 0 .4rem; }
.dialogo form { display: flex; flex-direction: column; gap: .6rem; }
.dialogo .opcao { text-align: left; background: var(--fundo); color: var(--texto); border: 1px solid var(--borda); display: flex; flex-direction: column; gap: .2rem; font-weight: 400; }
.dialogo .opcao:hover:not(:disabled) { border-color: var(--destaque); filter: none; }
.dialogo .opcao strong { font-weight: 600; color: var(--destaque); }
.dialogo .opcao span { font-size: .88rem; color: var(--suave); }
.menu summary {
  list-style: none; cursor: pointer; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: var(--suave);
}
.menu summary:hover { background: color-mix(in srgb, var(--texto) 6%, transparent); }
.menu summary svg { width: 20px; height: 20px; }
.menu summary::-webkit-details-marker { display: none; }
.menu-itens {
  position: absolute; right: 0; top: 46px; width: min(18rem, calc(100vw - 32px)); z-index: 5;
  background: var(--cartao); border: 1px solid var(--borda); border-radius: 16px; padding: 1rem;
  box-shadow: 0 16px 40px -16px rgb(0 0 0 / .35); animation: surgir-menu .15s ease-out;
}
@keyframes surgir-menu { from { opacity: 0; transform: translateY(-4px); } }
.menu-nome { margin: 0 0 .25rem; font-weight: 600; }
.menu-itens #uso { margin-top: 0; }
.menu-itens a { display: block; margin: .25rem 0 .5rem; }
.menu-itens select { margin: .35rem 0 .6rem; padding: .55rem; }
.menu-itens { max-height: calc(var(--altura, 100dvh) - 90px); overflow-y: auto; }
#area-relatorios { margin: .4rem 0 .8rem; }
.menu-titulo { margin: .9rem 0 .3rem; font-weight: 600; color: var(--texto); }
.lista-relatorios { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.lista-relatorios a { display: flex; justify-content: space-between; gap: .5rem; font-size: .9rem; text-decoration: none; padding: .45rem .6rem; border: 1px solid var(--borda); border-radius: 10px; }
.lista-relatorios a:hover { border-color: var(--destaque); }
.lista-relatorios .tipo { color: var(--suave); font-size: .8rem; }
.cartao-email { align-self: stretch; display: flex; flex-direction: column; gap: .5rem; padding: 1rem; border: 1px solid color-mix(in srgb, var(--destaque) 45%, var(--borda)); border-radius: 16px; background: var(--cartao); }
.cartao-email p { margin: 0; }
.cartao-email input { margin-top: 0; }
.cartao-email .link { align-self: flex-start; }
.bolha.relatorio { border-left: 3px solid var(--destaque); padding-left: 44px; }
.bolha.relatorio::before { left: 10px; }

.mensagens {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  -webkit-overflow-scrolling: touch;
}
.coluna { max-width: 46rem; margin: 0 auto; padding: .5rem 0 1.5rem; display: flex; flex-direction: column; gap: 1.4rem; }
.boas-vindas { padding-top: 8vh; }
.boas-vindas h2 { font-size: clamp(1.5rem, 5vw, 2rem); margin: 0 0 .4rem; }
.boas-vindas p { margin: 0; color: var(--suave); max-width: 34rem; }
#mais-antigas { align-self: center; font-size: .9rem; }

/* Mensagens: a do empresário em balão; a do parceiro é texto corrido com o selo ao lado. */
.bolha { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.bolha.minha {
  align-self: flex-end; max-width: 85%; background: var(--balao);
  padding: .6rem 1rem; border-radius: 20px 20px 6px 20px;
}
.bolha.parceiro { position: relative; padding-left: 36px; min-height: 26px; }
.bolha.parceiro::before {
  content: ""; position: absolute; left: 0; top: 2px; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--destaque-2), var(--destaque) 70%);
}
/* O selo "respira" enquanto o parceiro pensa ou escreve */
.bolha.parceiro.digitando::before, .bolha.parceiro.pensando::before { animation: respirar 1.6s ease-in-out infinite; }
@keyframes respirar { 0%, 100% { transform: scale(.82); opacity: .7; } 50% { transform: scale(1.05); opacity: 1; } }
.bolha.digitando:empty::after, .bolha.pensando {
  background: linear-gradient(90deg, var(--suave) 0%, var(--texto) 50%, var(--suave) 100%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: varrer 1.8s linear infinite;
}
.bolha.digitando:empty::after { content: "Pensando…"; }
.bolha.digitando.pesquisando:empty::after { content: "Pesquisando na internet…"; }
.bolha.digitando.gerando:empty::after { content: "Gerando o seu relatório em PDF…"; }
@keyframes varrer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.bolha .novo { animation: surgir .35s ease-out both; }
@keyframes surgir { from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; } }
.bolha.falha { color: var(--erro); }
.bolha a { color: var(--destaque); overflow-wrap: anywhere; text-underline-offset: 2px; }
.bolha a.link-relatorio { display: inline-block; margin-top: .3rem; padding: .45rem .9rem; border-radius: 999px; background: var(--destaque); color: var(--destaque-texto); text-decoration: none; font-weight: 600; }
.bolha[data-modo="voz"]:not(:empty):not(.pensando)::after { content: "por voz"; display: block; font-size: .72rem; color: var(--suave); margin-top: .15rem; }
.bolha.minha[data-modo="voz"]::after { text-align: right; }

/* Caixa de escrever: fica colada embaixo da área visível (sobe junto com o teclado) */
.rodape-chat {
  padding: .4rem max(16px, env(safe-area-inset-right)) calc(.75rem + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, transparent, var(--fundo) 35%);
}
.compositor {
  max-width: 46rem; margin: 0 auto; display: flex; align-items: flex-end; gap: .35rem;
  background: var(--cartao); border: 1px solid var(--borda); border-radius: 26px; padding: 6px 6px 6px 1rem;
  box-shadow: 0 8px 28px -14px color-mix(in srgb, var(--texto) 35%, transparent);
  transition: border-color .15s, box-shadow .15s;
}
.compositor:focus-within { border-color: color-mix(in srgb, var(--destaque) 55%, var(--borda)); }
.compositor textarea {
  flex: 1; min-width: 0; resize: none; min-height: 2.5rem; max-height: 140px; padding: .5rem 0;
  font: inherit; font-size: 16px; line-height: 1.5; color: inherit; background: none; border: 0; box-shadow: none !important;
}
.compositor textarea::placeholder { color: var(--suave); }
button.icone {
  width: 40px; height: 40px; padding: 0; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: transparent; color: var(--suave);
}
button.icone svg { width: 20px; height: 20px; }
button.icone:hover:not(:disabled) { background: color-mix(in srgb, var(--texto) 7%, transparent); filter: none; }
button.icone.principal { background: var(--destaque); color: var(--destaque-texto); }
button.icone.principal:hover:not(:disabled) { background: var(--destaque); filter: brightness(1.08); }
#falar .i-carregando { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: girar .8s linear infinite; }
#falar[data-estado="conectando"] .i-voz { display: none; }
#falar[data-estado="conectando"] .i-carregando { display: block; }
@keyframes girar { to { transform: rotate(360deg); } }
.estado { max-width: 46rem; margin: .4rem auto 0; text-align: center; }
.estado:empty { display: none; }

/* ---------- Voz: a barra de escrever vira a barra de voz; o chat continua à vista ---------- */
.barra-voz {
  max-width: 46rem; margin: 0 auto; display: flex; align-items: center; gap: .5rem;
  background: var(--cartao); border: 1px solid color-mix(in srgb, var(--destaque) 45%, var(--borda)); border-radius: 26px;
  padding: 6px 6px 6px 8px; box-shadow: 0 8px 28px -14px color-mix(in srgb, var(--destaque) 55%, transparent);
  animation: surgir-voz .25s ease-out both;
}
@keyframes surgir-voz { from { opacity: 0; transform: translateY(6px); } }
#orbe { width: 44px; height: 44px; flex: none; }
.voz-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.voz-estado { font-weight: 600; font-size: .95rem; }
.voz-tempo { font-size: .78rem; color: var(--suave); font-variant-numeric: tabular-nums; }
#mudo .i-mic-off { display: none; }
#mudo[aria-pressed="true"] { background: var(--texto); color: var(--fundo); }
#mudo[aria-pressed="true"] .i-mic { display: none; }
#mudo[aria-pressed="true"] .i-mic-off { display: block; }
button.icone.encerrar { background: #c7372f; color: #fff; }
button.icone.encerrar:hover:not(:disabled) { background: #c7372f; filter: brightness(1.1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
