/* PreçoView — admin/ (área da empresa-cliente, uso do atendente)
 * Fase 1: só o essencial pra login/base funcionar (reset, tema, botões, forms,
 * alertas, rodapé fixo). Estilo visual definitivo (neomorfismo/claymorfismo/flat
 * — PADROES.md §15) ainda não escolhido — decisão pra Fase 8 (polish). Por ora,
 * cards flat simples com sombra leve, só pra não ficar sem estilo nenhum.
 * Todas as cores em variável CSS (PADROES.md §7) — nunca cor hardcoded em componente.
 */

/* ── Reset (PADROES.md §7) ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overscroll-behavior-y: none; }
html, body { touch-action: manipulation; }

/* ── Tema claro (padrão) ──────────────────────────────────────────────────── */
:root, [data-theme="claro"] {
  --bg-page: #f4f6f9;
  --bg-card: #ffffff;
  --bg-input: #f4f6f9;
  --bg-hover: #eef1f6;

  --accent: #0ea5e9; /* placeholder — cada empresa pode trocar via config (§7.1) */
  --accent-hover: #0b8fcc;
  --accent-light: #e2f4fd;
  --accent-text: #ffffff;

  --text-primary: #1c2530;
  --text-secondary: #4b5665;
  --text-muted: #7c8797;
  --text-placeholder: #a7afba;

  --border: #dfe4ea;
  --border-focus: var(--accent);

  --shadow-xs: 0 1px 2px rgba(20,25,35,.06);
  --shadow-sm: 0 2px 6px rgba(20,25,35,.08);
  --shadow-md: 0 6px 16px rgba(20,25,35,.10);
  --shadow-lg: 0 12px 32px rgba(20,25,35,.16);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;

  --success: #16a34a; --success-bg: #e4f7ea; --success-border: #bfe9cc;
  --warning: #d97706; --warning-bg: #fdf1de; --warning-border: #f5d9a8;
  --danger:  #dc2626; --danger-bg:  #fbe6e6; --danger-border: #f3c2c2;
  --info:    #2563eb; --info-bg:    #e3ebfd; --info-border:   #bcd0f7;
}

/* ── Tema escuro ──────────────────────────────────────────────────────────── */
[data-theme="escuro"] {
  --bg-page: #12161d;
  --bg-card: #1a2029;
  --bg-input: #12161d;
  --bg-hover: #212834;

  --accent: #38bdf8;
  --accent-hover: #5cc9f9;
  --accent-light: #16313f;
  --accent-text: #0b1620;

  --text-primary: #edf1f5;
  --text-secondary: #b7c0cb;
  --text-muted: #838d99;
  --text-placeholder: #5b6470;

  --border: #2a3140;
  --border-focus: var(--accent);

  --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 2px 6px rgba(0,0,0,.35);
  --shadow-md: 0 6px 16px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.5);

  --success: #4ade80; --success-bg: #16321f; --success-border: #235430;
  --warning: #fbbf24; --warning-bg: #3a2c0d; --warning-border: #5c4715;
  --danger:  #f87171; --danger-bg:  #3a1616; --danger-border: #5c2222;
  --info:    #60a5fa; --info-bg:    #142a4d; --info-border:   #1f3d6b;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, h4 { font-family: 'Sora', 'DM Sans', sans-serif; font-weight: 700; color: var(--text-primary); }
a { color: var(--accent); }

.card { background: var(--bg-card); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 1.25rem; margin-bottom: 1rem; }

/* ── Botões ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: none; cursor: pointer; text-decoration: none;
  font-family: inherit; font-size: .92rem; font-weight: 700;
  padding: .7rem 1.3rem; border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text-primary);
  box-shadow: var(--shadow-xs);
  transition: box-shadow .12s ease, transform .12s ease;
  min-height: 44px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-secondary { color: var(--text-secondary); }
.btn-danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Campos de formulário ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: .82rem; font-weight: 700; color: var(--text-secondary); margin-bottom: .45rem; }
.form-control {
  width: 100%; border: 1px solid var(--border); outline: none;
  background: var(--bg-input); color: var(--text-primary);
  font-family: inherit; font-size: .95rem;
  padding: .8rem 1rem; border-radius: var(--radius-sm);
  min-height: 44px;
}
.form-control:focus { border-color: var(--border-focus); box-shadow: 0 0 0 2px var(--accent-light); }
.form-control::placeholder { color: var(--text-placeholder); }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .35rem; }
.form-row { display: grid; grid-template-columns: 1fr; gap: 1.1rem; }
@media (min-width: 900px) {
  .form-row { grid-template-columns: 1fr 1fr; gap: 0 1rem; }
}
.form-error { font-size: .78rem; color: var(--danger); margin-top: .35rem; display: none; }

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: .5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ── Alertas ──────────────────────────────────────────────────────────────── */
.alert { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 600; margin-bottom: 1rem; }
.alert-success { color: var(--success); background: var(--success-bg); }
.alert-warning { color: var(--warning); background: var(--warning-bg); }
.alert-danger  { color: var(--danger);  background: var(--danger-bg); }
.alert-info    { color: var(--info);    background: var(--info-bg); }

