/* ================= ESTILOS (CSS) ================= */
:root {
    --bg-body: #f1f5f9;
    --bg-panel: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --success: #10b981;
    --danger: #ef4444;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 30px 20px;
    display: flex;
    justify-content: center;
}

.calc-container {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 25px;
    max-width: 1150px;
    width: 100%;
}

@media (max-width: 900px) {
    .calc-container { grid-template-columns: 1fr; }
}

/* CABEÇALHO (Logo e Nome) */
.calc-header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between; /* <-- Isso separa a logo do texto */
    align-items: center;
    padding-bottom: 15px;
    margin-bottom: 5px;
    border-bottom: 2px solid var(--border-color);
}

.header-text {
    text-align: right;
}

.calc-header img {
    height: 45px;
    object-fit: contain;
    border-radius: 4px;
}

.calc-header h1 {
    margin: 0;
    font-size: 1.6rem;
    color: var(--text-main);
    font-weight: 800;
    letter-spacing: -0.5px;
}

.calc-header p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Painel de Parâmetros */
.calc-panel {
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 25px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    height: fit-content;
}

.panel-header { border-bottom: 1px solid var(--border-color); margin-bottom: 20px; padding-bottom: 15px; }
.panel-header h3 { margin: 0; font-size: 1rem; text-transform: uppercase; color: var(--text-main); font-weight: 700; letter-spacing: 0.5px; }

.row { display: flex; gap: 15px; }
.input-group { display: flex; flex-direction: column; margin-bottom: 18px; flex: 1; }
.input-group label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; }

