/* ═══════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════ */

:root {
    --bg-page: #0d1117;
    --bg-card: #161b22;
    --bg-card-hover: #1c2129;
    --bg-input: #0d1117;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-blue: #58a6ff;
    --accent-teal: #5eead4;
    --accent-purple: #bc8cff;
    --accent-yellow: #d29922;
    --font-sans: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,.3);
}

[data-theme="light"] {
    --bg-page: #f6f8fa; --bg-card: #ffffff; --bg-card-hover: #f3f4f6;
    --bg-input: #f6f8fa; --border: #d0d7de;
    --text-primary: #1f2328; --text-secondary: #656d76; --text-muted: #8b949e;
    --accent-green: #1a7f37; --accent-red: #cf222e;
    --accent-blue: #0969da; --accent-teal: #0d9488; --accent-purple: #8250df; --accent-yellow: #9a6700;
    --shadow: 0 2px 8px rgba(0,0,0,.08);
}

/* ═══════════════════════════════════════
   BASE
   ═══════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-sans); background: var(--bg-page);
    color: var(--text-primary); line-height: 1.6; min-height: 100vh;
}

/* ═══════════════════════════════════════
   HEADER
   ═══════════════════════════════════════ */

.header {
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    background: var(--bg-page);
}
.header-inner {
    max-width: 1200px; margin: 0 auto; padding: 14px 24px;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo { font-family: var(--font-mono); font-size: 1.1rem; font-weight: 700; }
.header-logo span { color: var(--accent-teal); }

.header-badge {
    font-size: .65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; background: var(--accent-teal); color: var(--bg-page);
    padding: 2px 8px; border-radius: 4px;
}

.header-right { display: flex; align-items: center; gap: 12px; }
.header-timestamp { font-size: .78rem; color: var(--text-muted); }

.theme-toggle {
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-primary); width: 34px; height: 34px;
    border-radius: var(--radius-sm); cursor: pointer; font-size: 1rem;
    display: flex; align-items: center; justify-content: center; transition: background .2s;
}
.theme-toggle:hover { background: var(--bg-card-hover); }

/* ═══════════════════════════════════════
   MAIN
   ═══════════════════════════════════════ */

.main { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ═══════════════════════════════════════
   INTRO — estado inicial (hero centralizado)
   ═══════════════════════════════════════ */

.intro {
    margin-bottom: 32px; padding-top: 16px;
    transition: all .5s ease;
}
.intro h1 {
    font-size: 1.8rem; font-weight: 800; margin-bottom: 8px;
    display: flex; align-items: center; gap: 10px;
}
.intro h1::before {
    content: ''; width: 4px; height: 28px;
    background: var(--accent-teal); border-radius: 2px; flex-shrink: 0;
}
.intro p { font-size: .9rem; color: var(--text-secondary); }

/* Após calcular */
.calculated .intro { margin-bottom: 20px; padding-top: 0; }
.calculated .intro h1 { font-size: 1.2rem; }
.calculated .intro h1::before { height: 20px; }
.calculated .intro p { font-size: .82rem; }

/* ═══════════════════════════════════════
   LAYOUT — dois estados
   ═══════════════════════════════════════ */

/* Estado 1: form full-width hero */
.layout {
    display: flex; flex-direction: column;
    gap: 20px; transition: all .5s ease;
}

.result-area { width: 100%; display: none; }

/* Estado 2: form sidebar + dashboard */
.calculated .layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    align-items: start;
    gap: 20px;
}
.calculated .result-area { display: block; }

/* ═══════════════════════════════════════
   CARD
   ═══════════════════════════════════════ */

.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
}

.card-title {
    font-size: .88rem; font-weight: 600; margin-bottom: 16px;
    display: flex; align-items: center; gap: 6px;
}

/* ═══════════════════════════════════════
   FORM — dois estados
   ═══════════════════════════════════════ */

/* Form hero: sem borda, sem fundo, full-width */
.form-card {
    width: 100%;
    transition: all .5s ease, opacity .4s ease;
    background: none; border: none; padding: 0;
}

/* Após calcular: sidebar compacta COM card styling */
.calculated .form-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    opacity: .85; position: sticky; top: 72px; z-index: 10;
}
.calculated .form-card:hover { opacity: 1; }

