/* Tema da Tecnomize, usado pelo painel (/app), pelo site (/) e pela administração (/admin).
   A interface some: aparecem a foto do produto e o preço. As superfícies vestem o tema do
   Telegram de quem abre (ou os valores abaixo, fora dele). Duas cores com um papel cada:
   turquesa = o toque que leva à oferta; coral = o desconto. São opostas, então o
   desconto é o que mais salta na tela. */
:root {
  --fundo: var(--tg-theme-bg-color, #ffffff);
  --camada: var(--tg-theme-secondary-bg-color, #f1f3f5);
  --texto: var(--tg-theme-text-color, #0f1722);
  --apagado: color-mix(in srgb, var(--texto) 64%, var(--fundo)); /* contraste garantido em qualquer tema */
  --palco: #f1f3f5;        /* onde a foto do produto fica */
  --oferta: #d63a2d;       /* coral: preço em oferta e economia (texto) */
  --oferta-fundo: #ff6b5e; /* selo de desconto */
  --oferta-tinta: #3b0905; /* texto sobre o selo */
  --gema: #14b8a6;         /* turquesa */
  --gema-texto: #0a7f75;   /* a mesma cor, legível como texto em fundo claro */
  --gema-tinta: #042f2b;   /* texto sobre a turquesa */
  --linha: color-mix(in srgb, var(--texto) 11%, transparent);
  --mola: cubic-bezier(.2, .9, .25, 1.12);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --fundo: var(--tg-theme-bg-color, #17212b);
  --camada: var(--tg-theme-secondary-bg-color, #232e3c);
  --texto: var(--tg-theme-text-color, #f4f6f8);
  --palco: #dfe4ea;        /* cinza claro: a foto não ofusca no escuro */
  --oferta: #ff6b5e;
  --gema: #2dd4bf;
  --gema-texto: #4fe3d0;
  color-scheme: dark;
}
@supports (animation-timing-function: linear(0, 1)) {
  :root { --mola: linear(0, .34 8%, .79 18%, 1.05 28%, 1.1 35%, 1.06 45%, 1 58%, .99 70%, 1); }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--texto); overflow-x: clip;
  font: 400 .9375rem/1.4 "Bricolage Grotesque", system-ui, sans-serif;
  font-optical-sizing: auto; font-variant-numeric: tabular-nums;
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; -webkit-tap-highlight-color: transparent; text-align: left; }
:focus-visible { outline: 2px solid var(--gema); outline-offset: 2px; }
dialog:focus-visible { outline: none; }
[hidden] { display: none !important; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* ---- topo ---------------------------------------------------------------- */
.topo { padding: .9rem 1rem .25rem; }
.topo .linha1 { display: flex; align-items: center; justify-content: space-between; }
.marca { margin: 0; display: flex; align-items: center; gap: .5rem; font-weight: 800; font-stretch: 88%; font-size: 1rem; letter-spacing: -.01em; }
.marca img { width: 1.55em; height: 1.55em; border-radius: 28%; flex: none; }
.redondo { width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--camada); display: grid; place-items: center; transition: scale .15s; }
.redondo:active { scale: .92; }
h1 { margin: .9rem 0 0; font-weight: 700; font-stretch: 92%; font-size: 1.7rem; line-height: 1.05; letter-spacing: -.025em; text-wrap: balance; }
.estado { margin: .3rem 0 0; color: var(--apagado); display: flex; align-items: center; gap: .45rem; font-size: .9rem; }
.vivo { width: .5rem; height: .5rem; border-radius: 50%; background: var(--gema); flex: none; }

/* ---- filtros --------------------------------------------------------------- */
.barra {
  position: sticky; top: 0; z-index: 5; padding: .75rem 0 .65rem; display: flex; align-items: center; gap: .5rem;
  background: color-mix(in srgb, var(--fundo) 82%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
}
.filtros { flex: 1; min-width: 0; display: flex; gap: .4rem; overflow-x: auto; padding: 0 .25rem 0 1rem; scrollbar-width: none; }
.modo { flex: none; margin-right: 1rem; width: 2.3rem; height: 2.3rem; }
.modo svg { width: 1.1rem; height: 1.1rem; }
.filtros::-webkit-scrollbar { display: none; }
.filtros button {
  flex: none; border-radius: 999px; background: var(--camada); padding: .5rem .85rem;
  font-weight: 600; font-size: .9rem; white-space: nowrap; transition: background-color .2s, color .2s, scale .15s;
}
.filtros button:active { scale: .95; }
.filtros button[aria-pressed="true"] { background: var(--texto); color: var(--fundo); }
.filtros small { font-weight: 500; opacity: .6; margin-left: .35em; font-size: .85em; }

/* ---- seções ----------------------------------------------------------------- */
main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.6rem; padding-top: .5rem; }
h2 { margin: 0 1rem .7rem; font-weight: 700; font-size: 1.15rem; letter-spacing: -.015em; }

/* O palco: a foto do produto, sem moldura. No claro o branco da foto some no cinza. */
.palco { position: relative; display: block; background: var(--palco); border-radius: 14px; overflow: hidden; aspect-ratio: 1; transition: scale .18s; }
.palco img { width: 100%; height: 100%; object-fit: contain; display: block; padding: 7%; }
.palco img { mix-blend-mode: multiply; } /* o branco da foto some no palco */
.palco .sigla { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 1.6rem; color: #9aa3ad; }

/* A queda: o selo de desconto, em coral. */
.queda {
  display: inline-block; background: var(--oferta-fundo); color: var(--oferta-tinta); border-radius: 999px;
  padding: .18rem .5rem; font-weight: 800; font-stretch: 88%; font-size: .85rem; line-height: 1.2; letter-spacing: -.01em;
}
.palco .queda { position: absolute; left: .5rem; top: .5rem; }

/* ---- em queda agora: carrossel ------------------------------------------------ */
.trilho { display: flex; gap: .75rem; overflow-x: auto; margin: 0; padding: 0 1rem .25rem; scroll-snap-type: x mandatory; scroll-padding-left: 1rem; scrollbar-width: none; }
.trilho::-webkit-scrollbar { display: none; }
.trilho > li { flex: none; width: min(74vw, 19rem); scroll-snap-align: start; list-style: none; }
.grande { display: grid; gap: .5rem; width: 100%; }
.grande .palco { aspect-ratio: 16 / 11; border-radius: 20px; }
.grande .palco .queda { left: .7rem; top: .7rem; font-size: 1.15rem; padding: .25rem .65rem; }
.grande .nome { font-size: .98rem; font-weight: 500; }
.grande .valor b { font-size: 1.75rem; }
.economia { color: var(--oferta); font-weight: 650; font-size: .88rem; }

/* ---- grade ----------------------------------------------------------------------- */
.grade { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.35rem .75rem; margin: 0; padding: 0 1rem; list-style: none; }
@media (min-width: 34rem) { .grade { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.item { display: grid; gap: .4rem; width: 100%; align-content: start; }
/* Lista: a mesma oferta em uma linha, para quem quer ver mais de uma vez. */
.grade.lista { grid-template-columns: minmax(0, 1fr); gap: 0; }
.grade.lista .item { grid-template-columns: 4.9rem minmax(0, 1fr); gap: .2rem .8rem; padding: .7rem 0; border-bottom: 1px solid var(--linha); }
.grade.lista li:last-child .item { border-bottom: 0; }
.grade.lista .palco { grid-row: 1 / span 3; border-radius: 12px; }
.grade.lista .palco .queda { left: .25rem; top: .25rem; font-size: .7rem; padding: .1rem .38rem; }
.grade.lista .nome { align-self: end; }
.item:active .palco, .grande:active .palco { scale: .975; }
.nome { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .875rem; line-height: 1.28; text-wrap: pretty; }
.valor { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 .45rem; }
.valor b { font-weight: 750; font-stretch: 86%; font-size: 1.22rem; letter-spacing: -.02em; line-height: 1.1; }
.valor b.sem { font-size: .9rem; font-weight: 600; font-stretch: 100%; color: var(--apagado); letter-spacing: 0; }
.valor s { color: var(--apagado); font-size: .8rem; }
.valor .de, .d-preco .de { color: var(--apagado); font-size: .8rem; }
.valor b.em-oferta, .d-preco strong.em-oferta { color: var(--oferta); }
.pe { display: flex; flex-wrap: wrap; gap: 0 .5rem; font-size: .78rem; color: var(--apagado); }
.pe b { font-weight: 600; color: var(--texto); }
.pe .forte { color: var(--texto); font-weight: 600; }

.vazio { margin: 0 1rem; padding: 1.1rem; border-radius: 18px; background: var(--camada); }
.vazio p { margin: 0; }
.vazio button { margin-top: .8rem; }
.nota-pe { margin: 0; padding: 0 1rem; color: var(--apagado); font-size: .78rem; }

.osso { border-radius: 14px; aspect-ratio: 1; background: linear-gradient(100deg, var(--camada) 35%, color-mix(in srgb, var(--camada) 55%, var(--fundo)) 50%, var(--camada) 65%); background-size: 240% 100%; animation: brilho 1.2s linear infinite; }
@keyframes brilho { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* ---- botões ------------------------------------------------------------------------ */
.ir { display: block; text-align: center; text-decoration: none; background: var(--gema); color: var(--gema-tinta); border-radius: 16px; padding: .95rem 1rem; font-weight: 750; font-size: 1.05rem; letter-spacing: -.01em; transition: scale .15s, filter .15s; }
.ir:active { scale: .98; filter: brightness(.93); }
.secundario { border-radius: 999px; background: var(--texto); color: var(--fundo); padding: .6rem 1rem; font-weight: 650; }
.discreto { border-radius: 999px; background: var(--camada); padding: .55rem .95rem; font-weight: 600; }

/* ---- folhas (detalhe e ajustes) ---------------------------------------------------- */
dialog {
  margin: auto auto 0; width: 100%; max-width: 36rem; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  border: 0; border-radius: 28px 28px 0 0; background: var(--fundo); color: var(--texto); padding: 0; outline: none;
  translate: 0 100%; transition: translate .42s var(--mola), overlay .42s allow-discrete, display .42s allow-discrete;
}
dialog[open] { translate: 0 0; }
@starting-style { dialog[open] { translate: 0 100%; } }
dialog::backdrop { background: rgb(8 12 18 / 0); transition: background-color .3s, overlay .3s allow-discrete, display .3s allow-discrete; }
dialog[open]::backdrop { background: rgb(8 12 18 / .55); }
@starting-style { dialog[open]::backdrop { background: rgb(8 12 18 / 0); } }
dialog.arrastando { transition: none; }
/* Com transição de visão, é ela que anima a folha (e a foto viaja do card até aqui). */
dialog.vt, dialog.vt::backdrop { transition: none; }
.pega { position: sticky; top: 0; z-index: 2; display: flex; justify-content: center; padding: .6rem 0 .5rem; background: linear-gradient(var(--fundo) 60%, transparent); touch-action: none; }
.pega::before { content: ""; width: 2.5rem; height: .28rem; border-radius: 999px; background: var(--linha); }
.fecha { position: absolute; right: .75rem; top: .75rem; z-index: 3; }
.folha { padding: 0 1.1rem 1.1rem; display: grid; gap: .9rem; }

.folha .d-palco { aspect-ratio: 4 / 3; border-radius: 22px; }
.d-meta { display: flex; flex-wrap: wrap; gap: .1rem .6rem; color: var(--apagado); font-size: .85rem; }
.d-meta b { color: var(--texto); font-weight: 650; }
.d-nome { margin: -.45rem 0 0; font-weight: 600; font-size: 1.2rem; line-height: 1.22; letter-spacing: -.015em; text-wrap: pretty; }
.d-preco { display: flex; align-items: baseline; flex-wrap: wrap; gap: .1rem .7rem; }
.d-preco strong { font-weight: 800; font-stretch: 84%; font-size: 2.75rem; line-height: 1; letter-spacing: -.035em; }
.d-preco strong.sem { font-size: 1.2rem; font-stretch: 100%; letter-spacing: 0; font-weight: 600; }
.d-preco s { color: var(--apagado); font-size: 1rem; }
.d-preco .pag { font-weight: 600; font-size: .9rem; }
.d-preco .de { font-size: 1rem; }
.d-parcelas { margin: -.45rem 0 0; font-weight: 600; font-size: .95rem; }
.d-economia { margin: -.45rem 0 0; display: flex; align-items: center; gap: .55rem; color: var(--oferta); font-weight: 650; }
.d-economia .queda { font-size: 1rem; padding: .22rem .6rem; }
.provas { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.provas li { background: var(--camada); border-radius: 999px; padding: .32rem .7rem; font-size: .85rem; font-weight: 550; }
.provas .estrela { color: #f5a524; }
.cupom { display: flex; align-items: center; justify-content: space-between; gap: .75rem; width: 100%; border: 1.5px dashed color-mix(in srgb, var(--texto) 30%, transparent); border-radius: 16px; padding: .7rem .8rem .7rem .95rem; }
.cupom span { display: grid; }
.cupom small { color: var(--apagado); font-size: .78rem; }
.cupom code { font: inherit; font-weight: 750; font-size: 1.1rem; letter-spacing: .03em; }
.cupom i { font-style: normal; display: inline-flex; align-items: center; gap: .35rem; background: var(--camada); border-radius: 999px; padding: .45rem .8rem; font-weight: 600; font-size: .88rem; }
.cupom i svg { width: 1rem; height: 1rem; }
.origem { margin: 0; color: var(--apagado); font-size: .85rem; line-height: 2; }
.origem span { display: inline-block; background: var(--camada); color: var(--texto); border-radius: 999px; padding: 0 .65rem; font-weight: 550; margin-right: .25rem; line-height: 1.75; }
.acao { position: sticky; bottom: 0; margin: 0 -1.1rem -1.1rem; padding: .8rem 1.1rem calc(1rem + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--fundo) 22%); }
.acao p { margin: .55rem 0 0; text-align: center; color: var(--apagado); font-size: .78rem; }

.folha h3 { margin: 0; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.folha .titulo { margin: 0; font-weight: 750; font-size: 1.5rem; letter-spacing: -.02em; }
.dica { margin: -.6rem 0 0; color: var(--apagado); font-size: .85rem; }
.cats { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.cats button { display: inline-flex; align-items: center; gap: .45rem; border-radius: 999px; background: var(--camada); padding: .55rem .9rem; font-weight: 600; transition: background-color .2s, color .2s, scale .15s; }
.cats button:active { scale: .95; }
.cats button svg { width: 1rem; height: 1rem; display: none; stroke-width: 2.6; }
.cats button[aria-pressed="true"] { background: var(--texto); color: var(--fundo); }
.cats button[aria-pressed="true"] svg { display: block; }
.alertas { margin: 0; padding: 0; list-style: none; }
.alertas li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--linha); }
.alertas .nenhum { color: var(--apagado); border: 0; }
/* Seção que segue o ritmo da folha (grid) sem criar outra caixa. */
.secao { display: contents; }
.secao[hidden] { display: none; }
/* Produtos com preço monitorado: foto, nome, preço de agora → alvo, e as ações. */
.monitor li { justify-content: flex-start; }
.monitor img, .monitor .sem { flex: none; width: 2.75rem; height: 2.75rem; border-radius: 10px; object-fit: contain; background: #fff; }
.monitor .sem { background: var(--camada); }
.monitor .info { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.monitor .nome { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.monitor .preco { font-size: .82rem; color: var(--apagado); }
.monitor .preco b { color: var(--texto); }
.monitor .chegou { color: var(--gema-texto); font-weight: 650; }
.monitor .botoes { flex: none; display: flex; gap: .3rem; }
.monitor .botoes .discreto { padding: .45rem .7rem; font-size: .85rem; }
#fMonitor { flex-wrap: wrap; }
#fMonitor #mLink { flex: 1 1 100%; }
#fMonitor #mAlvo { flex: 1 1 6rem; }
.aviso-m { margin-top: -.6rem; }
form { display: flex; gap: .5rem; }
input[type=text] { flex: 1; min-width: 0; border: 0; border-radius: 14px; background: var(--camada); padding: .75rem .9rem; outline: none; }
input[type=text]:focus-visible { box-shadow: 0 0 0 2px var(--gema); border-radius: 14px; }
input::placeholder { color: var(--apagado); }
.erro { color: var(--oferta); font-weight: 600; margin: -.5rem 0 0; min-height: 1.2em; font-size: .88rem; }
.pausa { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: .9rem; border-top: 1px solid var(--linha); }
.pausa p { margin: 0; font-size: .85rem; color: var(--apagado); }

/* ---- avisos flutuantes ------------------------------------------------------------- */
.novas {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom)); translate: -50% 0; z-index: 8;
  border-radius: 999px; background: var(--texto); color: var(--fundo); padding: .7rem 1.15rem; font-weight: 650;
  box-shadow: 0 10px 30px rgb(8 12 18 / .28);
  transition: translate .45s var(--mola), opacity .25s, display .45s allow-discrete;
}
@starting-style { .novas { translate: -50% 5rem; opacity: 0; } }
#copiado {
  position: fixed; inset: auto 0 calc(1.25rem + env(safe-area-inset-bottom)) 0; margin: 0 auto; width: max-content; max-width: calc(100% - 2rem);
  border: 0; border-radius: 999px; background: var(--texto); color: var(--fundo); padding: .7rem 1.1rem; font-weight: 600;
  opacity: 0; translate: 0 1.5rem; transition: opacity .2s, translate .4s var(--mola), overlay .4s allow-discrete, display .4s allow-discrete;
}
#copiado:popover-open { opacity: 1; translate: 0 0; }
@starting-style { #copiado:popover-open { opacity: 0; translate: 0 1.5rem; } }

/* ---- movimento ----------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .vivo { animation: pulsa 2.4s ease-out infinite; }
  @keyframes pulsa { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gema) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 .55rem transparent; } }
  ::view-transition-group(*) { animation-duration: .4s; animation-timing-function: cubic-bezier(.3, .75, .25, 1); }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }
  ::view-transition-new(folha):only-child { animation: sobe .42s var(--mola) both; }
  ::view-transition-old(folha):only-child { animation: desce .26s ease-in both; }
  @keyframes sobe { from { translate: 0 100%; } }
  @keyframes desce { to { translate: 0 100%; } }
}
@media (prefers-reduced-motion: reduce) {
  *, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
}
