/* --- FUNDAÇÃO E IDENTIDADE VISUAL --- */
@import url('../../shared/base.css');

:root {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --text: #212529;
    --text-secondary: #6c757d;
    --border: #dee2e6;
    --shadow: 0 2px 8px rgba(0,0,0,0.07);

    --primary: #2563eb;
    --secondary: #003366;
    --cor-destaque: #ffc107;
    --cor-sucesso: #28a745;
    --cor-erro: #dc3545;
    --accent-light: #fff3cd;

    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --transition: 0.3s ease;
}

body.dark-theme {
    --bg: #0a1929;
    --surface: #112233;
    --text: #e9ecef;
    --text-secondary: #8696a7;
    --border: #334b61;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --primary: #3b82f6;
}

/* --- ESTILOS GERAIS E LAYOUT --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background-color var(--transition), color var(--transition);
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

/* --- HEADER --- */
.app-header {
    background: linear-gradient(145deg, #0f172a 0%, #1e3a5f 50%, #1a365d 100%);
    color: white;
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow);
    z-index: 1000;
    position: sticky;
    top: 0;
}
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1600px;
    margin: 0 auto;
}
.header-content h1 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}
.header-content p { display: none; }
.theme-switcher { display: flex; align-items: center; gap: .5rem; }
.switch { position: relative; display: inline-block; width: 50px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.25); transition: .4s; border-radius: 26px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--cor-destaque); }
input:checked + .slider:before { transform: translateX(24px); }

/* --- LAYOUT PRINCIPAL --- */
.app-main {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
    width: 100%;
}
.app-main > * { min-width: 0; }
#inputs-column, #outputs-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- CARDS E TÍTULOS --- */
.card {
    background-color: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
}
.card h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 1.5rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
body.dark-theme .card h2 { color: var(--text); }

.resultado-card { border-top: 3px solid var(--cor-sucesso); }
.resultado-card h2 { color: var(--cor-sucesso); }
body.dark-theme .resultado-card h2 { color: var(--cor-sucesso); }

/* --- FORMULÁRIOS E INPUTS --- */
.input-group { margin-bottom: 1rem; }
.input-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .4rem;
}
.input-group input[type="number"] {
    width: 100%;
    padding: .7rem .85rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg);
    color: var(--text);
    font-size: .9rem;
    font-family: var(--font);
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}
.input-group input[type="number"]:focus {
    border-color: var(--cor-destaque);
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.15);
}

/* --- ÍCONE DE AJUDA --- */
.ajuda-icone {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
    border-radius: 50%;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}
.ajuda-icone:hover, .ajuda-icone:focus {
    background: var(--primary);
    color: white;
}
.ajuda-popup {
    position: fixed;
    z-index: 9999;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow);
    max-width: 320px;
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.5;
}

/* --- BOTÕES --- */
.button-group { display: flex; gap: .75rem; margin-top: 1.25rem; }
.main-button, .secondary-button {
    padding: .85rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 1;
    font-family: var(--font);
}
.main-button { background-color: var(--primary); color: white; }
.secondary-button { background-color: transparent; color: var(--primary); border: 2px solid var(--border); }
body.dark-theme .secondary-button { color: var(--text); }
.main-button:hover { opacity: 0.9; }
.secondary-button:hover { background: var(--bg); }
body.dark-theme .secondary-button:hover { background: var(--border); }
.main-button:active, .secondary-button:active { transform: scale(.98); }

/* --- RESULTADO --- */
#resultado { font-size: 1rem; line-height: 1.8; }
#resultado strong { color: var(--primary); }
#resultado .success-message { color: var(--cor-sucesso); font-weight: 600; }
#resultado .error-message { color: var(--cor-erro); font-weight: 600; }
#resultado small { display: block; margin-top: 0.75rem; color: var(--text-secondary); font-size: 0.85rem; }

/* --- GRÁFICO E TABELA --- */
#graficoCustos {
    margin-top: 1.5rem;
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--radius-sm);
}
#tabelaCustos table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.25rem;
    font-size: 0.9rem;
}
#tabelaCustos th, #tabelaCustos td {
    padding: 0.65rem 0.5rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
}
#tabelaCustos th {
    background: var(--primary);
    color: white;
    font-weight: 600;
}
#tabelaCustos tr:nth-child(even) td { background: rgba(0,0,0,0.02); }
body.dark-theme #tabelaCustos tr:nth-child(even) td { background: rgba(255,255,255,0.03); }

/* --- HISTÓRICO --- */
#historico-list { list-style: none; padding: 0; }
#historico-list li {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    line-height: 1.6;
}
#historico-list li:last-child { border-bottom: none; }
#historico-list li b { color: var(--primary); }

/* --- SIMULAÇÃO --- */
#simulacao-container, #historico-container { margin-top: 0; }

.hidden { display: none !important; }

@keyframes fadeInCard {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.resultado-card { animation: fadeInCard 0.4s ease; }

/* --- RESPONSIVIDADE --- */
@media (min-width: 1024px) {
    .app-main {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
        padding: 1.5rem;
        max-width: 1600px;
        margin: 0 auto;
    }
    #inputs-column, #outputs-column { gap: 1.5rem; }
}
