/* ============================================================
   RENTA SV — Fintech Design System
   ============================================================ */

/* ── Google Fonts cargadas desde HTML ── */

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
    --page-bg:      #f4f6f9;
    --surface:      #ffffff;
    --surface-alt:  #f8fafc;
    --border:       #e5e9f0;
    --border-strong:#d0d7e2;

    --text-900:     #0d1526;
    --text-600:     #4b5a72;
    --text-400:     #8c98ac;

    --brand:        #1a56db;
    --brand-hover:  #1344b5;
    --brand-light:  #eef3fe;
    --brand-border: #c7d7fc;

    --success:      #0e7a4f;
    --success-bg:   #ecfdf5;
    --success-border:#a7f3d0;

    --danger:       #b91c1c;
    --danger-bg:    #fef2f2;
    --danger-border:#fecaca;

    --warn:         #92400e;
    --warn-bg:      #fffbeb;
    --warn-border:  #fde68a;

    --radius-sm:    6px;
    --radius-md:    10px;
    --radius-lg:    14px;

    --shadow-xs:    0 1px 2px rgba(0,0,0,.06);
    --shadow-sm:    0 2px 6px rgba(0,0,0,.07);
    --shadow-md:    0 4px 16px rgba(0,0,0,.09);
    --shadow-lg:    0 8px 32px rgba(0,0,0,.11);

    --ease:         cubic-bezier(.4,0,.2,1);
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--page-bg);
    color: var(--text-900);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Top Navigation Bar ──────────────────────────────────────── */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-xs);
}

.topbar-inner {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: var(--brand);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-icon svg { display: block; }

.brand-name {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-900);
    letter-spacing: -0.03em;
}

.brand-name span { color: var(--brand); }

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.topbar-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--brand-light);
    border: 1px solid var(--brand-border);
    color: var(--brand);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.28rem 0.75rem;
    border-radius: 999px;
}

/* ── Page Shell ──────────────────────────────────────────────── */
.page-shell {
    max-width: 1300px;
    margin: 0 auto;
    padding: 2.5rem 2rem 5rem;
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.035em;
    color: var(--text-900);
    line-height: 1.15;
    margin-bottom: 0.4rem;
}

.page-header p {
    font-size: 0.9rem;
    color: var(--text-600);
    max-width: 560px;
}

/* ── Main Layout ─────────────────────────────────────────────── */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .main-grid { grid-template-columns: 1fr; }
}

/* ── Form Column ─────────────────────────────────────────────── */
.form-col {
    display: flex;
    flex-direction: column;
    gap: 1px; /* fusionar cards con borde compartido */
}

/* ── Section Card ────────────────────────────────────────────── */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1.75rem 2rem;
    transition: border-color .18s var(--ease);
    position: relative;
}

/* Redondear solo la primera y última card del form-col */
.section-card:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.section-card:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.section-card:only-child {
    border-radius: var(--radius-lg);
}

/* El separador entre cards es el borde inferior de la anterior */
.section-card + .section-card {
    border-top: none;
}

.section-card:focus-within {
    border-color: var(--brand-border);
    z-index: 1;
}

/* Step tag + header */
.step-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--brand);
    margin-bottom: 0.5rem;
}

.step-dot {
    width: 18px;
    height: 18px;
    background: var(--brand);
    color: #fff;
    border-radius: 50%;
    font-size: 0.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-dot.opt { background: var(--text-400); }

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-900);
    letter-spacing: -0.01em;
    margin-bottom: 0.25rem;
}

.section-desc {
    font-size: 0.825rem;
    color: var(--text-600);
    line-height: 1.55;
    margin-bottom: 1.25rem;
}

/* Card top row for optional toggle cards */
.card-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 0;
}

.card-top-row > div { flex: 1; }

/* ── Two / Three column grids ────────────────────────────────── */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}
@media (max-width: 540px) { .two-col { grid-template-columns: 1fr; } }

/* ── Field Group ─────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 0.4rem; }

.field-label {
    font-size: 0.775rem;
    font-weight: 600;
    color: var(--text-600);
    letter-spacing: 0.03em;
}

.field-hint {
    font-size: 0.72rem;
    color: var(--text-400);
}

/* ── Input styles ────────────────────────────────────────────── */
.input-wrapper {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}

