/* GPTTargetIA no estilo do Codex: barra lateral, conversa centralizada e caixa de mensagem. */

:root {
  --fundo: #ffffff;
  --lateral: #f7f7f8;
  --superficie: #ffffff;
  --superficie-2: #f3f3f4;
  --realce: #ececee;
  --borda: #e4e4e7;
  --borda-forte: #d4d4d8;
  --texto: #18181b;
  --texto-2: #52525b;
  --texto-3: #8b8b93;
  --destaque: #0f7d67;
  --destaque-suave: #e7f5f1;
  --perigo: #c0392b;
  --bolha: #f1f1f3;
  --codigo: #f6f6f7;
  --sombra: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .08);
  --sombra-forte: 0 24px 64px rgba(0, 0, 0, .18);
  --raio: 12px;
  --raio-caixa: 22px;
  --coluna: 760px;
  --fonte: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --fundo: #1f1f1f;
    --lateral: #181818;
    --superficie: #262626;
    --superficie-2: #2c2c2c;
    --realce: #333333;
    --borda: #343434;
    --borda-forte: #444444;
    --texto: #ececec;
    --texto-2: #b4b4b4;
    --texto-3: #8a8a8a;
    --destaque: #3cc7a6;
    --destaque-suave: #1d3631;
    --bolha: #2f2f2f;
    --codigo: #171717;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-tema="escuro"] {
  --fundo: #1f1f1f;
  --lateral: #181818;
  --superficie: #262626;
  --superficie-2: #2c2c2c;
  --realce: #333333;
  --borda: #343434;
  --borda-forte: #444444;
  --texto: #ececec;
  --texto-2: #b4b4b4;
  --texto-3: #8a8a8a;
  --destaque: #3cc7a6;
  --destaque-suave: #1d3631;
  --bolha: #2f2f2f;
  --codigo: #171717;
  --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--fundo);
  color: var(--texto);
  font: 15px/1.6 var(--fonte);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.app { display: flex; height: 100dvh; overflow: hidden; }
body.sem-login .app { filter: blur(3px); pointer-events: none; user-select: none; }

/* ---------- Barra lateral ---------- */
.lateral {
  width: 264px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 10px 8px;
  background: var(--lateral);
  border-right: 1px solid var(--borda);
}
.lateral-topo { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; }
.marca { display: flex; align-items: center; gap: 9px; color: var(--texto); text-decoration: none; font-weight: 600; letter-spacing: -.01em; }
.marca img { width: 26px; height: auto; }
.lateral-acao {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 7px 10px;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--texto); text-align: left; font-size: 14px;
}
.lateral-acao:hover { background: var(--realce); }
.lateral-acao span { flex: 1; }
.lateral-acao kbd { font: 11px var(--fonte); color: var(--texto-3); }
.busca-conversas {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 0 4px; padding: 6px 10px;
  border: 1px solid var(--borda); border-radius: 8px; background: var(--superficie);
  color: var(--texto-3);
}
.busca-conversas input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 14px; color: var(--texto); }
.lista-titulo { padding: 12px 10px 4px; font-size: 12px; color: var(--texto-3); }
.lista-conversas { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.item-conversa {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 6px 10px;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--texto-2); font-size: 14px; text-align: left;
}
.item-conversa span { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.item-conversa time { font-size: 12px; color: var(--texto-3); }
.item-conversa:hover { background: var(--realce); color: var(--texto); }
.item-conversa.ativa { background: var(--realce); color: var(--texto); font-weight: 500; }
.lista-vazia { padding: 8px 10px; color: var(--texto-3); font-size: 13px; }
.lateral-rodape { position: relative; border-top: 1px solid var(--borda); padding-top: 8px; margin-top: 6px; }
.conta {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; text-align: left;
}
.conta:hover { background: var(--realce); }
.conta-nome { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--destaque); color: #fff; font-size: 13px; font-weight: 600; text-transform: uppercase;
}
.menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 30;
  padding: 5px; border: 1px solid var(--borda); border-radius: 10px;
  background: var(--superficie); box-shadow: var(--sombra);
}
.menu button { display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-size: 14px; }
.menu button:hover { background: var(--realce); }