.form-card > .card-title { display: none; } /* oculto no hero */
.calculated .form-card > .card-title { display: flex; font-size: .78rem; margin-bottom: 10px; }
.calculated .form-card .field { margin-bottom: 8px; }
.calculated .form-card .field label { font-size: .58rem; }
.calculated .form-card .field input,
.calculated .form-card .field select { font-size: .8rem; padding: 7px 10px; }
.calculated .form-card .btn-calcular { padding: 9px; font-size: .8rem; }

.field { margin-bottom: 14px; }

.field label {
    display: block; font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-muted); margin-bottom: 4px;
}

.field input, .field select {
    width: 100%; appearance: none; -webkit-appearance: none;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-primary); font-family: var(--font-sans);
    font-size: .88rem; font-weight: 500; padding: 11px 14px;
    border-radius: var(--radius-sm); transition: all .15s;
}

.field input:focus, .field select:focus {
    outline: none; border-color: var(--accent-teal);
    box-shadow: 0 0 0 2px rgba(94,234,212,.15);
}

.field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
    padding-right: 32px;
}

/* Form fields: grid responsivo no hero */
.form-fields {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 16px;
}
.form-fields .field-full { grid-column: 1 / -1; }
.form-fields .field { margin-bottom: 0; }

.calculated .form-fields { grid-template-columns: 1fr 1fr; gap: 8px 12px; }

/* Toggle group (férias vencidas) */
.toggle-group {
    display: flex; gap: 0; border-radius: var(--radius-sm); overflow: hidden;
    border: 1px solid var(--border);
}
.toggle-btn {
    flex: 1; padding: 9px 8px; border: none;
    background: var(--bg-card); color: var(--text-muted);
    font-family: var(--font-sans); font-size: .78rem; font-weight: 600;
    cursor: pointer; transition: all .15s;
    border-right: 1px solid var(--border);
}
.toggle-btn:last-child { border-right: none; }
.toggle-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.toggle-btn.active { background: var(--accent-teal); color: var(--bg-page); }
.calculated .toggle-btn { padding: 6px 4px; font-size: .7rem; }

.btn-calcular {
    width: 100%; padding: 14px; margin-top: 4px;
    background: var(--accent-teal); color: var(--bg-page);
    border: none; border-radius: var(--radius-sm);
    font-family: var(--font-sans); font-size: .92rem; font-weight: 700;
    cursor: pointer; transition: all .2s; letter-spacing: .02em;
}
.btn-calcular:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(94,234,212,.25); }
.btn-calcular:active { transform: translateY(0); }


/* ═══════════════════════════════════════
   RESULTADO — dashboard grid
   ═══════════════════════════════════════ */

.result-area { min-height: 0; }

.result-placeholder {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-height: 300px; color: var(--text-muted);
    text-align: center; gap: 12px;
}
.result-icon {
    font-family: var(--font-mono); font-size: 3rem; font-weight: 800;
    color: var(--border); line-height: 1;
}
.result-placeholder p { font-size: .88rem; }

.result-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.result-tipo {
    font-size: .65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; padding: 3px 10px; border-radius: 4px;
    background: rgba(94,234,212,.1); color: var(--accent-teal);
}
.result-periodo { font-size: .78rem; color: var(--text-muted); }

.result-total-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-left: 4px solid var(--accent-teal); border-radius: var(--radius);
    padding: 20px; margin-bottom: 16px; text-align: left;
}
.result-total-label {
    font-size: .68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-muted); margin-bottom: 4px;
}
.result-total-value {
    font-family: var(--font-mono); font-size: 2rem; font-weight: 800;
    color: var(--accent-green);
}

/* Dashboard grid: verbas e descontos lado a lado */
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }

.verbas-section {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.verbas-title {
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-muted); margin-bottom: 10px;
}

.verba-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid rgba(48,54,61,.4); gap: 12px;
}
.verba-row:last-child { border-bottom: none; }
[data-theme="light"] .verba-row { border-bottom-color: rgba(208,215,222,.5); }