/* ── Campo de senha com olho ─────────────────────────────────────────────────*/
.inp-pwd-wrap { position: relative; }
.inp-pwd-wrap .form-control { padding-right: 2.6rem; }
.btn-pwd-eye { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; padding: .25rem; color: var(--text-muted); display: flex; align-items: center; line-height: 0; }
.btn-pwd-eye:hover { color: var(--text-primary); }
.btn-pwd-eye svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Switch (PADROES.md §9.5) — usado no "lembrar de mim" (nunca checkbox cru) ── */
.x-switch { position: relative; display: inline-flex; flex-shrink: 0; width: 30px; height: 17px; }
.x-switch-input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.x-switch-track { width: 30px; height: 17px; border-radius: 9px; background: var(--border); transition: background .15s; position: relative; }
.x-switch-thumb { position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--bg-card); box-shadow: var(--shadow-xs); transition: transform .15s; }
.x-switch-input:checked + .x-switch-track { background: var(--accent); }
.x-switch-input:checked + .x-switch-track .x-switch-thumb { transform: translateX(13px); }

/* ── Rodapé fixo (PADROES.md §8.5) — versão discreta específica do PreçoView.
   Padrão da casa é uma faixa sólida na cor de acento (ver outros sistemas);
   aqui o usuário pediu algo mais discreto só pra este sistema — decisão
   pontual, não alterar PADROES.md a partir disto. ─────────────────────── */
.footer-fixo {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 250;
  background: var(--bg-card); color: var(--text-muted);
  border-top: 1px solid var(--border);
  text-align: center; font-size: .68rem; font-weight: 600;
  padding: .4rem 1rem;
}
.footer-fixo a { color: var(--text-secondary); text-decoration: none; }

/* ── Pill toggle (Escanear / Buscar) ──────────────────────────────────────── */
.pill-toggle { display: flex; gap: .4rem; background: var(--bg-card); padding: .3rem; border-radius: var(--radius-md); box-shadow: var(--shadow-xs); }
.pill-btn { flex: 1; border: none; background: transparent; cursor: pointer; font-family: inherit; font-weight: 700; font-size: .86rem;
  color: var(--text-muted); padding: .65rem 1rem; border-radius: var(--radius-sm); min-height: 44px; }
.pill-btn.active { background: var(--accent); color: var(--accent-text); }

/* ── Campo de busca com lupa (PADROES.md §9.11) ───────────────────────────── */
.inp-search-wrap { position: relative; }
.inp-search-wrap .form-control { padding-right: 2.2rem; width: 100%; }
.inp-search-clear {
  display: none; position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
  align-items: center; justify-content: center; width: 22px; height: 22px;
  background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: .7rem; border-radius: var(--radius-sm);
}
.inp-search-clear:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn-icon { padding: .7rem; width: 44px; }

/* ── Scanner de código de barras ───────────────────────────────────────────
   Câmera contínua (§7.1 do PROJETO.md) — a linha vermelha é só estética, não
   representa progresso real de detecção (referência de UX validada com o
   usuário: imagetotext.info/br/leitor-de-codigo-de-barras). ─────────────── */
