/* Estoque do almoxarifado (consulta) — 22/09/2026, pedido do Guilherme: "o layout igual do PCP,
   segundo o princípio da Apple". É o MESMO sistema do public/css/pcp.css (skill apple-design):
   mesmas variáveis de cor, controle segmentado em pílula, números tabulares, resposta no aperto,
   claro/escuro e as três preferências de acessibilidade.

   A tela é desenhada dentro de TRÊS módulos (Compras, Logística e PCP) e só o PCP carrega o pcp.css,
   por isso tudo aqui mora sob .ae — nada escapa para o módulo que a hospeda. Cor nova entra como
   variável; texto pequeno com contraste mínimo de 4,5:1 (valores herdados do pcp.css). */

.ae {
  --ae-bg: transparent;
  --ae-surface: #ffffff;
  --ae-surface-2: #fafafc;
  --ae-ink: #1d1d1f;
  --ae-ink-2: #3a3a3c;
  --ae-muted: #636366;
  --ae-hairline: rgba(0, 0, 0, 0.07);
  --ae-sep: rgba(0, 0, 0, 0.13);
  --ae-fill: rgba(118, 118, 128, 0.14);
  --ae-fill-2: rgba(118, 118, 128, 0.08);
  --ae-hover: rgba(0, 0, 0, 0.028);
  --ae-primary: #15293a;
  --ae-primary-ink: #ffffff;
  --ae-tint: #b4500f;
  --ae-focus: rgba(236, 106, 28, 0.32);
  --ae-ok: #1f7a3a;
  --ae-warn: #b4500f;
  --ae-danger: #c81e1e;
  --ae-info: #1d5fb8;
  --ae-radius: 14px;
  --ae-radius-sm: 9px;
  --ae-shadow-card: 0 0 0 0.5px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 28px -18px rgba(0, 0, 0, 0.2);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  color: var(--ae-ink);
  -webkit-font-smoothing: antialiased;
}
[data-theme="dark"] .ae {
  --ae-surface: #1b1d22;
  --ae-surface-2: #212329;
  --ae-ink: #f5f5f7;
  --ae-ink-2: #d1d1d6;
  --ae-muted: #a1a1a6;
  --ae-hairline: rgba(255, 255, 255, 0.07);
  --ae-sep: rgba(255, 255, 255, 0.14);
  --ae-fill: rgba(118, 118, 128, 0.28);
  --ae-fill-2: rgba(118, 118, 128, 0.18);
  --ae-hover: rgba(255, 255, 255, 0.035);
  --ae-primary: #f3934f;
  --ae-primary-ink: #1b1206;
  --ae-tint: #f3934f;
  --ae-focus: rgba(243, 147, 79, 0.38);
  --ae-ok: #4cc27a;
  --ae-warn: #f3934f;
  --ae-danger: #ff6b6b;
  --ae-info: #7fb2ff;
  --ae-shadow-card: 0 0 0 0.5px rgba(255, 255, 255, 0.07), 0 12px 28px -18px rgba(0, 0, 0, 0.7);
}

/* ── Cabeçalho: título grande, subtítulo neutro, P1 | P9 à direita ─────────────────────────── */
.ae-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin: 2px 2px 16px; }
.ae-titulo { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.022em; line-height: 1.1; margin: 0; }
.ae-sub { font-size: 0.84rem; color: var(--ae-muted); margin-top: 4px; }

/* Controle segmentado (o mesmo das seções do PCP): trilho cinza, a opção ativa vira pílula. */
.ae-seg { display: inline-flex; padding: 2px; border-radius: 10px; background: var(--ae-fill); gap: 2px; }
.ae-seg button {
  appearance: none; border: 0; background: transparent; color: var(--ae-ink-2);
  font: inherit; font-size: 0.86rem; font-weight: 600; padding: 6px 16px; border-radius: 8px; cursor: pointer;
  transition: background 160ms ease, transform 120ms ease;
}
.ae-seg button:hover { color: var(--ae-ink); }
.ae-seg button:active { transform: scale(0.97); }
.ae-seg button[aria-pressed="true"] { background: var(--ae-surface); color: var(--ae-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
.ae-seg button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ae-focus); }

/* ── Resumo: quatro números que também são o filtro ────────────────────────────────────────── */
.ae-resumo { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.ae-tile {
  appearance: none; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--ae-surface); border: 0; border-radius: var(--ae-radius); box-shadow: var(--ae-shadow-card);
  padding: 12px 14px; transition: transform 120ms ease, box-shadow 160ms ease;
}
.ae-tile:active { transform: scale(0.98); }
.ae-tile:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ae-focus), var(--ae-shadow-card); }
.ae-tile .n { display: block; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ae-tile .r { display: block; font-size: 0.8rem; color: var(--ae-muted); margin-top: 3px; }
.ae-tile.falta .n { color: var(--ae-danger); }
.ae-tile.acima .n { color: var(--ae-info); }
.ae-tile.parado .n { color: var(--ae-muted); }
.ae-tile[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ae-primary), var(--ae-shadow-card); }