.verba-label { font-size: .82rem; color: var(--text-secondary); flex: 1; }
.verba-detail { font-size: .68rem; color: var(--text-muted); }
.verba-valor {
    font-family: var(--font-mono); font-size: .82rem; font-weight: 600;
    white-space: nowrap;
}
.verba-valor.positivo { color: var(--accent-green); }
.verba-valor.negativo { color: var(--accent-red); }
.verba-valor.neutro { color: var(--text-primary); }

.verba-row.total {
    border-top: 2px solid var(--border); border-bottom: none;
    padding-top: 12px; margin-top: 4px;
}
.verba-row.total .verba-label { font-weight: 700; color: var(--text-primary); }
.verba-row.total .verba-valor { font-size: .92rem; font-weight: 800; }

/* Info boxes */
.info-row { display: flex; gap: 12px; margin-bottom: 12px; }
.info-box-sm {
    flex: 1; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px; text-align: left;
}
.info-box-label {
    font-size: .6rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-muted); margin-bottom: 2px;
}
.info-box-value { font-family: var(--font-mono); font-size: 1rem; font-weight: 700; }

/* ═══════════════════════════════════════
   LEGAL NOTE
   ═══════════════════════════════════════ */

.result-meta {
    font-size: .7rem; color: var(--text-muted); padding: 8px 0; line-height: 1.5;
}

.btn-imprimir {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 20px; margin-top: 8px;
    background: none; border: 1px solid var(--border); color: var(--text-secondary);
    border-radius: var(--radius-sm); font-family: var(--font-sans);
    font-size: .78rem; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-imprimir:hover { border-color: var(--accent-teal); color: var(--text-primary); }

.proj-disclaimer {
    margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
    font-size: .72rem; color: var(--text-muted); line-height: 1.5;
}
.proj-disclaimer strong { color: var(--text-secondary); }

.legal-note {
    margin-top: 16px; padding: 8px 0;
    background: none; border: none;
    font-size: .68rem; color: var(--text-muted); line-height: 1.5;
}
.legal-note strong { color: var(--text-muted); font-weight: 600; }

/* ═══════════════════════════════════════
   GRÁFICO DE PROJEÇÃO
   ═══════════════════════════════════════ */

.proj-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; margin-top: 20px;
}
.proj-title {
    font-size: .88rem; font-weight: 600; margin-bottom: 4px;
    display: flex; align-items: center; gap: 6px;
}
.proj-subtitle { font-size: .75rem; color: var(--text-muted); margin-bottom: 16px; }
.proj-chart { position: relative; height: 300px; }

.proj-fgts-inline {
    font-size: .82rem; color: var(--text-secondary); margin-bottom: 14px;
    padding: 10px 14px; background: rgba(88,166,255,.06); border: 1px solid rgba(88,166,255,.12);
    border-radius: var(--radius-sm); display: inline-block;
}
.proj-fgts-inline .proj-fgts-label {
    font-size: .68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-muted);
}
.proj-fgts-inline strong {
    font-family: var(--font-mono); color: var(--accent-blue);
}
.proj-fgts-inline .proj-fgts-detail { font-size: .75rem; color: var(--text-muted); }

/* ═══════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════ */

