:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --success: #059669;
    --error: #ef4444;
    --border: #e2e8f0;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh; /* Usa dynamic viewport unit para evitar scroll no mobile */
}

/* Wrapper principal que garante a centralização */
.main-wrapper {
    display: flex;
    width: 100%;
    justify-content: center; /* Centraliza a calculadora quando o painel some */
    align-items: flex-start;
    gap: 2rem;
    transition: all 0.3s ease;
}

/* Containers base */
.container, .config-panel {
    background: var(--card);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    width: 100%;
}

.container {
    max-width: 500px;
}

.config-panel {
    max-width: 380px;
}

.hidden {
    display: none !important;
}

/* Tipografia */
h1, h2 {
    color: var(--primary);
    text-align: center;
    margin: 0 0 1.5rem 0;
}

h1 {
    font-size: 1.5rem;
}

h2 {
    font-size: 1.1rem;
}

/* Formulários */
.input-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
}

input, select, textarea {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Botões */
.btn {
    padding: 0.8rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-secondary {
    background: #e2e8f0;
    color: #475569;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-add {
    margin: 10px 0 20px 0;
    width: 100%;
    background: #ecfdf5;
    color: var(--success);
    border: 1px dashed var(--success);
}

.btn-add:hover {
    background: var(--success);
    color: white;
}

.btn-remove {
    background: #fee2e2;
    color: var(--error);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    height: 32px;
    font-weight: bold;
    transition: 0.2s;
}

.btn-remove:hover {
    background: var(--error);
    color: white;
}

/* Engrenagem Flutuante */
.btn-config-trigger {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    font-size: 1.2rem;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.btn-config-trigger:hover {
    transform: rotate(90deg);
}

/* Resultados da Calculadora */
.result-card {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #f0fdf4;
    border-radius: 12px;
    border: 1px solid #dcfce7;
    text-align: center;
}
.instruction-msg {
     font-size: 0.85rem;
     color: var(--text-muted);
    text-align: left;
 }
.btn-config-trigger.attention-mode {
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
    background: var(--primary);
    color: white;
    border: none;
    opacity: 1;
    animation: jump-attention 3s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
}

@keyframes jump-attention {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-15px) scale(1.1);
    }
    60% {
        transform: translateY(-7px) rotate(10deg);
    }
}

/* Tooltips */
label[data-tooltip] {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    position: relative;
    cursor: default;
}

label[data-tooltip]::after {
    content: "ⓘ";
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg);
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
}

label[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    width: 180px;
    opacity: 0;
    visibility: hidden; /* Garante que não apareça sem hover */
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 999;
    text-align: center;
    font-weight: normal;
    line-height: 1.2;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: opacity 0.2s;
}

label[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
}

.filament-header, .filament-item {
    display: grid;
    grid-template-columns: 5fr 2fr 3fr 35px;
    gap: 8px;
    align-items: center;
}

.filament-header {
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--text-muted);
    padding: 0 10px;
    margin-bottom: 4px;
}

.filament-item {
    background: var(--bg);
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.filament-item input {
    padding: 6px;
    font-size: 0.85rem;
    background: #fff;
}

.filament-item input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Chips de Cores */
.color-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1.5rem;
    padding: 10px;
    background: var(--bg);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.color-chip {
    padding: 8px 16px;
    border: 2px solid var(--border);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
    user-select: none;
}

.color-chip:hover {
    border-color: var(--primary);
}

.color-chip.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}


@media (max-width: 850px) {
    .main-wrapper {
        flex-direction: column;
        align-items: center;
        padding-bottom: 60px;
    }

    .config-panel {
        order: 2;
    }

    .container {
        order: 1;
    }
}