.scanner-wrap {
  position: relative; width: 100%; aspect-ratio: 3/4; max-height: 60vh;
  background: #0b0f14; border-radius: var(--radius-md); overflow: hidden;
}
.scanner-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-frame {
  position: absolute; left: 10%; right: 10%; top: 30%; bottom: 30%;
  border: 2px solid rgba(255,255,255,.75); border-radius: 12px; overflow: hidden;
  /* SEM vinheta escura — achado real (2 reclamações): tanto .35 quanto .18 de
     box-shadow deixavam a área visível escura demais. Câmera fica 100% normal,
     só a moldura com borda clara marca onde mirar (igual à referência de UX). */
  --pvw-scan-h: 200px; /* sobrescrito via JS com a altura real do frame (pvwAjustarLinhaScanner) */
}
.scanner-line {
  position: absolute; left: 4%; right: 4%; height: 2px; top: 4%;
  background: #ef4444; box-shadow: 0 0 8px 1px rgba(239,68,68,.8);
  will-change: transform; /* transform (composited) em vez de animar `top` — não trava
    disputando o thread principal com o processamento pesado do decoder */
  animation: scanline 1.6s linear infinite alternate;
}
@keyframes scanline { from { transform: translateY(0); } to { transform: translateY(var(--pvw-scan-h)); } }
.scanner-hint {
  position: absolute; left: 0; right: 0; bottom: 10px; text-align: center;
  color: #fff; font-size: .8rem; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.scanner-status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: .8rem; color: #fff; text-align: center; padding: 1.5rem;
  background: rgba(11,15,20,.85);
}
.scanner-status svg { width: 32px; height: 32px; }
/* CAUSA REAL da "câmera escura" (achada em 2026-09-06): declarar `display:flex`
   numa classe de autor sempre vence o `display:none` do atributo `hidden` do
   navegador (é precedência de origem no cascade CSS — UA perde pra author
   mesmo com especificidade igual). Resultado: `el.hidden = true` nunca
   escondia de verdade #scannerStatus/#scannerResultado, então essa camada
   escura (rgba(11,15,20,.85)) ficava sempre em cima do vídeo — a vinheta
   removida antes nunca foi a causa. Regra abaixo força o hidden a funcionar. */
.scanner-status[hidden] { display: none; }

/* ── Resultado (produto encontrado) ────────────────────────────────────────── */
.produto-resultado { text-align: center; padding: 1.5rem 1.25rem; }
.produto-resultado .produto-desc { font-size: 1rem; font-weight: 700; margin-bottom: .3rem; }
.produto-resultado .produto-preco { font-family: 'Sora', sans-serif; font-size: 2rem; font-weight: 800; color: var(--accent); margin: .4rem 0 .2rem; }
.produto-resultado .produto-codigo { font-size: .78rem; color: var(--text-muted); font-family: monospace; }

/* ── Lista de resultados da busca ─────────────────────────────────────────── */
.produtos-lista { display: flex; flex-direction: column; gap: .6rem; }
.produto-item { padding: .85rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.produto-item .produto-item-desc { font-size: .88rem; font-weight: 600; line-height: 1.3; }
.produto-item .produto-item-codigo { font-size: .72rem; color: var(--text-muted); font-family: monospace; margin-top: .15rem; }
.produto-item .produto-item-preco { font-family: 'Sora', sans-serif; font-weight: 800; color: var(--accent); white-space: nowrap; }

/* ── Layout: sidebar + topbar (PADROES.md §8.1) ──────────────────────────── */
.app-shell { display: flex; min-height: 100vh; flex: 1; }
.sidebar {
  width: 248px; background: var(--bg-card); flex-shrink: 0;
  padding: 1.1rem .9rem; display: flex; flex-direction: column; gap: .3rem;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 300; overflow-y: auto;
  transform: translateX(-100%); transition: transform .2s ease;
}
.sidebar.open { transform: translateX(0); }
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: .5rem .4rem 1.2rem; }
.sidebar-brand img { width: 34px; height: 34px; border-radius: 10px; }
.sidebar-brand span { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1.05rem; color: var(--text-primary); }
.nav-link {
  display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-weight: 700; font-size: .88rem; text-decoration: none; min-height: 44px;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: var(--bg-hover); }
.nav-link.active { background: var(--accent-light); color: var(--accent); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(20,25,35,.45); z-index: 290; }
.sidebar-overlay.open { display: block; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px; background: var(--bg-card); display: flex; align-items: center; gap: .8rem;
  padding: 0 1.1rem; position: sticky; top: 0; z-index: 200; box-shadow: var(--shadow-xs);
}
.topbar-title { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 1.02rem; flex: 1; }
.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--text-secondary); padding: .5rem;
  border-radius: 10px; display: flex; line-height: 0; min-width: 44px; min-height: 44px;
  align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn svg { width: 20px; height: 20px; }
.menu-btn { display: flex; }

.page-content { flex: 1; padding: 1.1rem 1.1rem calc(1.1rem + 40px); max-width: 480px; width: 100%; margin: 0 auto; }

@media (min-width: 900px) {
  .sidebar { position: sticky; transform: none; }
  .sidebar-overlay { display: none !important; }
  .menu-btn { display: none; }
  .page-content { max-width: 640px; padding: 1.6rem 2rem calc(1.6rem + 40px); }
}

