/* base.css — tokens e átomos do design system.
   Estética: SaaS moderno — neutros frios (slate) + acento índigo. Claro + escuro.
   Mono só em dados. Mesmos NOMES de token de antes: a paleta troca, nada quebra. */

:root {
  /* ── Superfícies — neutros frios (slate) ───────────────────── */
  --canvas:  #E7EAEF;
  --bg:      #F7F8FA;
  --surface: #FFFFFF;
  --panel:   #F3F4F7;
  --inset:   #EDEFF3;

  /* ── Tinta ─────────────────────────────────────────────────── */
  --ink:   #0F172A;
  --ink2:  #334155;
  --muted: #5B6472;
  --faint: #6B7280;          /* AA em texto pequeno */
  --hairline: #E5E8EE;
  --rule:  #D3D8E1;

  /* ── Chrome — superfícies sempre escuras (sidebar, hero, toast). */
  --chrome:     #0F172A;
  --chrome-ink: #FFFFFF;

  /* ── Acento — índigo ───────────────────────────────────────── */
  --accent: #4F46E5;
  --accent-ink: #FFFFFF;
  --accent-soft: #EEF0FE;

  /* ── Status (legado — mantido p/ compatibilidade) ──────────── */
  --ok: #16A34A;     --ok-soft: #E7F6EC;
  --warn: #B45309;   --warn-soft: #FAF0DC;
  --err: #DC2626;    --err-soft: #FBE6E6;

  /* ── Status semânticos do domínio (Disponível/Reservado/ciclo) */
  --st-disp:   #16A34A;  --st-disp-soft:   #E7F6EC;   /* Disponível   */
  --st-resv:   #B45309;  --st-resv-soft:   #FAF0DC;   /* Reservado    */
  --st-sep:    #2563EB;  --st-sep-soft:    #E6EDFD;   /* Em separação */
  --st-pronta: #7C3AED;  --st-pronta-soft: #F0E9FE;   /* Pronta       */
  --st-ret:    #64748B;  --st-ret-soft:    #EEF1F5;   /* Retirada     */
  --st-alert:  #DC2626;  --st-alert-soft:  #FBE6E6;   /* Conflito     */

  /* ── Tendência (setas ↑/↓) do hero. NÃO variam por tema: o .hero é
        sempre escuro (background:var(--chrome)), então ficam pastel claro
        nos dois temas. Por isso ficam fora do bloco [data-theme="dark"]. */
  --hero-delta-up:   #8FE0B4;   /* alta   */
  --hero-delta-down: #F0B5AC;   /* baixa  */

  /* ── Placeholder de imagem ausente (foto de produto/sofá) ──── */
  --sofa-ph: linear-gradient(160deg, #D9CFC1, #8E8273);

  /* ── Tipografia ────────────────────────────────────────────── */
  --sans: 'Geist', -apple-system, system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;
  --serif: 'Instrument Serif', Georgia, serif;
  --fs-xs:11px; --fs-sm:12px; --fs-base:14px; --fs-md:15px;
  --fs-lg:18px; --fs-xl:24px; --fs-2xl:30px; --fs-3xl:40px;

  /* ── Espaçamento (escala 4/8) ──────────────────────────────── */
  --sp-1:4px;  --sp-2:8px;  --sp-3:12px; --sp-4:16px; --sp-5:20px;
  --sp-6:24px; --sp-8:32px; --sp-10:40px; --sp-12:48px;

  /* ── Raio ──────────────────────────────────────────────────── */
  --r-sm:6px; --r-md:10px; --r-lg:14px; --r-xl:18px; --r-pill:999px;

  /* ── Elevação (sombras frias, mais nítidas) ────────────────── */
  --sh-1: 0 1px 2px rgba(15,23,42,.06);
  --sh-2: 0 1px 2px rgba(15,23,42,.04), 0 10px 24px -12px rgba(15,23,42,.20);
  --sh-3: 0 24px 60px -16px rgba(15,23,42,.34);

  /* ── Camadas (z-index) ─────────────────────────────────────── */
  --z-sticky:10; --z-drawer:40; --z-modal:900; --z-toast:1000;
}

/* ── Tema escuro (slate) ─────────────────────────────────────── */
[data-theme="dark"] {
  --canvas:  #060910;
  --bg:      #0B0F19;
  --surface: #131826;
  --panel:   #1A2030;
  --inset:   #222A3C;

  --ink:   #EEF1F7;
  --ink2:  #C5CDDB;
  --muted: #93A0B4;
  --faint: #7B8699;
  --hairline: #232B3B;
  --rule:  #313B4F;

  --chrome: #0B0F19;          /* segue escuro nos dois temas */
  --chrome-ink: #EEF1F7;

  --accent: #818CF8;
  --accent-ink: #0B0F19;
  --accent-soft: #20243F;

  --ok: #4ADE80;   --ok-soft: #0F2A1B;
  --warn: #FBBF24; --warn-soft: #2A2008;
  --err: #F87171;  --err-soft: #2E1517;

  --st-disp:   #4ADE80;  --st-disp-soft:   #0F2A1B;
  --st-resv:   #FBBF24;  --st-resv-soft:   #2A2008;
  --st-sep:    #60A5FA;  --st-sep-soft:    #0F1E3A;
  --st-pronta: #A78BFA;  --st-pronta-soft: #241A3D;
  --st-ret:    #94A3B8;  --st-ret-soft:    #202838;
  --st-alert:  #F87171;  --st-alert-soft:  #2E1517;

  --sofa-ph: linear-gradient(160deg, #2A2E3A, #1A1F2C);
}

* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  font-family: var(--sans);
  color: var(--ink);
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }

/* ── Átomos ──────────────────────────────────────────────────── */
.rule { height: 1px; background: var(--hairline); border: 0; }

.dot { width: 6px; height: 6px; border-radius: 99px; display: inline-block; flex-shrink: 0; background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--err { background: var(--err); }
.dot--muted { background: var(--faint); }

.eyebrow {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 1.2px; color: var(--faint); text-transform: uppercase;
}

.mono { font-family: var(--mono); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 4px;
  background: var(--inset); color: var(--ink2);
  border: 1px solid transparent;
  font-size: 11px; font-weight: 500; letter-spacing: 0.1px; line-height: 1.2;
}
.chip--accent { background: var(--accent-soft); color: var(--accent); }
.chip--ok   { background: var(--ok-soft);   color: var(--ok); }
.chip--warn { background: var(--warn-soft); color: var(--warn); }
.chip--err  { background: var(--err-soft);  color: var(--err); }
.chip--outline { background: transparent; color: var(--ink2); border-color: var(--rule); }

/* ── Badge de status (domínio) ───────────────────────────────── */
/* Pílula com dot (via ::before) + texto. A cor vem dos tokens --st-*;
   o dot herda currentColor, então cor nunca é o único sinal. */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 500; line-height: 1.4;
  white-space: nowrap;
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: var(--r-pill);
  background: currentColor; flex-shrink: 0;
}
.badge--disp   { background: var(--st-disp-soft);   color: var(--st-disp); }
.badge--resv   { background: var(--st-resv-soft);   color: var(--st-resv); }
.badge--sep    { background: var(--st-sep-soft);    color: var(--st-sep); }
.badge--pronta { background: var(--st-pronta-soft); color: var(--st-pronta); }
.badge--ret    { background: var(--st-ret-soft);    color: var(--st-ret); }
.badge--alert  { background: var(--st-alert-soft);  color: var(--st-alert); }

/* ── Skeleton (loading) ──────────────────────────────────────── */
.skeleton {
  display: block; height: 12px; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--inset) 25%, var(--panel) 37%, var(--inset) 63%);
  background-size: 400% 100%; animation: skeleton 1.4s ease infinite;
}
@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ── Botões ──────────────────────────────────────────────────── */
.btn {
  appearance: none; border: 0; cursor: pointer;
  font-family: var(--sans); font-size: 14px; font-weight: 500; letter-spacing: -0.1px;
  padding: 12px 18px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter .15s ease, opacity .15s ease, transform .12s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary:hover:not(:disabled), .btn--accent:hover:not(:disabled) { box-shadow: var(--sh-2); }

/* Movimento reduzido: respeita a preferência do sistema. */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .btn:hover:not(:disabled) { transform: none; }
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn--accent { background: var(--accent); color: var(--accent-ink); }
.btn--accent:hover:not(:disabled) { filter: brightness(1.08); }
.btn--ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.btn--ghost:hover:not(:disabled) { background: var(--inset); }
.btn--full { width: 100%; }
.btn--sm { padding: 8px 12px; font-size: 13px; }

/* ── Inputs ──────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); }
.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--hairline); background: var(--surface);
  font-family: var(--sans); font-size: 14px; color: var(--ink);
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { appearance: none; cursor: pointer; }

/* ── Cartões / superfícies ───────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast-stack {
  position: fixed; top: 18px; right: 18px; z-index: 1000;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 380px;
}
.toast {
  background: var(--chrome); color: var(--chrome-ink);
  border-radius: 12px; padding: 14px;
  display: flex; align-items: flex-start; gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  animation: toast-in .25s ease;
}
.toast__icon {
  width: 28px; height: 28px; border-radius: 99px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--ok); color: #fff; font-weight: 700;
}
.toast--err .toast__icon { background: var(--err); }
.toast__title { font-size: 13px; font-weight: 500; }
.toast__sub { font-size: 11px; color: rgba(255,255,255,0.7); margin-top: 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ── Banner (aviso contextual) ───────────────────────────────── */
.banner {
  padding: 12px 14px; border-radius: 8px;
  background: var(--inset); color: var(--ink2);
  border: 1px solid var(--hairline);
  font-size: 13px; line-height: 1.5;
}
.banner--info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.banner strong { font-weight: 600; }

/* ── Utilidades ──────────────────────────────────────────────── */
.row { display: flex; align-items: center; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }
.ico { flex-shrink: 0; }
/* Ícone do toggle de tema: lua no claro, sol no escuro. */
.t-sun { display: none; }
[data-theme="dark"] .t-moon { display: none; }
[data-theme="dark"] .t-sun { display: inline-flex; }

/* Ação no toast (ex.: Desfazer). */
.toast__action { margin-left: 8px; white-space: nowrap; }

/* Command palette (busca global / ⌘K). */
.cmdk { position: fixed; inset: 0; z-index: var(--z-modal, 900); background: rgba(10,10,8,.45);
  display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.cmdk[hidden] { display: none; }
.cmdk__panel { width: min(560px, 92vw); background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg, 14px); box-shadow: var(--sh-3, 0 30px 80px -20px rgba(0,0,0,.4)); overflow: hidden; }
.cmdk__input { width: 100%; border: 0; border-bottom: 1px solid var(--hairline); background: transparent;
  color: var(--ink); padding: 16px 18px; font-size: 15px; outline: none; }
.cmdk__list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.cmdk__opt { padding: 10px 12px; border-radius: var(--r-sm, 6px); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cmdk__opt.is-sel { background: var(--accent-soft); }
.cmdk__tag { font-family: var(--mono); font-size: 10px; color: var(--faint); text-transform: lowercase; }
.cmdk__empty { padding: 14px 12px; color: var(--faint); font-size: 13px; }

/* Respeita a preferência de menos movimento (acessibilidade). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* Carrinho / reserva em lote na vitrine. */
.prod-card { position: relative; }
.prod-card__pick { position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(255,255,255,.92); border-radius: var(--r-sm); padding: 3px 5px;
  display: inline-flex; box-shadow: var(--sh-1); cursor: pointer; }
.prod-card__pick input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.cart-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px;
  z-index: var(--z-toast, 1000); display: flex; align-items: center; gap: 12px;
  background: var(--chrome); color: var(--chrome-ink); padding: 10px 14px;
  border-radius: var(--r-pill); box-shadow: var(--sh-3); }
.cart-bar[hidden] { display: none; }
.cart-bar__count { font-size: 13px; font-weight: 500; }

/* Navegação mobile do lojista (barra flutuante). Parcial: _tabbar.html */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: calc(100% - 32px); max-width: 412px; z-index: var(--z-drawer);
  background: var(--chrome); color: var(--chrome-ink);
  border-radius: var(--r-pill); padding: 6px; display: flex; gap: 4px;
  box-shadow: var(--sh-3);
}
.tabbar__btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 44px; padding: 10px 8px; border-radius: var(--r-pill); font-size: var(--fs-sm);
  color: rgba(255,255,255,.7); background: transparent; border: 0;
  text-decoration: none; cursor: pointer; font-family: var(--sans); position: relative;
}
.tabbar__btn.is-active { background: var(--accent); color: var(--accent-ink); }
.tabbar__btn:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: -2px; }

/* Skip-link das telas logadas — oculto até receber foco via teclado (WCAG 2.4.1). */
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 1000;
  background: var(--accent); color: var(--accent-ink);
  padding: 8px 16px; border-radius: var(--r-md); font-size: var(--fs-sm);
  text-decoration: none; transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

/* Estado de processando: aplicar .is-loading via JS antes de await; remover depois. */
.btn.is-loading { color:transparent !important; pointer-events:none; position:relative; }
.btn.is-loading::after { content:""; position:absolute; width:14px; height:14px; top:calc(50% - 7px);
  left:calc(50% - 7px); border-radius:50%; border:2px solid currentColor; border-right-color:transparent;
  color:var(--accent-ink); animation:btnspin .6s linear infinite; }
@keyframes btnspin { to { transform:rotate(360deg) } }
@media (prefers-reduced-motion: reduce){ .btn.is-loading::after{ animation-duration:1.6s } }
