/* ============================================================
   JADE STOCK — DESIGN SYSTEM v3
   "Mineral Técnico": Engineering UI + disciplina de cor mineral
   
   Regras absolutas:
   1. Fundo neutro puro — zero tint verde no bg ou panels
   2. Verde (jade-core) = acento cirúrgico, máx 3 ocorrências/tela
   3. Estrutura > decoração — borda e espaço criam profundidade
   4. Fonte mono no terminal/carrinho — não em títulos de página
   5. clip-path só em elementos de ação (btn, avatar) — não em cards
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── TOKENS ── */
:root {
  /* Neutros — backbone, sem tint */
  --bg:       #0a0a0a;
  --panel:    #111111;
  --panel-2:  #161616;
  --panel-3:  #1c1c1c;
  --panel-4:  #222222;
  --panel-5:  #2a2a2a;

  --border:     rgba(255,255,255,.07);
  --border-2:   rgba(255,255,255,.12);
  --border-3:   rgba(255,255,255,.18);

  --text:   #e5e5e5;
  --text-2: #888888;
  --text-3: #4a4a4a;

  /* Jade — ACENTO, não fundo */
  --jade:       #34d399;
  --jade-dim:   #1a7a55;
  --jade-tint:  rgba(52,211,153,.07);
  --jade-line:  rgba(52,211,153,.16);
  --jade-glow:  rgba(52,211,153,.25);

  /* Semânticas */
  --red:        #f87171;
  --red-tint:   rgba(248,113,113,.07);
  --red-line:   rgba(248,113,113,.18);
  --amber:      #fbbf24;
  --amber-tint: rgba(251,191,36,.07);
  --blue:       #60a5fa;

  /* Tipografia */
  --font-brand: 'Syne', sans-serif;
  --font-ui:    'DM Sans', sans-serif;
  --font-mono:  'JetBrains Mono', monospace;

  /* Formas */
  --r-xs:   4px;
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-full: 9999px;

  /* Layout */
  --rail-w:     60px;
  --header-h:   52px;
  --terminal-h: 230px;
  --nav-h:      68px;

  /* Faceta — clip-path para botões de ação */
  --facet: 8px;
}

/* ── RESET ── */
*, *::before, *::after {
  box-sizing: border-box; margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html, body {
  height: 100%; background: var(--bg);
  color: var(--text); font-family: var(--font-ui);
  font-size: 14px; overflow: hidden;
}

/* ── APP SHELL ── */
/* Desktop: layout horizontal (rail + workspace) */
/* Mobile: bottom nav */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ── SIDE RAIL (desktop / tablet) ── */
#rail {
  width: var(--rail-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  z-index: 100;
  flex-shrink: 0;
}

.rail-logo {
  width: 28px; height: 28px;
  margin-bottom: 28px;
  flex-shrink: 0;
}

.rail-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); cursor: pointer;
  border-radius: var(--r-md); border: none; background: none;
  margin-bottom: 4px;
  transition: background .12s, color .12s;
  position: relative;
  flex-shrink: 0;
}
.rail-btn:hover  { background: var(--panel-3); color: var(--text-2); }
.rail-btn.active { color: var(--jade); background: var(--jade-tint); }

/* Linha ativa — estilo VSCode, 2px exato */
.rail-btn.active::before {
  content: '';
  position: absolute;
  left: -1px; top: 25%; bottom: 25%;
  width: 2px;
  background: var(--jade);
  border-radius: 0 2px 2px 0;
}
.rail-btn svg { width: 18px; height: 18px; }

.rail-spacer { flex: 1; }

.rail-avatar {
  width: 30px; height: 30px;
  background: var(--panel-3);
  border: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-brand); font-size: 12px; font-weight: 800;
  color: var(--jade); cursor: pointer;
  /* Faceta — único lugar com clip-path */
  clip-path: polygon(0 0, calc(100% - var(--facet)) 0, 100% var(--facet), 100% 100%, 0 100%);
  border-radius: 0;
  transition: filter .12s;
}
.rail-avatar:hover { filter: brightness(1.15); }

/* ── WORKSPACE ── */
#workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

/* ── HEADER ── */
#header {
  height: var(--header-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 20;
}

