/* ============================================================
   3DGestor — style.css
   Tema escuro, acento azul (extraído da logo), números em monoespaçada
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Cores */
  --bg: #0E1015;
  --surface: #171A21;
  --surface-2: #1E222C;
  --surface-3: #262B37;
  --border: #2A2F3B;
  --border-soft: #21252F;

  --accent: #2F8CFF;
  --accent-dim: #1457A6;
  --accent-soft: rgba(47, 140, 255, 0.14);
  --mint: #33D6A6;
  --mint-soft: rgba(51, 214, 166, 0.12);
  --danger: #FF5C5C;
  --danger-soft: rgba(255, 92, 92, 0.12);
  --warning: #FFC24B;

  --text: #F2F1EC;
  --text-muted: #9399AA;
  --text-faint: #5C6270;

  /* Tipografia */
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Layout */
  --sidebar-w: 232px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px rgba(0,0,0,0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Textura sutil de "mesa de impressão" no fundo */
body {
  background-image:
    linear-gradient(var(--border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 28px 28px;
  background-attachment: fixed;
  background-position: -1px -1px;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

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

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

::selection { background: var(--accent-soft); color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Layout geral ---------- */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 22px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16.5px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color .12s ease, color .12s ease;
}

.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }

/* Defesa extra: garante que nenhum ícone SVG do menu renderize gigante
   caso a folha de estilo demore a carregar ou falhe. */
.nav-link svg, .tabbar svg { max-width: 20px; max-height: 20px; }

.hero-logo {
  display: flex;
  justify-content: center;
  padding: 22px 10px;
}
.hero-logo img {
  width: 100%;
  max-width: 380px;
  height: auto;
  display: block;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-foot {
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
  font-family: var(--font-mono);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 30px 36px 80px;
  max-width: 1180px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 24px; }
.page-header p { margin: 0; color: var(--text-muted); font-size: 13.5px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
  display: block;
}

/* Divisor "linha de camada" — elemento assinatura */
.layer-divider {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, transparent 60%);
  margin: 14px 0 20px;
  opacity: 0.55;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
}

.card + .card { margin-top: 16px; }

.card-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.card-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- Formulários ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }

.field label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.field .hint {
  font-size: 11px;
  color: var(--text-faint);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  width: 100%;
  transition: border-color .12s ease, background-color .12s ease;
}

input:hover, select:hover, textarea:hover { border-color: #3A4152; }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--surface-3);
}

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

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239399AA'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.input-suffix { position: relative; }
.input-suffix input { padding-right: 42px; }
.input-suffix span {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  pointer-events: none;
}

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .08s ease, background-color .12s ease, border-color .12s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}
.btn-primary:hover { background: #4FA0FF; }

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { border-color: #454C5E; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(255,92,92,0.2); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-icon { padding: 8px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.actions-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* ---------- Tabelas ---------- */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

tbody tr:hover { background: var(--surface-2); }

td.num, th.num { font-family: var(--font-mono); text-align: right; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Resultado / tickets de precificação ---------- */

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}
@media (max-width: 860px) { .result-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .result-grid { grid-template-columns: 1fr; } }

.result-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  position: relative;
}

.result-card .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
  margin-bottom: 6px;
}

.result-card .value {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 600;
}

.result-card.highlight {
  background: var(--accent-soft);
  border-color: var(--accent-dim);
  grid-column: span 3;
}
@media (max-width: 860px) { .result-card.highlight { grid-column: span 2; } }
@media (max-width: 560px) { .result-card.highlight { grid-column: span 1; } }

.result-card.highlight .label { color: var(--accent); }

.result-card.highlight .value {
  font-size: 34px;
  color: var(--accent);
  text-shadow: 0 0 24px var(--accent-soft);
}

.result-card.profit .value { color: var(--mint); }

/* Ticket: borda pontilhada no topo lembrando picotado de recibo */
.ticket-top {
  height: 0;
  border-top: 2px dashed var(--border);
  margin-bottom: 16px;
}

/* ---------- Badges / tags ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.badge-mint { background: var(--mint-soft); color: var(--mint); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-muted { background: var(--surface-3); color: var(--text-muted); }

/* ---------- Toast ---------- */

#toast-root {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  min-width: 220px;
}
.toast.success { border-left-color: var(--mint); }
.toast.error { border-left-color: var(--danger); }

/* ---------- Estado vazio ---------- */

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 30px; margin-bottom: 10px; opacity: 0.7; }
.empty-state h3 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty-state p { font-size: 13px; margin: 0 0 16px; }

/* ---------- Filtros (histórico) ---------- */

.filters-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filters-bar > * { flex: 1; min-width: 160px; }
.filters-bar .btn { flex: 0 0 auto; }

/* ---------- Mobile: sidebar vira barra inferior ---------- */

.topbar-mobile { display: none; }

@media (max-width: 860px) {
  .app { flex-direction: column; }

  .sidebar {
    display: none;
  }

  .topbar-mobile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .main { padding: 20px 18px 90px; max-width: 100%; }

  .tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 30;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }

  .tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px;
    font-size: 10.5px;
    color: var(--text-faint);
    border-radius: var(--radius-sm);
  }

  .tabbar a svg { width: 19px; height: 19px; }
  .tabbar a.active { color: var(--accent); }
}

/* ---------- Utilitários ---------- */

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