.input-group input, .input-group select {
    background: #f8fafc; border: 1px solid #cbd5e1; color: var(--text-main); 
    padding: 10px 12px; border-radius: 6px; font-family: 'Segoe UI', sans-serif; font-size: 0.95rem;
    transition: all 0.2s;
}
.input-group input:focus, .input-group select:focus { outline: none; border-color: var(--primary); background: #ffffff; box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15); }
.input-group input[readonly] { background: #e2e8f0; color: var(--text-muted); cursor: not-allowed; border-color: #cbd5e1; }

.highlight-box { background: #f0f9ff; padding: 15px; border-radius: 8px; border: 1px solid #bae6fd; margin-bottom: 18px; }

.input-prefix { position: relative; display: flex; align-items: center; }
.input-prefix span { position: absolute; left: 12px; color: var(--text-muted); font-size: 0.85rem; }
.input-prefix input { padding-left: 35px; width: 100%; }

.input-suffix { display: flex; align-items: center; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 6px; padding-right: 12px; }
.input-suffix input { border: none; background: transparent; width: 60px; text-align: right; color: var(--success); font-weight: bold; }
.input-suffix span { color: var(--success); font-weight: bold; }

.flex-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.badge-red { background: #fee2e2; color: var(--danger); padding: 3px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; }

/* Botões de Material */
.material-presets { display: flex; gap: 6px; }
.btn-preset { 
    background: #f1f5f9; border: 1px solid #cbd5e1; color: var(--text-muted); 
    font-size: 0.65rem; padding: 3px 8px; border-radius: 4px; cursor: pointer; 
    font-weight: 700; transition: all 0.2s; text-transform: uppercase;
}
.btn-preset.active, .btn-preset:hover { background: #e0f2fe; border-color: var(--primary); color: var(--primary-hover); }

/* Toggle Switch (Multi-Material) */
.toggle-container { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.8rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; margin-bottom: 15px; }
.toggle-checkbox { display: none; }
.toggle-slider { width: 36px; height: 20px; background: #cbd5e1; border-radius: 10px; position: relative; transition: 0.3s; flex-shrink: 0; }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px; background: white; border-radius: 50%; top: 2px; left: 2px; transition: 0.3s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle-checkbox:checked + .toggle-slider { background: var(--primary); }
.toggle-checkbox:checked + .toggle-slider::before { transform: translateX(16px); }

/* Sliders */
input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; margin-top: 8px; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 6px; background: #e2e8f0; border-radius: 3px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 18px; width: 18px; border-radius: 50%; background: var(--primary); margin-top: -6px; cursor: pointer; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }

/* Painel de Resultados */
.calc-results { display: flex; flex-direction: column; gap: 20px; }

.result-hero { 
    background: var(--bg-panel); border-radius: 12px; border: 1px solid var(--border-color); 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); position: relative; overflow: hidden;
    display: grid; grid-template-columns: 1fr; 
}
.result-hero.has-unit { grid-template-columns: 1fr 1fr; }

.result-hero::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: linear-gradient(90deg, var(--primary), var(--success)); }

.hero-section { padding: 30px; text-align: center; }
.hero-section:first-child { border-right: 1px solid var(--border-color); }
.result-hero:not(.has-unit) .hero-section:first-child { border-right: none; }

.hero-section p { color: var(--text-muted); font-size: 0.75rem; letter-spacing: 1.5px; margin: 0 0 10px 0; font-weight: 700; text-transform: uppercase; }
.hero-section h1 { font-size: 3.2rem; margin: 0 0 20px 0; color: var(--text-main); font-weight: 800; letter-spacing: -1px; }
.hero-section.unit h1 { color: var(--primary); }

.hero-details { display: flex; justify-content: center; gap: 10px; }
.detail-box { padding: 10px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; flex: 1; }
.detail-box.profit { background: #ecfdf5; border: 1px solid #a7f3d0; }
.detail-box.profit span { color: var(--success); font-size: 0.65rem; font-weight: 700; text-transform: uppercase; }
.detail-box.profit strong { font-size: 1.1rem; color: #065f46; }
.detail-box.cost { background: #f8fafc; border: 1px solid var(--border-color); }
.detail-box.cost span { color: var(--text-muted); font-size: 0.65rem; font-weight: 700; text-transform: uppercase; }
.detail-box.cost strong { font-size: 1.1rem; color: var(--text-main); }

.result-table { background: var(--bg-panel); border-radius: 12px; padding: 20px 25px; border: 1px solid var(--border-color); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); }
.table-header { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); border-bottom: 1px solid var(--border-color); padding-bottom: 12px; margin-bottom: 10px; text-transform: uppercase; font-weight: 700; letter-spacing: 0.5px; }
.table-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 0.9rem; color: var(--text-main); }
.table-row:last-child { border-bottom: none; font-weight: bold; background: #f8fafc; margin: 0 -25px; padding: 12px 25px; border-top: 1px solid var(--border-color); }

.col-name { flex: 1; display: flex; align-items: center; gap: 8px; }
.col-total { flex: 1; text-align: right; font-family: 'Courier New', Courier, monospace; font-weight: 700; }
.col-unit { flex: 1; text-align: right; font-family: 'Courier New', Courier, monospace; color: var(--text-muted); font-size: 0.85rem; }

.result-table:not(.has-unit) .col-unit { display: none; }
.result-table:not(.has-unit) .col-name { flex: 2; }

.result-bar-chart { background: var(--bg-panel); border-radius: 12px; padding: 25px; border: 1px solid var(--border-color); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); }
.bar-item { margin-bottom: 15px; }
.bar-item:last-child { margin-bottom: 0; }
.bar-label { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 700; text-transform: uppercase; }
.bar-label span:last-child { color: var(--text-main); font-family: 'Courier New', Courier, monospace; }
.bar-track { width: 100%; height: 6px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; width: 0%; transition: width 0.5s ease; }

.fill-blue { background: #3b82f6; }
.fill-yellow { background: #f59e0b; }
.fill-fuchsia { background: #8b5cf6; }
.fill-red { background: #ef4444; }
.fill-gray { background: #94a3b8; }
.fill-green { background: #10b981; }

.hidden { display: none !important; }
/* Botão de Adicionar Material */
.btn-add-mat {
    width: 100%;
    padding: 10px;
    background: #e0f2fe;
    border: 1px dashed var(--primary);
    color: var(--primary);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 18px;
    text-transform: uppercase;
}

.btn-add-mat:hover {
    background: #bae6fd;
    border-style: solid;
}