#header-title {
  font-family: var(--font-brand);
  font-size: 13px; font-weight: 700;
  color: var(--text-2); letter-spacing: 1.5px;
  text-transform: uppercase; flex: 1;
}

/* Divisor vertical — detalhe que faz diferença */
.h-divider {
  width: 1px; height: 16px;
  background: var(--border-2);
  margin: 0 16px; flex-shrink: 0;
}

.op-code {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--jade);
  letter-spacing: .5px;
}

/* ── CANVAS — grid de pontos (Obsidian) ── */
#content {
  flex: 1;
  overflow-y: auto; overflow-x: hidden;
  padding: 20px;
  background-image: radial-gradient(circle, var(--panel-4) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: 0 0;
  scroll-behavior: smooth;
}
#content::-webkit-scrollbar { width: 4px; }
#content::-webkit-scrollbar-thumb { background: var(--panel-5); border-radius: 2px; }

/* Mobile: padding bottom para a nav */
@media (max-width: 600px) {
  #content { padding-bottom: calc(var(--nav-h) + 20px); }
}

/* ── TERMINAL (PDV — painel inferior) ── */
#terminal {
  height: var(--terminal-h);
  background: var(--panel);
  border-top: 1px solid var(--jade-dim);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  box-shadow: 0 -8px 32px rgba(0,0,0,.5);
}

.terminal-bar {
  padding: 7px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  display: flex; justify-content: space-between; align-items: center;
}
.terminal-bar span {
  font-family: var(--font-mono); font-size: 10px; color: var(--jade); letter-spacing: .5px;
}

.terminal-body {
  flex: 1; overflow-y: auto;
  padding: 10px 20px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text);
}
.terminal-body::-webkit-scrollbar { width: 3px; }
.terminal-body::-webkit-scrollbar-thumb { background: var(--panel-5); }

.cart-row {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 5px;
  padding: 3px 0;
}
.cart-row-info { display: flex; gap: 10px; }
.cart-qty { color: var(--jade); }
.cart-row-price { color: var(--text-2); }

.terminal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.term-total {
  font-family: var(--font-mono); font-size: 22px; font-weight: 600;
  color: var(--jade);
}

/* ── BOTTOM NAV (mobile) ── */
#nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}

.nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px; padding: 8px 0;
  border: none; background: none; cursor: pointer;
  color: var(--text-3);
  transition: color .15s;
  position: relative;
}

.nav-pill {
  position: absolute; top: 8px;
  width: 48px; height: 28px;
  background: var(--jade-tint);
  border-radius: var(--r-full);
  opacity: 0; transform: scale(.65);
  transition: opacity .2s, transform .25s cubic-bezier(.34,1.56,.64,1);
}
.nav-btn.active { color: var(--jade); }
.nav-btn.active .nav-pill { opacity: 1; transform: scale(1); }

.nav-btn svg { width: 22px; height: 22px; position: relative; z-index: 1; }
.nav-label {
  font-size: 10px; font-weight: 600; letter-spacing: .5px;
  text-transform: uppercase; font-family: var(--font-brand);
  position: relative; z-index: 1;
}

/* ── CARDS ──
   Neutros. Sem gradiente interno. Profundidade = borda + bg diferente do canvas.
   clip-path só em .card-action (botão grande de ação).
*/
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 10px;
}

/* Card com acento jade — só borda muda */
.card-accent {
  border-color: var(--jade-line);
  background: var(--panel);
}

/* Card de alerta */
.card-warn {
  border-color: var(--red-line);
  background: var(--red-tint);
}

.card-label {
  font-size: 10px; font-weight: 600; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-2);
  margin-bottom: 6px;
}

.card-value {
  font-family: var(--font-brand);
  font-size: 28px; font-weight: 800;
  color: var(--text); line-height: 1.1;
}
.card-value.jade  { color: var(--jade); }
.card-value.red   { color: var(--red); }
.card-value.amber { color: var(--amber); }

.card-sub { font-size: 11px; color: var(--text-2); margin-top: 4px; }

/* Grid 2 colunas para dashboard */
.grid2 {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 10px;
}
.grid2 .card { margin-bottom: 0; }
.grid2 .card-value { font-size: 22px; }

/* Span linha inteira */
.span2 { grid-column: span 2; }

