/* ============================================================
   Ferramentas de Impressão 3D — tema compartilhado
   Dark sóbrio (padrão) + claro, estilo documentação técnica.
   ============================================================ */

:root {
    --bg: #0e1116;
    --surface: #151a21;
    --surface-2: #1b212b;
    --surface-3: #222a36;
    --border: #2a3240;
    --border-strong: #3a4454;
    --text: #e6e9ee;
    --text-2: #9aa4b2;
    --text-3: #6b7480;
    --accent: #4f9cf9;
    --accent-strong: #2f7fe0;
    --accent-soft: rgba(79, 156, 249, 0.12);
    --cal: #f5a524;          /* categoria: calibração da impressora */
    --cal-soft: rgba(245, 165, 36, 0.12);
    --fil: #c084fc;          /* categoria: calibração do filamento */
    --fil-soft: rgba(192, 132, 252, 0.12);
    --slice: #34c9a3;        /* categoria: fatiamento */
    --slice-soft: rgba(52, 201, 163, 0.12);
    --ok: #3fb968;
    --ok-soft: rgba(63, 185, 104, 0.14);
    --warn: #e0b341;
    --warn-soft: rgba(224, 179, 65, 0.14);
    --err: #e05252;
    --err-soft: rgba(224, 82, 82, 0.14);
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

[data-theme="light"] {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --surface-3: #e7eaef;
    --border: #d9dee6;
    --border-strong: #c3cad6;
    --text: #1c2330;
    --text-2: #556173;
    --text-3: #8a94a6;
    --accent: #2f7fe0;
    --accent-strong: #1f68c2;
    --accent-soft: rgba(47, 127, 224, 0.10);
    --cal-soft: rgba(200, 130, 10, 0.12);
    --fil: #9333ea;
    --fil-soft: rgba(147, 51, 234, 0.10);
    --slice-soft: rgba(20, 150, 115, 0.12);
    --ok-soft: rgba(40, 145, 75, 0.12);
    --warn-soft: rgba(170, 130, 30, 0.14);
    --err-soft: rgba(190, 60, 60, 0.12);
    --shadow: 0 1px 3px rgba(20, 30, 50, 0.10);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px 64px;
}

/* ---------------- Shell: sidebar + topbar ---------------- */

/* transição suave entre páginas (Chrome/Edge 126+) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .14s; }

@media (min-width: 1024px) {
    body { padding-left: 240px; }
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 12px 12px;
    overflow-y: auto;
    z-index: 70;
    transform: translateX(-100%);
    transition: transform .2s ease;
}

@media (min-width: 1024px) {
    .sidebar { transform: none; }
}

.sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.5); }

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 4px 14px 8px;
}

.sidebar-head .brand { flex: 1; }

.sidebar nav { flex: 1; }

.nav-sec {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-3);
    margin: 16px 10px 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-sec .dot { width: 7px; height: 7px; border-radius: 2px; }

.nav-link {
    display: block;
    padding: 7px 10px;
    margin: 1px 0;
    border-radius: 8px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.35;
}

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

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 650;
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-link .en { color: var(--text-3); font-weight: 400; font-size: 12px; }
.nav-link.active .en { color: color-mix(in srgb, var(--accent) 65%, transparent); }

.field-label strong { font-weight: 700; color: var(--text); }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 65;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
}

/* em telas largas a sidebar é fixa: esconde topbar e backdrop */
@media (min-width: 1024px) {
    .topbar { display: none; }
    .sidebar-backdrop { display: none; }
}

.topbar .spacer { flex: 1; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
}

.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 15px;
}

.brand svg { color: var(--accent); flex-shrink: 0; }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    transition: color .15s, border-color .15s;
}

.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ---------------- Tipografia / hero ---------------- */

.hero {
    padding: 44px 0 8px;
}

.hero h1 {
    font-size: 30px;
    line-height: 1.2;
    margin: 0 0 10px;
    letter-spacing: -0.02em;
}

.hero p {
    color: var(--text-2);
    max-width: 640px;
    margin: 0;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 40px 0 6px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-2);
}

.section-title .dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.section-title.cat-cal .dot { background: var(--cal); }
.section-title.cat-fil .dot { background: var(--fil); }
.section-title.cat-slice .dot { background: var(--slice); }
.section-title.cat-gen .dot { background: var(--accent); }

.section-desc {
    color: var(--text-3);
    font-size: 13px;
    margin: 0 0 16px;
}

