/* =====================================================================
   ERP LUB3D — camada visual sobre o Tabler (design system open source)
   Identidade: mesa de impressão (grade PEI), linhas de camada e cores de filamento.
   Liquid glass: painéis translúcidos com blur sobre o fundo da "mesa".
   ===================================================================== */

:root,
[data-bs-theme="light"] {
  --p3-ink: #1c2a3a;          /* grafite */
  --p3-plate: #eef2f6;        /* mesa fria */
  --p3-teal: #0e8f9b;         /* PETG azul-petróleo — ação principal */
  --p3-gold: #b88a1c;         /* folha PEI dourada — destaque único */
  --p3-magenta: #c2367a;      /* filamento seda — alertas/realce secundário */
  --p3-grid: rgba(28, 42, 58, .06);
  --p3-glass: rgba(255, 255, 255, .62);
  --p3-glass-border: rgba(255, 255, 255, .75);
  --p3-glass-edge: rgba(28, 42, 58, .08);
  --p3-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 12px 32px -18px rgba(28, 42, 58, .35);

  --tblr-primary: var(--p3-teal);
  --tblr-primary-rgb: 14, 143, 155;
  --tblr-body-bg: var(--p3-plate);
  --tblr-body-color: var(--p3-ink);
  --tblr-font-sans-serif: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tblr-border-radius: 10px;
  color-scheme: light;
}

[data-bs-theme="dark"] {
  --p3-ink: #e6edf5;
  --p3-plate: #101c2c;
  --p3-teal: #2fc3cf;
  --p3-gold: #e2b84a;
  --p3-magenta: #ef6aa8;
  --p3-grid: rgba(230, 237, 245, .045);
  --p3-glass: rgba(24, 38, 58, .55);
  --p3-glass-border: rgba(255, 255, 255, .09);
  --p3-glass-edge: rgba(0, 0, 0, .35);
  --p3-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 16px 40px -20px rgba(0, 0, 0, .8);

  --tblr-primary: var(--p3-teal);
  --tblr-primary-rgb: 47, 195, 207;
  --tblr-body-bg: var(--p3-plate);
  --tblr-body-color: var(--p3-ink);
  --tblr-bg-surface: rgba(24, 38, 58, .55);
  color-scheme: dark;
}

/* ---------- Fundo: grade da mesa de impressão ---------- */
body {
  background-color: var(--p3-plate);
  background-image:
    radial-gradient(60rem 40rem at 110% -10%, color-mix(in srgb, var(--p3-teal) 16%, transparent), transparent 60%),
    radial-gradient(50rem 36rem at -20% 110%, color-mix(in srgb, var(--p3-magenta) 10%, transparent), transparent 60%),
    linear-gradient(var(--p3-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--p3-grid) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
  background-attachment: fixed;
  font-family: var(--tblr-font-sans-serif);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .page-title, .display-font {
  font-family: "Bricolage Grotesque", var(--tblr-font-sans-serif);
  letter-spacing: -0.02em;
}

/* ---------- Liquid glass ---------- */
.glass,
.card,
.navbar-glass,
.modal-content,
.dropdown-menu {
  background: var(--p3-glass) !important;
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--p3-glass-border) !important;
  box-shadow: var(--p3-shadow);
}
.card { border-radius: 14px; }
.card .card-header { background: transparent; border-bottom-color: var(--p3-glass-edge); }
.table { --tblr-table-bg: transparent; }
.table thead th { text-transform: none; letter-spacing: 0; font-size: .8rem; font-weight: 600; color: var(--tblr-secondary); }

@supports not (backdrop-filter: blur(1px)) {
  .glass, .card, .navbar-glass, .modal-content { background: var(--tblr-bg-surface) !important; }
}

/* ---------- Shell (sidebar + topo) ---------- */
.p3-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.p3-side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px;
  border-right: 1px solid var(--p3-glass-edge);
  background: color-mix(in srgb, var(--p3-glass) 70%, transparent);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}
.p3-brand { display: flex; align-items: center; gap: 10px; font-family: "Bricolage Grotesque"; font-weight: 700; font-size: 1.1rem; padding: 4px 8px 18px; color: inherit; text-decoration: none; }
.p3-brand img { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; }
.p3-logo { width: 30px; height: 30px; flex: none; }
.p3-nav-group { font-size: .75rem; color: var(--tblr-secondary); padding: 14px 10px 6px; }
.p3-nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  color: inherit; text-decoration: none; font-size: .92rem; opacity: .85;
}
.p3-nav a:hover { background: color-mix(in srgb, var(--p3-teal) 10%, transparent); opacity: 1; }
.p3-nav a.active { background: color-mix(in srgb, var(--p3-teal) 16%, transparent); color: var(--p3-teal); opacity: 1; font-weight: 600; }
.p3-nav a .ti { font-size: 1.15rem; }
.p3-main { min-width: 0; }
.p3-top { display: flex; align-items: center; gap: 12px; padding: 14px 28px; position: sticky; top: 0; z-index: 10; }
.p3-top .page-title { margin: 0; font-size: 1.35rem; }
.p3-content { padding: 8px 28px 48px; max-width: 1400px; }
.p3-burger { display: none; }