/* ── PROGRESS BAR ── */
.progress-bar {
  height: 3px;
  background: var(--panel-5);
  border-radius: var(--r-full);
  overflow: hidden; margin-top: 10px;
}
.progress-fill {
  height: 100%; background: var(--jade);
  border-radius: var(--r-full);
  transition: width .6s ease;
}

/* ── SECTION LABEL — drive-style ── */
.section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 10px; font-weight: 600; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-3);
  margin: 18px 0 10px;
}
.section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── LIST ── */
.list-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden; margin-bottom: 10px;
}

.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--panel-2); }

.list-name {
  font-family: var(--font-brand); font-size: 14px; font-weight: 600;
  color: var(--text); flex: 1;
}
.list-sub {
  font-size: 11px; color: var(--text-2); margin-top: 2px;
}

/* ── PDV GRID ── */
.prod-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px; margin-bottom: 14px;
}

.prod-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .1s;
}
.prod-card:hover { border-color: var(--border-2); background: var(--panel-2); }
.prod-card:active { transform: scale(.97); }
.prod-card.esgotado { opacity: .3; pointer-events: none; }

.prod-name {
  font-family: var(--font-brand); font-size: 13px; font-weight: 700;
  color: var(--text); line-height: 1.3; margin-bottom: 8px;
  display: block;
}
.prod-price {
  font-family: var(--font-mono); font-size: 15px; font-weight: 600;
  color: var(--jade);
}
.prod-stock {
  font-size: 11px; color: var(--text-2); margin-top: 4px;
  font-family: var(--font-mono);
}

/* ── SEARCH ── */
.search-wrap {
  position: relative; margin-bottom: 14px;
}
.search-wrap svg {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
  width: 16px; height: 16px;
}
.search-wrap input { padding-left: 38px; border-radius: var(--r-full); }

/* ── BOTÕES ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border: none; cursor: pointer;
  font-family: var(--font-brand); font-size: 13px; font-weight: 700;
  letter-spacing: .3px;
  transition: filter .12s, transform .1s;
}
.btn:active { transform: scale(.97); }

/* Botão de ação principal — faceta jade */
.btn-action {
  background: var(--jade); color: #002818;
  clip-path: polygon(0 0, calc(100% - var(--facet)) 0, 100% var(--facet), 100% 100%, 0 100%);
  border-radius: 0;
}
.btn-action:hover { filter: brightness(1.08); }

/* Botões sem faceta */
.btn-primary { background: var(--jade); color: #002818; border-radius: var(--r-md); }
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  background: transparent; color: var(--jade);
  border: 1px solid var(--jade-line); border-radius: var(--r-md);
}
.btn-ghost:hover { background: var(--jade-tint); }

.btn-ghost-red {
  background: transparent; color: var(--red);
  border: 1px solid var(--red-line); border-radius: var(--r-md);
}
.btn-ghost-red:hover { background: var(--red-tint); }

.btn-dim {
  background: var(--panel-3); color: var(--text-2);
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.btn-dim:hover { background: var(--panel-4); color: var(--text); }

.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 11px; }
.btn-xs { height: 26px; padding: 0 10px; font-size: 10px; }

/* ── INPUTS ── */
.field {
  width: 100%; background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 12px 14px;
  font-size: 14px; color: var(--text);
  font-family: var(--font-ui); outline: none;
  transition: border-color .12s;
  -webkit-appearance: none; appearance: none;
}
.field:focus { border-color: var(--border-2); }
.field::placeholder { color: var(--text-3); }
select.field option { background: var(--panel-2); }

label {
  display: block; font-size: 10px; font-weight: 600;
  letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 6px;
}
.form-group { margin-bottom: 14px; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--r-xs);
  font-size: 10px; font-weight: 600; letter-spacing: .3px;
  text-transform: uppercase; font-family: var(--font-mono);
}
.badge-green { background: var(--jade-tint); color: var(--jade);  border: 1px solid var(--jade-line); }
.badge-red   { background: var(--red-tint);  color: var(--red);   border: 1px solid var(--red-line); }
.badge-amber { background: var(--amber-tint); color: var(--amber); border: 1px solid rgba(251,191,36,.2); }
.cat-chip {
  display: inline-block; font-size: 10px; font-weight: 500;
  padding: 2px 8px; border-radius: var(--r-full);
  background: var(--panel-3); color: var(--text-2);
}