/* ---------------- Cards (index) ---------------- */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 12px;
}

.tool-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text);
    transition: border-color .15s, transform .15s, box-shadow .15s;
    box-shadow: var(--shadow);
}

.tool-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.tool-card .icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-card.cat-cal .icon { background: var(--cal-soft); color: var(--cal); }
.tool-card.cat-fil .icon { background: var(--fil-soft); color: var(--fil); }
.tool-card.cat-slice .icon { background: var(--slice-soft); color: var(--slice); }
.tool-card.cat-gen .icon { background: var(--accent-soft); color: var(--accent); }

.tool-card h3 {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 650;
}

.tool-card p {
    margin: 0;
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.45;
}

/* ---------------- Painéis genéricos ---------------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.panel h2 {
    margin: 0 0 12px;
    font-size: 18px;
    letter-spacing: -0.01em;
}

.panel h3 {
    margin: 18px 0 8px;
    font-size: 15px;
}

.muted { color: var(--text-2); }
.small { font-size: 13px; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 20px 0 4px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 13px;
}

.back-link:hover { color: var(--text); }

.page-title {
    margin: 10px 0 4px;
    font-size: 26px;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-2);
    margin: 0 0 24px;
}

/* ---------------- Alertas ---------------- */

.alert {
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 14px;
    margin: 12px 0;
    border: 1px solid transparent;
}

.alert.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.alert.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.alert.err { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 40%, transparent); }

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

label.field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 6px;
}

.input {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    transition: border-color .15s;
}

.input:focus {
    outline: none;
    border-color: var(--accent);
}

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

input[type="range"].slider {
    width: 100%;
    accent-color: var(--accent);
}

.field-row {
    display: grid;
    gap: 14px;
}

@media (min-width: 640px) {
    .field-row.cols-2 { grid-template-columns: 1fr 1fr; }
    .field-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}

.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }

.btn.primary {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: #fff;
}

.btn.primary:hover { background: var(--accent); border-color: var(--accent); }

.btn.small { padding: 5px 10px; font-size: 13px; }

/* Grupo de opções (segmented) */

.seg-group {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.seg-group .seg {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}

.seg-group .seg:hover { color: var(--text); }

.seg-group .seg.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

/* ---------------- Abas ---------------- */

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.tabs .tab {
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
}

.tabs .tab:hover { color: var(--text); }

.tabs .tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

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

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

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.data th {
    text-align: left;
    padding: 8px 10px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

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

table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

td.status-ok { color: var(--ok); font-weight: 600; }
td.status-warn { color: var(--warn); font-weight: 600; }
td.status-err { color: var(--err); font-weight: 600; }

/* ---------------- KPI / resultados ---------------- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.kpi {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.kpi .label {
    font-size: 12px;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.kpi .value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.kpi .hint { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.kpi.highlight { border-color: var(--accent); background: var(--accent-soft); }
.kpi.highlight .value { color: var(--accent); }

/* ---------------- Código / valores ---------------- */

code, .code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--surface-3);
    border-radius: 6px;
    padding: 2px 6px;
}

pre.code-block {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    overflow-x: auto;
    line-height: 1.6;
}

/* ---------------- Accordion ---------------- */

details.accordion {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

details.accordion > summary {
    padding: 14px 20px;
    cursor: pointer;
    font-weight: 650;
    font-size: 15px;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-2);
}

details.accordion > summary::-webkit-details-marker { display: none; }

details.accordion > summary::before {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform .15s;
    flex-shrink: 0;
}

details.accordion[open] > summary::before { transform: rotate(45deg); }
details.accordion[open] > summary { color: var(--text); }

details.accordion > .accordion-body {
    padding: 0 20px 20px;
}

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

.tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-2);
}

.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.err { background: var(--err-soft); color: var(--err); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------------- Modal (imagem de referência) ---------------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 20px;
}

.modal-backdrop img {
    max-width: min(92vw, 900px);
    max-height: 88vh;
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

/* ---------------- Passos numerados ---------------- */

.steps {
    counter-reset: step;
    margin: 0;
    padding: 0;
    list-style: none;
}

.steps li {
    counter-increment: step;
    position: relative;
    padding: 0 0 14px 40px;
}

.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: -1px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------------- Footer ---------------- */

.site-footer {
    margin-top: 48px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--text-3);
    font-size: 13px;
    text-align: center;
}

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

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