.input-wrapper:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.input-prefix {
    padding: 0 0.75rem;
    background: var(--surface-alt);
    border-right: 1px solid var(--border);
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-400);
    flex-shrink: 0;
}

.input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 0.6rem 0.75rem;
    font-family: inherit;
    font-size: 0.925rem;
    font-weight: 500;
    color: var(--text-900);
    width: 100%;
}

.input-wrapper input::placeholder { color: var(--text-400); }

/* Plain input (no $ prefix) */
.plain-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.925rem;
    color: var(--text-900);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}

.plain-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

select.plain-input {
    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='%238c98ac' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
    cursor: pointer;
}

/* ── Slider ──────────────────────────────────────────────────── */
.slider-input {
    width: 100%;
    accent-color: var(--brand);
    cursor: pointer;
    height: 4px;
    border-radius: 99px;
    margin-top: 0.35rem;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-400);
    margin-top: 0.25rem;
}

.accent-text { color: var(--brand); font-weight: 700; }

/* ── Toggle Switch ───────────────────────────────────────────── */
.toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.toggle input { display: none; }

.toggle-track {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--border-strong);
    border-radius: 999px;
    transition: background .2s var(--ease);
    display: block;
}

.toggle input:checked ~ .toggle-track { background: var(--brand); }

.toggle-thumb {
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: var(--shadow-xs);
    transition: transform .2s var(--ease);
    display: block;
}

.toggle input:checked ~ .toggle-track .toggle-thumb {
    transform: translateX(18px);
}

/* ── Collapsible ─────────────────────────────────────────────── */
.collapsible-content {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height .35s var(--ease), opacity .25s var(--ease);
}
.collapsible-content.open { max-height: 600px; opacity: 1; }

/* ── Payroll Summary ─────────────────────────────────────────── */
.payroll-summary {
    margin-top: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.payroll-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.payroll-row:last-child { border-bottom: none; }
.payroll-row.total {
    background: var(--surface-alt);
    font-weight: 700;
    color: var(--text-900);
}

.pr-label { color: var(--text-600); }
.pr-val   { font-variant-numeric: tabular-nums; font-weight: 600; }
.pr-val.red   { color: var(--danger); }
.pr-val.green { color: var(--success); }

/* ── Info Note ───────────────────────────────────────────────── */
.info-note {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: var(--brand-light);
    border: 1px solid var(--brand-border);
    color: #1a56db;
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    line-height: 1.5;
    margin-top: 1rem;
}
.info-note svg { flex-shrink: 0; margin-top: 1px; }

/* ── Assets Section ──────────────────────────────────────────── */
.assets-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.assets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.9rem;
    gap: 1rem;
}

.assets-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-900);
}

.assets-subtitle {
    font-size: 0.775rem;
    color: var(--text-400);
    margin-top: 0.1rem;
}

.btn-add {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--brand-border);
    color: var(--brand);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.775rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .18s var(--ease), box-shadow .18s var(--ease);
    white-space: nowrap;
}
.btn-add:hover { background: var(--brand-light); box-shadow: var(--shadow-xs); }

/* ── Asset Row ───────────────────────────────────────────────── */
.asset-row {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.625rem;
    background: var(--surface-alt);
    position: relative;
    animation: slideIn .22s var(--ease) both;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.remove-asset {
    position: absolute;
    top: 0.7rem; right: 0.7rem;
    background: transparent;
    border: none;
    color: var(--text-400);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background .15s, color .15s;
    display: flex;
    align-items: center;
    line-height: 1;
}
.remove-asset:hover { background: var(--danger-bg); color: var(--danger); }

/* ── Divider within card ─────────────────────────────────────── */
.card-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* ── Calculate Button ────────────────────────────────────────── */
.btn-calculate {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.875rem 1.5rem;
    background: var(--brand);
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(26,86,219,.25);
    transition: background .18s var(--ease), box-shadow .18s var(--ease), transform .12s var(--ease);
    letter-spacing: 0.01em;
    margin-top: 1.5rem;
}

.btn-calculate:hover {
    background: var(--brand-hover);
    box-shadow: 0 4px 16px rgba(26,86,219,.35);
    transform: translateY(-1px);
}

.btn-calculate:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(26,86,219,.2);
}