/* ---------- Área principal ---------- */
.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.topo { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 16px; flex: none; }
.titulo-conversa { flex: 1; margin: 0; font-size: 15px; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.topo-acoes { display: flex; gap: 4px; }
.icone-botao {
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 0; border-radius: 8px; background: transparent; color: var(--texto-2);
}
.icone-botao:hover { background: var(--realce); color: var(--texto); }
.so-celular { display: none; }

.conversa { flex: 1; overflow-y: auto; padding: 8px 16px 24px; scroll-behavior: smooth; }
.mensagens { max-width: var(--coluna); margin: 0 auto; display: flex; flex-direction: column; gap: 26px; }

.boas-vindas { max-width: var(--coluna); margin: 12vh auto 0; text-align: center; }
.boas-vindas img { width: 52px; height: auto; opacity: .9; }
.boas-vindas h2 { margin: 14px 0 6px; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.boas-vindas p { margin: 0 auto 22px; max-width: 520px; color: var(--texto-2); }

.msg-usuario { align-self: flex-end; max-width: 80%; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.msg-usuario .bolha {
  padding: 10px 16px; border-radius: 20px; background: var(--bolha);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 260px;
  padding: 4px 10px; border: 1px solid var(--borda); border-radius: 8px;
  background: var(--superficie); color: var(--texto-2); font-size: 13px;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg-assistente { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.passos { display: flex; flex-direction: column; gap: 2px; }
.passo { display: flex; align-items: center; gap: 8px; color: var(--texto-3); font-size: 13.5px; min-width: 0; }
.passo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.passo svg { width: 15px; height: 15px; }
.pensando { display: flex; align-items: center; gap: 8px; color: var(--texto-3); font-size: 14px; }
.pensando::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--texto-3);
  animation: pulso 1.2s ease-in-out infinite;
}
@keyframes pulso { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }

.texto { min-width: 0; overflow-wrap: anywhere; }
.texto > :first-child { margin-top: 0; }
.texto > :last-child { margin-bottom: 0; }
.texto p, .texto ul, .texto ol, .texto table, .texto pre, .texto blockquote { margin: 0 0 12px; }
.texto h1, .texto h2, .texto h3, .texto h4 { margin: 20px 0 8px; line-height: 1.3; letter-spacing: -.01em; }
.texto h1 { font-size: 21px; } .texto h2 { font-size: 18px; } .texto h3 { font-size: 16px; }
.texto ul, .texto ol { padding-left: 22px; }
.texto li + li { margin-top: 3px; }
.texto a { color: var(--destaque); text-underline-offset: 2px; }
.texto code { font: 13.5px var(--mono); padding: 1px 5px; border-radius: 5px; background: var(--codigo); border: 1px solid var(--borda); }
.texto pre { position: relative; padding: 14px 16px; border: 1px solid var(--borda); border-radius: 10px; background: var(--codigo); overflow-x: auto; }
.texto pre code { padding: 0; border: 0; background: none; font-size: 13px; line-height: 1.55; }
.texto blockquote { padding-left: 14px; border-left: 3px solid var(--borda-forte); color: var(--texto-2); }
.texto table {
  display: block; width: 100%; max-width: 100%; overflow-x: auto;
  border-collapse: collapse; font-size: 14px; overscroll-behavior-x: contain;
}
.texto th, .texto td {
  min-width: 16ch; padding: 8px 10px; border: 1px solid var(--borda);
  text-align: left; vertical-align: top; overflow-wrap: break-word; word-break: normal;
}
.texto th[align="center"], .texto td[align="center"] { text-align: center; }
.texto th[align="right"], .texto td[align="right"] { text-align: right; }
.texto th { background: var(--superficie-2); font-weight: 600; }
.copiar-codigo {
  position: absolute; top: 6px; right: 6px; padding: 2px 8px; border: 1px solid var(--borda);
  border-radius: 6px; background: var(--superficie); color: var(--texto-3); font-size: 12px; opacity: 0;
}
.texto pre:hover .copiar-codigo { opacity: 1; }

.imagens { display: flex; flex-wrap: wrap; gap: 10px; }
.imagens a { display: block; }
.imagens img { display: block; max-width: min(100%, 420px); max-height: 420px; border-radius: 12px; border: 1px solid var(--borda); }
.msg-usuario .imagens img { max-width: 220px; max-height: 220px; }

.fontes { display: flex; flex-wrap: wrap; gap: 6px; }
.fonte {
  display: inline-flex; align-items: center; gap: 6px; max-width: 280px;
  padding: 3px 10px; border: 1px solid var(--borda); border-radius: 999px;
  color: var(--texto-2); font-size: 12.5px; text-decoration: none;
}
.fonte span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fonte:hover { background: var(--realce); color: var(--texto); }

.rodape-msg { display: flex; align-items: center; gap: 4px; color: var(--texto-3); font-size: 12.5px; }
.rodape-msg .icone-botao { width: 28px; height: 28px; }
.rodape-msg .icone-botao svg { width: 15px; height: 15px; }
.msg-assistente .rodape-msg { opacity: 0; transition: opacity .15s; }
.msg-assistente:hover .rodape-msg, .msg-assistente:focus-within .rodape-msg { opacity: 1; }
.avisos { color: var(--texto-2); font-size: 13.5px; padding: 8px 12px; border-radius: 8px; background: var(--superficie-2); }
.erro-msg { color: var(--perigo); }

.orcamento {
  padding: 14px 16px; border: 1px solid var(--borda); border-radius: var(--raio);
  background: var(--superficie); box-shadow: var(--sombra); max-width: 520px;
}
.orcamento h3 { margin: 0 0 4px; font-size: 15px; }
.orcamento p { margin: 0 0 6px; color: var(--texto-2); font-size: 14px; }
.orcamento .valor { font-size: 22px; font-weight: 600; color: var(--texto); }
.orcamento .pedido { max-height: 96px; overflow: auto; font-size: 13px; color: var(--texto-3); }
.orcamento .acoes { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- Caixa de mensagem ---------- */
.compositor { flex: none; padding: 0 16px 10px; }
.caixa {
  max-width: var(--coluna); margin: 0 auto;
  border: 1px solid var(--borda); border-radius: var(--raio-caixa);
  background: var(--superficie); box-shadow: var(--sombra);
  padding: 10px 10px 8px 14px;
}
.caixa:focus-within { border-color: var(--borda-forte); }
.caixa textarea {
  display: block; width: 100%; max-height: 40vh; min-height: 26px; resize: none;
  border: 0; outline: 0; background: transparent; padding: 4px 4px 6px; line-height: 1.5;
}
.caixa textarea::placeholder { color: var(--texto-3); }
.caixa-rodape { display: flex; align-items: center; gap: 4px; }
.espaco { flex: 1; }
.anexos { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 8px; }
.anexo {
  display: inline-flex; align-items: center; gap: 6px; max-width: 240px;
  padding: 4px 6px 4px 10px; border: 1px solid var(--borda); border-radius: 8px;
  background: var(--superficie-2); font-size: 13px;
}
.anexo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anexo button { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 4px; background: transparent; color: var(--texto-3); }
.anexo button:hover { background: var(--realce); color: var(--texto); }
.anexo button svg { width: 12px; height: 12px; }

.seletor { position: relative; }
.pilula {
  display: inline-flex; align-items: center; gap: 4px; max-width: 260px;
  padding: 5px 8px 5px 10px; border: 0; border-radius: 999px; background: transparent;
  color: var(--texto-2); font-size: 13.5px;
}
.pilula span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pilula svg { width: 14px; height: 14px; }
.pilula:hover, .pilula[aria-expanded="true"] { background: var(--realce); color: var(--texto); }
.painel-modelos, .painel-esforco {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 40;
  border: 1px solid var(--borda); border-radius: 12px; background: var(--superficie); box-shadow: var(--sombra);
}
.painel-modelos { width: min(380px, 86vw); padding: 8px; }
.painel-modelos input {
  width: 100%; padding: 7px 10px; margin-bottom: 6px;
  border: 1px solid var(--borda); border-radius: 8px; background: var(--superficie-2); outline: 0; font-size: 14px;
}
.lista-modelos { max-height: min(420px, 55vh); overflow-y: auto; }
.grupo-modelos { padding: 8px 8px 3px; font-size: 11.5px; font-weight: 600; color: var(--texto-3); text-transform: uppercase; letter-spacing: .04em; }
.opcao {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border: 0; border-radius: 7px; background: transparent; text-align: left; font-size: 14px;
}
.opcao:hover, .opcao.foco { background: var(--realce); }
.opcao .nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opcao .extra { font-size: 12px; color: var(--texto-3); white-space: nowrap; }
.opcao .marca-ok { width: 16px; color: var(--destaque); }
.painel-esforco { width: 220px; padding: 5px; }

.enviar {
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: 50%; background: var(--texto); color: var(--fundo);
}
.enviar:disabled { opacity: .3; cursor: default; }
.enviar .parar { display: none; }
.enviar.trabalhando .seta { display: none; }
.enviar.trabalhando .parar { display: block; fill: currentColor; stroke: none; }
.aviso-rodape { max-width: var(--coluna); margin: 6px auto 0; text-align: center; font-size: 12px; color: var(--texto-3); }

.soltar {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: color-mix(in srgb, var(--fundo) 80%, transparent);
  border: 2px dashed var(--destaque); font-size: 18px; color: var(--destaque);
}

/* ---------- Botões, campos e diálogos ---------- */
.botao { padding: 8px 16px; border-radius: 10px; border: 1px solid var(--borda); background: var(--superficie); font-size: 14px; font-weight: 500; }
.botao:hover { background: var(--realce); }
.botao.primario { border-color: var(--texto); background: var(--texto); color: var(--fundo); }
.botao.primario:hover { opacity: .88; }
.botao:disabled { opacity: .5; cursor: default; }
.botao.largo { width: 100%; padding: 10px 16px; }
.link { border: 0; background: none; color: var(--texto-2); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--texto); }
.campo { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: var(--texto-2); text-align: left; }
.campo input, .campo select {
  padding: 9px 12px; border: 1px solid var(--borda); border-radius: 10px;
  background: var(--superficie); color: var(--texto); font-size: 15px; outline: 0;
}
.campo input:focus, .campo select:focus { border-color: var(--destaque); box-shadow: 0 0 0 3px var(--destaque-suave); }

.dialogo {
  width: min(460px, calc(100vw - 32px)); padding: 0;
  border: 1px solid var(--borda); border-radius: 16px; background: var(--superficie); color: var(--texto);
  box-shadow: var(--sombra-forte);
}
.dialogo::backdrop { background: rgba(0, 0, 0, .35); }
.dialogo-corpo { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.dialogo-corpo h2 { margin: 0; font-size: 18px; }
.dialogo-corpo p { margin: 0; color: var(--texto-2); font-size: 14px; }
.dialogo-acoes { display: flex; justify-content: flex-end; gap: 8px; }
.estado-conversao:empty { display: none; }

.login-fundo {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--fundo) 45%, transparent);
}
.login {
  width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px;
  padding: 28px 26px 22px; border: 1px solid var(--borda); border-radius: 18px;
  background: var(--superficie); box-shadow: var(--sombra-forte); text-align: center;
}
.login img { width: 46px; height: auto; margin: 0 auto; }
.login h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.login-sub { margin: -6px 0 4px; color: var(--texto-2); font-size: 14px; }
#camposCadastro { display: flex; flex-direction: column; gap: 14px; }
.login-erro { margin: 0; min-height: 0; color: var(--perigo); font-size: 13.5px; }
.login-erro:empty { display: none; }

/* ---------- Celular ---------- */
@media (max-width: 760px) {
  .so-celular { display: grid; }
  .lateral {
    position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(300px, 86vw);
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .app.lateral-aberta .lateral { transform: none; box-shadow: var(--sombra-forte); }
  .sombra-lateral { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .35); }
  .topo { padding: 0 8px; }
  .conversa { padding: 8px 16px 16px; }
  .compositor { padding: 0 8px 8px; }
  .msg-usuario { max-width: 92%; }
  .boas-vindas { margin-top: 6vh; }
  .lateral-acao kbd { display: none; }
  .pilula { max-width: 150px; }
}
.area-pdf-resposta { display: none; }
@media (hover: none) { .msg-assistente .rodape-msg { opacity: 1; } }

@media print {
  @page { margin: 16mm; }
  body.imprimindo-resposta > :not(.area-pdf-resposta) { display: none !important; }
  body.imprimindo-resposta { margin: 0; background: #fff !important; color: #111 !important; }
  .area-pdf-resposta { display: block !important; color: #111; font: 11pt/1.45 Arial, sans-serif; }
  .area-pdf-resposta .titulo-pdf { margin: 0 0 12mm; font-size: 17pt; line-height: 1.25; }
  .area-pdf-resposta .msg-assistente { display: block; }
  .area-pdf-resposta .texto, .area-pdf-resposta .texto * { overflow: visible; max-width: none; }
  .area-pdf-resposta .texto { overflow-wrap: anywhere; }
  .area-pdf-resposta .texto table { display: table; width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 9pt; }
  .area-pdf-resposta .texto thead { display: table-header-group; }
  .area-pdf-resposta .texto tr { break-inside: avoid; }
  .area-pdf-resposta .texto th, .area-pdf-resposta .texto td { min-width: 0; overflow-wrap: anywhere; padding: 5px 7px; border: 1px solid #999; vertical-align: top; }
  .area-pdf-resposta .texto th { background: #eee !important; color: #111 !important; }
  .area-pdf-resposta .texto a { color: #075c51 !important; }
  .area-pdf-resposta .texto pre { white-space: pre-wrap; overflow-wrap: anywhere; border-color: #bbb; }
  .area-pdf-resposta .texto code { white-space: pre-wrap; }
  .area-pdf-resposta .imagens { display: block; }
  .area-pdf-resposta .imagens img { max-width: 100%; max-height: 180mm; margin: 0 0 8mm; object-fit: contain; }
  .area-pdf-resposta .fontes { margin-top: 8mm; }
  .area-pdf-resposta .fonte { display: block; max-width: none; padding: 0; margin: 3mm 0; border: 0; color: #075c51; }
  .area-pdf-resposta .fonte span { overflow: visible; white-space: normal; }
  .area-pdf-resposta .fonte svg { display: none; }
  .area-pdf-resposta .avisos { margin-top: 5mm; }
}

/* Compartilhamento e visualização de cópias de conversa. */
.dialogo-corpo h3 { margin: 4px 0 0; font-size: 15px; }
.dialogo-corpo .estado-compartilhamento { min-height: 1em; color: var(--texto-2); }
.lista-partilhas { display: flex; flex-direction: column; gap: 8px; max-height: 180px; overflow-y: auto; }
.partilha-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; border: 1px solid var(--borda); border-radius: 8px; }
.partilha-item span { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.partilha-item button { flex: none; }
.dialogo-previsao { width: min(760px, calc(100% - 24px)); max-height: 90vh; }
.previsao-partilha { display: flex; flex-direction: column; gap: 18px; max-height: 55vh; overflow: auto; padding: 8px; border: 1px solid var(--borda); border-radius: 8px; }
.previsao-partilha .msg-usuario { align-self: flex-end; }
.previsao-partilha .msg-assistente { align-self: stretch; }

.arquivos-mensagem { justify-content: flex-start; }
.arquivos-mensagem a.chip { text-decoration: none; }
.arquivos-mensagem a.chip:hover { background: var(--realce); color: var(--texto); }