/* ── Busca e categoria ─────────────────────────────────────────────────────────────────────── */
.ae-barra { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.ae-busca { position: relative; flex: 1; min-width: 220px; }
.ae-busca input {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 0.92rem; color: var(--ae-ink);
  padding: 9px 12px 9px 34px; border: 0; border-radius: 10px; background: var(--ae-fill-2);
  transition: background 160ms ease, box-shadow 160ms ease;
}
.ae-busca input::placeholder { color: var(--ae-muted); }
.ae-busca input:focus { outline: none; background: var(--ae-surface); box-shadow: 0 0 0 3px var(--ae-focus); }
.ae-busca::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-52%); color: var(--ae-muted); font-size: 1.05rem; pointer-events: none; }
.ae-barra select {
  font: inherit; font-size: 0.88rem; color: var(--ae-ink); padding: 8px 10px; border: 0; border-radius: 10px;
  background: var(--ae-fill-2); max-width: 230px;
}
.ae-barra select:focus { outline: none; box-shadow: 0 0 0 3px var(--ae-focus); }
.ae-conta { font-size: 0.82rem; color: var(--ae-muted); margin: 0 2px 8px; }

/* ── Tabela: carta com linhas de meio pixel, cabeçalho que gruda, números tabulares ────────── */
.ae-carta { background: var(--ae-surface); border-radius: var(--ae-radius); box-shadow: var(--ae-shadow-card); overflow: auto; max-height: 70vh; }
.ae-tab { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.86rem; }
.ae-tab th {
  position: sticky; top: 0; z-index: 1; background: var(--ae-surface-2);
  text-align: left; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--ae-muted); padding: 9px 12px; border-bottom: 0.5px solid var(--ae-sep); white-space: nowrap;
}
.ae-tab td { padding: 10px 12px; border-bottom: 0.5px solid var(--ae-hairline); vertical-align: middle; }
.ae-tab tbody tr:last-child td { border-bottom: 0; }
.ae-tab tbody tr:hover td { background: var(--ae-hover); }
.ae-tab .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ae-tab .apagado { color: var(--ae-muted); }
.ae-tab tr.fora td { opacity: 0.62; }
.ae-cod { font-weight: 700; color: var(--ae-ink); text-decoration: none; white-space: nowrap; }
.ae-cod:hover { color: var(--ae-tint); }
.ae-desc { color: var(--ae-ink); }
.ae-cat { display: block; font-size: 0.76rem; color: var(--ae-muted); margin-top: 1px; }

/* Saldo do MEU almoxarifado: número forte, ponto de estado e barra de nível entre mín e máx. */
.ae-saldo { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ae-ponto { width: 8px; height: 8px; border-radius: 50%; background: var(--ae-ok); flex: 0 0 auto; }
.ae-ponto.falta { background: var(--ae-danger); }
.ae-ponto.acima { background: var(--ae-info); }
.ae-ponto.parado, .ae-ponto.sem { background: var(--ae-fill); box-shadow: inset 0 0 0 1px var(--ae-sep); }
.ae-nivel { display: block; width: 72px; height: 4px; border-radius: 3px; background: var(--ae-fill); margin: 5px 0 0 auto; overflow: hidden; }
.ae-nivel > i { display: block; height: 100%; border-radius: 3px; background: var(--ae-ok); }
.ae-nivel.falta > i { background: var(--ae-danger); }
.ae-nivel.acima > i { background: var(--ae-info); }
.ae-cob-baixa { color: var(--ae-warn); font-weight: 700; }
.ae-vazio { padding: 28px 16px; text-align: center; color: var(--ae-muted); }

/* ── Celular: a tabela vira lista de cartas (sem rolagem de lado) ──────────────────────────── */
@media (max-width: 720px) {
  .ae-resumo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ae-carta { max-height: none; background: transparent; box-shadow: none; overflow: visible; }
  .ae-tab thead { display: none; }
  .ae-tab, .ae-tab tbody, .ae-tab tr, .ae-tab td { display: block; width: auto; }
  .ae-tab tr {
    background: var(--ae-surface); border-radius: var(--ae-radius); box-shadow: var(--ae-shadow-card);
    margin-bottom: 10px; padding: 10px 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px;
  }
  .ae-tab td { border: 0; padding: 0; }
  .ae-tab tbody tr:hover td { background: transparent; }
  .ae-tab td.cab { grid-column: 1 / -1; }
  .ae-tab td[data-r]::before { content: attr(data-r); display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.02em; color: var(--ae-muted); }
  .ae-tab .num { text-align: left; }
  .ae-nivel { margin-left: 0; }
}

/* ── Acessibilidade (mesmas três preferências do PCP) ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ae * { transition: none !important; }
  .ae-seg button:active, .ae-tile:active { transform: none; }
}
@media (prefers-contrast: more) {
  .ae { --ae-muted: #3a3a3c; --ae-hairline: rgba(0, 0, 0, 0.2); --ae-sep: rgba(0, 0, 0, 0.35); }
  [data-theme="dark"] .ae { --ae-muted: #d1d1d6; --ae-hairline: rgba(255, 255, 255, 0.22); --ae-sep: rgba(255, 255, 255, 0.4); }
}

/* Lápis de corrigir a descrição (22/09/2026) — só aparece na tela aberta dentro de Compras.
   Fica apagado até o mouse passar pela linha: é uma correção ocasional, não uma ação do dia. */
.ae .ae-editar {
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  line-height: 1;
  color: var(--ae-muted);
  padding: 2px 5px;
  margin-left: 5px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 120ms ease, background-color 120ms ease, color 120ms ease, transform 100ms ease;
}
.ae tr:hover .ae-editar,
.ae .ae-editar:focus-visible { opacity: 1; }
.ae .ae-editar:hover { background: var(--ae-fill); color: var(--ae-ink); }
.ae .ae-editar:active { transform: scale(0.92); }
.ae .ae-editar:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ae-focus); }
/* Em tela de toque não há "passar o mouse": o lápis fica sempre visível, só discreto. */
@media (hover: none) { .ae .ae-editar { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .ae .ae-editar:active { transform: none; } }