/* ── Results Panel (Sticky) ──────────────────────────────────── */
.results-col {
    position: relative;
}

.results-sticky {
    position: sticky;
    top: calc(60px + 1.5rem); /* altura del topbar + gap */
}

/* Empty state */
.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
}

.empty-icon {
    width: 52px; height: 52px;
    background: var(--brand-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.empty-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-900);
    margin-bottom: 0.3rem;
}

.empty-sub {
    font-size: 0.8rem;
    color: var(--text-400);
}

/* Results card */
.results-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    animation: revealUp .3s var(--ease) both;
}

@keyframes revealUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Results header */
.results-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-alt);
}

.results-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-900);
    letter-spacing: -0.01em;
}

.results-badge {
    background: var(--brand-light);
    border: 1px solid var(--brand-border);
    color: var(--brand);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    letter-spacing: 0.06em;
}

/* Line items */
.result-list { list-style: none; }

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    gap: 0.5rem;
}

.result-item:last-child { border-bottom: none; }

.result-item.separator {
    background: var(--surface-alt);
    font-weight: 700;
}

.ri-label { color: var(--text-600); flex: 1; }
.ri-val   {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 0.875rem;
    color: var(--text-900);
}
.ri-val.neg  { color: var(--danger); }
.ri-val.bold { font-weight: 700; color: var(--text-900); }

/* ── Verdict Box ─────────────────────────────────────────────── */
.verdict-box {
    padding: 1.5rem;
    text-align: center;
    background: var(--surface-alt);
    border-top: 1px solid var(--border);
    transition: background .25s var(--ease), border-color .25s var(--ease);
}

.verdict-box.pay {
    background: var(--danger-bg);
    border-top-color: var(--danger-border);
}

.verdict-box.refund {
    background: var(--success-bg);
    border-top-color: var(--success-border);
}

.verdict-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-400);
    margin-bottom: 0.5rem;
}

.verdict-amount {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 2.25rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
    line-height: 1.1;
    color: var(--text-900);
    margin-bottom: 0.5rem;
}

.verdict-box.pay    .verdict-amount { color: var(--danger); }
.verdict-box.refund .verdict-amount { color: var(--success); }

.verdict-msg {
    font-size: 0.78rem;
    color: var(--text-600);
    line-height: 1.5;
}

/* ── Disclaimer ──────────────────────────────────────────────── */
.disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    background: var(--warn-bg);
    border-top: 1px solid var(--warn-border);
    font-size: 0.76rem;
    color: var(--warn);
    line-height: 1.5;
}
.disclaimer svg { flex-shrink: 0; margin-top: 1px; }

/* ── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Focus Visible (accessibility) ──────────────────────── */
:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 3px;
}

/* Remove default focus ring where we have custom :focus-visible */
.input-wrapper input:focus,
.plain-input:focus,
button:focus { outline: none; }

/* ── Stale Banner ────────────────────────────────────────── */
.stale-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    border-radius: var(--radius-md);
    padding: 0.7rem 1rem;
    font-size: 0.82rem;
    color: var(--warn);
    margin-bottom: 1.25rem;
    animation: slideDown .25s var(--ease) both;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.stale-banner svg { flex-shrink: 0; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-track { background: var(--page-bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-400); }

/* ── Footer strip ────────────────────────────────────────────── */
.page-footer {
    margin-top: 4rem;
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-400);
    max-width: 1300px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Responsive: mobile stacks columns ──────────────────────── */
@media (max-width: 1024px) {
    .page-shell { padding: 1.5rem 1rem 4rem; }
    .topbar-inner { padding: 0 1rem; }
    .main-grid { grid-template-columns: 1fr; }
    .results-sticky { position: static; }
    /* On mobile show results first when panel visible */
    .results-col { order: -1; }
    .results-col:has(.hidden) { display: none; }
}

/* ── Print Styles ────────────────────────────────────────── */
@media print {
    .topbar,
    .btn-calculate,
    .btn-add,
    .remove-asset,
    .stale-banner,
    .empty-state  { display: none !important; }

    body          { background: #fff; color: #000; }
    .page-shell   { padding: 1rem; }
    .main-grid    { grid-template-columns: 1fr; }
    .results-card { box-shadow: none; border: 1px solid #ccc; }
    .results-sticky { position: static; }
    .form-col     { display: none; }
}