/* ── UPLOAD ZONE ── */
.upload-zone {
  border: 1.5px dashed var(--border-2);
  border-radius: var(--r-lg); padding: 28px 16px;
  text-align: center; cursor: pointer;
  transition: border-color .15s;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--jade); }
.upload-zone svg { width: 28px; height: 28px; color: var(--text-3); display: block; margin: 0 auto 10px; }
.upload-zone p { font-size: 13px; color: var(--text-2); }
.upload-zone strong { color: var(--jade); font-weight: 600; }

/* ── MODAL ── */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 200; display: flex; align-items: flex-end;
  backdrop-filter: blur(4px);
}
.modal-sheet {
  background: var(--panel);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--border-2);
  width: 100%; max-height: 90vh; overflow-y: auto;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 16px);
  animation: slideSheet .28s cubic-bezier(.2,0,0,1);
}
@keyframes slideSheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle {
  width: 28px; height: 3px;
  background: var(--panel-5); border-radius: var(--r-full);
  margin: 0 auto 20px;
}
.mapper-row {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px; margin-bottom: 8px;
}

/* ── TOAST ── */
#toast {
  position: fixed; bottom: calc(var(--nav-h) + 12px);
  left: 16px; right: 16px;
  background: var(--panel-5); color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xs); padding: 13px 18px;
  font-size: 13px; font-weight: 500; z-index: 999;
  display: none;
  animation: slideUp .2s cubic-bezier(.2,0,0,1);
}
#toast.error { background: var(--red-tint); color: var(--red); border-color: var(--red-line); }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── LOADING ── */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--panel-5); border-top-color: var(--jade);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  height: 40vh; flex-direction: column; gap: 12px;
}
.loading-overlay p { color: var(--text-2); font-size: 13px; }

/* ── MISC ── */
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.empty   { text-align: center; color: var(--text-2); font-size: 13px; padding: 28px 0; }

/* PDV carrinho — componente separado */
.pdv-cart {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-md); margin-bottom: 14px; overflow: hidden;
}
.pdv-cart-header {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  display: flex; justify-content: space-between; align-items: center;
}
.pdv-cart-header span {
  font-family: var(--font-mono); font-size: 10px; color: var(--jade); letter-spacing: .5px;
}
.pdv-cart-body { padding: 0 14px; max-height: 180px; overflow-y: auto; }
.cart-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--border); gap: 8px;
}
.cart-item:last-child { border-bottom: none; }
.cart-item-name  { font-size: 13px; flex: 1; color: var(--text); }
.cart-item-qty   { display: flex; align-items: center; gap: 6px; }
.qty-btn {
  width: 28px; height: 28px; border-radius: var(--r-full);
  border: 1px solid var(--border-2); background: transparent;
  color: var(--text); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .1s;
}
.qty-btn:hover { background: var(--panel-3); }
.cart-item-price {
  font-family: var(--font-mono); font-weight: 600; font-size: 13px;
  color: var(--jade); min-width: 60px; text-align: right;
}
.pdv-total {
  padding: 12px 14px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.pdv-total-label { font-size: 10px; color: var(--text-2); text-transform: uppercase; letter-spacing: .5px; }
.pdv-total-val {
  font-family: var(--font-mono); font-size: 20px; font-weight: 700;
  color: var(--jade);
}

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 18px; }
.page-header h1 {
  font-family: var(--font-brand); font-size: 20px; font-weight: 800;
  color: var(--text); letter-spacing: -.3px;
}
.page-header p { font-size: 11px; color: var(--text-2); margin-top: 3px; }

/* ── ANIMATIONS ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim-fade { animation: fadeInUp .22s cubic-bezier(.4,0,.2,1) both; }

/* ── RESPONSIVE ──
   Mobile: rail escondido, nav fixa no rodapé
   Desktop: rail visível, nav escondida
*/
@media (max-width: 600px) {
  #rail { display: none; }
  #nav  { display: flex; }
}
@media (min-width: 601px) {
  #rail { display: flex; }
  #nav  { display: none; }
  #content { padding-bottom: 20px; }
}

/* Standalone PWA */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); }
  #nav { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
}