@media (max-width: 991px) {
  .p3-shell { grid-template-columns: 1fr; }
  .p3-side { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 1050; transform: translateX(-100%); transition: transform .2s ease; }
  .p3-side.open { transform: none; }
  .p3-burger { display: inline-flex; }
  .p3-top, .p3-content { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Componentes ---------- */
.kpi .kpi-value { font-family: "Bricolage Grotesque"; font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.kpi .kpi-label { color: var(--tblr-secondary); font-size: .85rem; }
.kpi .kpi-foot { font-size: .8rem; color: var(--tblr-secondary); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #2fb344; display: inline-block; box-shadow: 0 0 0 0 rgba(47,179,68,.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(47,179,68,0); } 100% { box-shadow: 0 0 0 0 rgba(47,179,68,0); } }

.swatch { width: 18px; height: 18px; border-radius: 50%; display: inline-block; border: 2px solid var(--p3-glass-border); box-shadow: 0 0 0 1px var(--p3-glass-edge); vertical-align: middle; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--tblr-secondary); }
.empty-state .ti { font-size: 2.4rem; display: block; margin-bottom: 8px; color: var(--p3-teal); }

/* Termômetro de preço */
.thermo { position: relative; height: 14px; border-radius: 99px; background: linear-gradient(90deg, #d63939 0%, #f59f00 22%, #2fb344 45%, #2fb344 62%, var(--p3-gold) 80%, #d63939 100%); }
.thermo-marker { position: absolute; top: -6px; width: 4px; height: 26px; border-radius: 3px; background: var(--p3-ink); transform: translateX(-50%); transition: left .25s ease; box-shadow: 0 0 0 3px var(--p3-plate); }
.thermo-labels { display: flex; justify-content: space-between; font-size: .75rem; color: var(--tblr-secondary); margin-top: 8px; }

.breakdown-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--p3-glass-edge); }
.breakdown-bar span { display: block; height: 100%; }

.filament-line { border: 1px dashed var(--p3-glass-edge); border-radius: 12px; padding: 12px; }

/* Onboarding */
.machine-pick { cursor: pointer; transition: transform .12s ease, border-color .12s ease; }
.machine-pick:hover { transform: translateY(-2px); }
.machine-pick.selected { border-color: var(--p3-teal) !important; box-shadow: 0 0 0 2px var(--p3-teal); }
.step-list { counter-reset: step; list-style: none; padding: 0; }
.step-list li { counter-increment: step; position: relative; padding: 0 0 18px 44px; }
.step-list li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: color-mix(in srgb, var(--p3-teal) 18%, transparent); color: var(--p3-teal); }

/* Banner de impersonação */
.impersonate-bar { background: var(--p3-gold); color: #1c1600; padding: 8px 16px; font-weight: 600; display: flex; gap: 12px; align-items: center; justify-content: center; }

/* Toasts */
.p3-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 2000; display: grid; gap: 8px; }
.p3-toast { padding: 12px 16px; border-radius: 12px; min-width: 260px; max-width: 380px; }
.p3-toast.error { border-left: 4px solid #d63939 !important; }
.p3-toast.success { border-left: 4px solid #2fb344 !important; }

/* Foco visível para teclado */
:focus-visible { outline: 3px solid color-mix(in srgb, var(--p3-teal) 70%, transparent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Impressão do catálogo */
@media print {
  body { background: #fff !important; }
  .no-print, .p3-side, .p3-top { display: none !important; }
  .p3-shell { display: block; }
  .card { box-shadow: none !important; backdrop-filter: none !important; background: #fff !important; border: 1px solid #ddd !important; break-inside: avoid; }
}

/* Modal nativo <dialog> */
dialog.p3-dialog { border: 0; padding: 0; background: transparent; width: min(580px, 94vw); max-height: 92vh; color: inherit; }
dialog.p3-dialog.lg { width: min(860px, 96vw); }
dialog.p3-dialog::backdrop { background: rgba(10, 18, 30, .45); backdrop-filter: blur(4px); }
dialog.p3-dialog .modal-content { border-radius: 16px; max-height: 92vh; display: flex; flex-direction: column; }
dialog.p3-dialog .modal-body { overflow-y: auto; }
dialog.p3-dialog .modal-header, dialog.p3-dialog .modal-footer { border-color: var(--p3-glass-edge); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
dialog.p3-dialog .modal-footer { justify-content: flex-end; }