/* ── Tela de login ────────────────────────────────────────────────────────── */
.login-wrap { width: 100%; max-width: 380px; }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: .7rem; margin-bottom: 1.6rem; }
.login-logo h1 { font-family: 'Sora', sans-serif; font-size: 1.3rem; }
.login-card { padding: 1.75rem 1.5rem; }
.login-row-lembrar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.3rem; }
.login-row-lembrar label { font-size: .85rem; font-weight: 600; color: var(--text-secondary); }
.login-footer-link { text-align: center; margin-top: 1.1rem; font-size: .85rem; color: var(--text-muted); }

/* ── Cor de acento — swatches (PADROES.md §7.1) ───────────────────────────── */
.cor-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin-bottom: 1.1rem; position: relative; }
.cor-swatch {
  width: 38px; height: 38px; min-height: 38px; aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent; padding: 0;
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); transition: transform .1s;
}
.cor-swatch:hover { transform: scale(1.08); }
.cor-swatch svg { width: 16px; height: 16px; color: #fff; opacity: 0; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.cor-swatch.selecionado { border-color: var(--text-primary); }
.cor-swatch.selecionado svg { opacity: 1; }
.cor-swatch-outra { background: conic-gradient(from 180deg, #ef4444, #eab308, #22c55e, #06b6d4, #6366f1, #ec4899, #ef4444); }
.cor-swatch-outra svg { color: #fff; opacity: 1; }
.cor-swatch-outra.selecionado svg { opacity: 0; }
.cor-swatch-input-real { position: absolute; width: 1px; height: 1px; min-height: 1px; opacity: 0; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 700; padding: .3rem .7rem; border-radius: 999px; }
.badge-success { color: var(--success); background: var(--success-bg); }
.badge-warning { color: var(--warning); background: var(--warning-bg); }
.badge-danger  { color: var(--danger);  background: var(--danger-bg); }
.badge-info    { color: var(--info);    background: var(--info-bg); }
.badge-muted   { color: var(--text-muted); background: var(--bg-hover); }

/* ── Modal (PADROES.md §9.1) — necessário pro panel/ (Fase 7) ────────────── */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(20,25,35,.5); z-index: 500; align-items: center; justify-content: center; padding: 2rem 1rem; overflow-y: auto; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; max-height: calc(100vh - 4rem); display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem; }
.modal-title { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 1.05rem; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: .3rem; line-height: 0; }
.modal-body { padding: 0 1.25rem 1.1rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.25rem; }

/* ── Menu de contexto (kebab) — §9.2 ──────────────────────────────────────── */
.ctx-menu { position: fixed; z-index: 600; background: var(--bg-card); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: .35rem; min-width: 170px; }
.ctx-item { display: flex; align-items: center; gap: .55rem; padding: .55rem .7rem; border-radius: 8px; font-size: .86rem; font-weight: 600; color: var(--text-primary); cursor: pointer; }
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--danger); }
.ctx-separator { height: 1px; background: var(--border); margin: .3rem 0; }
.row-kebab { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: .4rem; border-radius: 8px; line-height: 0; }
.row-kebab:hover { background: var(--bg-hover); color: var(--text-primary); }
.row-kebab svg { width: 18px; height: 18px; }

/* ── Tela "Empresas" (panel/) — dual markup mobile/desktop (PADROES.md §10) ── */
.empresas-grid { display: flex; flex-direction: column; gap: .7rem; }
.empresas-tabela-wrap { display: none; }
.empresa-item-card { padding: .9rem 1rem; cursor: pointer; }
@media (min-width: 900px) {
  .empresas-grid { display: none; }
  .empresas-tabela-wrap { display: block; }
}

/* ── Pull-to-refresh (PADROES.md §11) ─────────────────────────────────────── */
#ptr-indicator {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%) translateY(-64px); opacity: 0;
  width: 40px; height: 40px; background: var(--accent); color: var(--accent-text);
  border-radius: 50%; box-shadow: var(--shadow-lg); display: flex; align-items: center; justify-content: center;
  z-index: 600; pointer-events: none; transition: transform .26s cubic-bezier(.34,1.4,.64,1), opacity .2s ease;
}
#ptr-indicator.ptr-pulling { transition: none; }
#ptr-indicator svg { width: 20px; height: 20px; display: block; }
#ptr-indicator.ptr-refreshing svg { animation: ptr-spin .65s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ── Modo híbrido offline — Fase 5 (PROJETO.md §7.3) ─────────────────────── */
.produto-offline-aviso { font-size: .76rem; color: var(--warning); font-weight: 700; margin-bottom: .5rem; }