.footer { border-top: 1px solid var(--border); }
.footer-inner {
    max-width: 1200px; margin: 0 auto; padding: 18px 24px;
    text-align: left; font-size: .75rem; color: var(--text-muted); line-height: 1.8;
}
.footer a { color: var(--accent-teal); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════
   ANIMAÇÃO DE ENTRADA
   ═══════════════════════════════════════ */

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.result-area { animation: fadeSlideUp .5s ease forwards; }

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */

@media (max-width: 768px) {
    .main { padding: 16px; }
    .header-inner, .footer-inner { padding: 12px 16px; }
    .intro h1 { font-size: 1.3rem; }
    .form-fields { grid-template-columns: 1fr 1fr; }

    .calculated .layout {
        grid-template-columns: 1fr;
    }
    .calculated .form-card {
        position: relative; top: 0; opacity: 1;
    }
    .result-total-value { font-size: 1.6rem; }
    .info-row { flex-direction: column; }
    .result-grid { grid-template-columns: 1fr; }
    .proj-chart { height: 240px; }
}

/* ═══════════════════════════════════════
   PRINT
   ═══════════════════════════════════════ */

@media print {
    @page { size: A4 portrait; margin: 10mm 12mm; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    body { background: #fff !important; color: #1f2328 !important; font-size: 8pt !important; line-height: 1.35 !important; }

    /* Ocultar UI */
    .header, .form-card, .btn-imprimir, .btn-calcular, .legal-note, .footer,
    .proj-fgts-inline, .proj-disclaimer, .intro { display: none !important; }

    #app { display: block; }
    .main { max-width: none !important; padding: 0 !important; margin: 0 !important; }
    .calculated .layout { display: block !important; }
    .result-area { display: block !important; }

    /* Título */
    .result-area::before {
        content: 'Simulacao de Rescisao CLT — 2026';
        display: block; font-size: 18pt; font-weight: 800; color: #1f2328;
        margin-bottom: 4px;
    }

    /* Header resultado */
    .result-header { margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid #0d9488; }
    .result-tipo { font-size: 7pt; padding: 2px 8px; background: #e0f2f1 !important; color: #0d9488 !important; }
    .result-periodo { font-size: 8pt; }

    /* Info boxes */
    .info-row { display: flex !important; flex-direction: row !important; gap: 10px; margin-bottom: 16px; }
    .info-box-sm { flex: 1; padding: 10px 12px; border: 1px solid #d0d7de; border-radius: 6px; }
    .info-box-label { font-size: 6pt; }
    .info-box-value { font-size: 10pt; }

    /* Total principal */
    .result-total-card { padding: 16px 18px; margin-bottom: 16px; border-left: 4px solid #0d9488 !important; border-color: #d0d7de; width: 100%; }
    .result-total-label { font-size: 7pt; margin-bottom: 2px; color: #656d76; }
    .result-total-value { font-size: 22pt !important; color: #1a7f37 !important; }

    /* Verbas e descontos */
    .result-grid { display: grid !important; grid-template-columns: 3fr 2fr !important; gap: 10px; margin-bottom: 12px; }
    .verbas-section { padding: 10px 12px; margin-bottom: 0; border: 1px solid #d0d7de; border-radius: 6px; }
    .verbas-title { font-size: 6.5pt; margin-bottom: 5px; color: #656d76; }
    .verba-row { padding: 3.5px 0; gap: 8px; border-bottom: 1px solid #f0f0f0; }
    .verba-label { font-size: 7.5pt !important; color: #1f2328; }
    .verba-detail { font-size: 5.5pt; color: #8b949e; }
    .verba-valor { font-size: 7.5pt !important; }
    .verba-valor.positivo { color: #1a7f37 !important; }
    .verba-valor.negativo { color: #cf222e !important; }
    .verba-valor.neutro { color: #1f2328 !important; }
    .verba-row.total { padding-top: 5px; margin-top: 2px; border-top: 1.5px solid #bbb; }
    .verba-row.total .verba-label { font-size: 8pt !important; }
    .verba-row.total .verba-valor { font-size: 8.5pt !important; }

    /* Gráfico */
    .proj-card {
        display: block !important; padding: 12px 14px; margin-top: 14px;
        border: 1px solid #d0d7de; border-radius: 6px;
        page-break-inside: avoid; width: 100%;
    }
    .proj-title { font-size: 8pt; font-weight: 700; margin-bottom: 6px; color: #1f2328; }
    .proj-subtitle { display: none !important; }
    .proj-chart { height: 190px !important; width: 100% !important; overflow: visible !important; }
    .proj-chart canvas { height: 190px !important; width: 100% !important; }

    /* Memória de cálculo */
    .result-meta { display: block !important; font-size: 6pt; color: #8b949e; padding: 6px 0 0; margin-top: 8px; border-top: 1px solid #eee; }
}

@media (max-width: 480px) {
    .intro h1 { font-size: 1.1rem; }
    .intro p { font-size: .82rem; }
    .form-fields { grid-template-columns: 1fr; }
    .field label { font-size: .62rem; }
    .verba-label { font-size: .78rem; }
    .verba-valor { font-size: .78rem; }
}
