/**
 * Financial Calculators – consolidated styles.
 *
 * Layout: a CSS grid that puts the form and results side-by-side on
 * wide screens and stacks them on narrow ones. The results panel uses
 * a tabbed interface so the heavy amortization table stays out of the
 * way until the user asks for it.
 *
 * All selectors are scoped under .fincalc-widget so the plugin's styles
 * cannot leak into the rest of the WordPress theme.
 */

/* ---------- container & layout grid ---------------------------- */

.fincalc-widget {
    /*
     * Brand colors. The plugin's main class injects an inline <style>
     * block that overrides these on the front end whenever the admin
     * has set custom values; otherwise these defaults apply.
     */
    --fincalc-accent-bg:   #0066ff;
    --fincalc-accent-bg-2: #0052cc; /* Slightly darker for hero gradient + button hover. */
    --fincalc-accent-text: #ffffff;

    max-width: 960px;
    margin: 1em auto;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1rem;
    color: #222;
    box-sizing: border-box;
}

.fincalc-widget *,
.fincalc-widget *::before,
.fincalc-widget *::after {
    box-sizing: border-box;
}

.fincalc-widget .fincalc-title {
    text-align: center;
    margin: 0 0 0.75em;
}

/*
 * Two-column grid above 760px: form left (fixed-ish), results right
 * (flexible). Below 760px the grid collapses to a single column and
 * the form's stickiness is dropped.
 */
.fincalc-widget .fincalc-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    align-items: start;
}

@media (min-width: 760px) {
    .fincalc-widget .fincalc-layout {
        grid-template-columns: minmax(280px, 360px) 1fr;
    }

    /* Keep the form visible while the user scrolls long results. */
    .fincalc-widget .fincalc-form {
        position: sticky;
        top: 32px;
    }
}

/* ---------- form --------------------------------------------- */

.fincalc-widget .fincalc-form {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 16px;
}

.fincalc-widget .fincalc-label {
    display: block;
    margin-top: 10px;
    font-weight: 600;
    font-size: 0.95em;
}

.fincalc-widget .fincalc-label:first-of-type {
    margin-top: 0;
}

.fincalc-widget .fincalc-input {
    width: 100%;
    padding: 8px 10px;
    margin-top: 4px;
    font: inherit;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    color: inherit;
}

.fincalc-widget .fincalc-input:focus {
    outline: 2px solid #2271b1;
    outline-offset: 0;
    border-color: #2271b1;
}

.fincalc-widget .fincalc-inline-row {
    display: flex;
    gap: 5px;
    margin-top: 4px;
}

.fincalc-widget .fincalc-input-narrow {
    width: 30%;
    margin-top: 0;
}

.fincalc-widget .fincalc-input-wide {
    width: 70%;
    margin-top: 0;
}

.fincalc-widget .fincalc-button {
    width: 100%;
    margin-top: 16px;
    padding: 11px;
    background: var(--fincalc-accent-bg);
    color: var(--fincalc-accent-text);
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    transition: background 0.15s ease;
}

.fincalc-widget .fincalc-button:hover,
.fincalc-widget .fincalc-button:focus {
    background: var(--fincalc-accent-bg-2);
}

/* ---------- results panel ------------------------------------ */

.fincalc-widget .fincalc-results {
    min-width: 0; /* prevents overflow children from blowing out the grid */
}

/*
 * Empty state shown before the user clicks Calculate.
 */
.fincalc-widget .fincalc-results-empty {
    background: #fafafa;
    border: 1px dashed #c0c0c0;
    border-radius: 6px;
    padding: 32px 20px;
    text-align: center;
    color: #777;
    font-style: italic;
}

/*
 * Hero metric card – the single most important number, always visible
 * regardless of which tab is selected.
 */
.fincalc-widget .fincalc-hero {
    background: linear-gradient(135deg, var(--fincalc-accent-bg) 0%, var(--fincalc-accent-bg-2) 100%);
    color: var(--fincalc-accent-text);
    padding: 18px 20px;
    border-radius: 6px 6px 0 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fincalc-widget .fincalc-hero-label {
    font-size: 0.85em;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.fincalc-widget .fincalc-hero-value {
    font-size: 1.8em;
    font-weight: 700;
    line-height: 1.1;
}

/* ---------- tabs --------------------------------------------- */

.fincalc-widget .fincalc-tabs {
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 6px 6px;
    background: #fff;
    overflow: hidden;
}

.fincalc-widget .fincalc-tablist {
    display: flex;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.fincalc-widget .fincalc-tab {
    flex: 1;
    padding: 11px 14px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font: inherit;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.fincalc-widget .fincalc-tab:hover {
    background: #ececec;
    color: #222;
}

.fincalc-widget .fincalc-tab:focus {
    outline: 2px solid #2271b1;
    outline-offset: -2px;
}

.fincalc-widget .fincalc-tab[aria-selected="true"] {
    background: #fff;
    color: var(--fincalc-accent-bg);
    border-bottom-color: var(--fincalc-accent-bg);
}

.fincalc-widget .fincalc-tabpanel {
    padding: 18px;
}

.fincalc-widget .fincalc-tabpanel[hidden] {
    display: none;
}

/* ---------- summary tab content ------------------------------ */

.fincalc-widget .fincalc-summary-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.fincalc-widget .fincalc-summary-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    gap: 1em;
}

.fincalc-widget .fincalc-summary-list li:last-child {
    border-bottom: none;
}

.fincalc-widget .fincalc-summary-list .fincalc-summary-label {
    color: #555;
    font-size: 0.95em;
}

.fincalc-widget .fincalc-summary-list .fincalc-summary-value {
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

/* ---------- amortization table ------------------------------- */

.fincalc-widget .fincalc-amortization {
    overflow-x: auto;
    max-height: 480px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.fincalc-widget .fincalc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92em;
}

.fincalc-widget .fincalc-table thead tr {
    background: #f5f5f5;
}

/*
 * Sticky table header inside the scroll container so column labels
 * stay visible while scrolling 360-row schedules.
 */
.fincalc-widget .fincalc-table thead th {
    position: sticky;
    top: 0;
    background: #f5f5f5;
    z-index: 1;
}

.fincalc-widget .fincalc-table th,
.fincalc-widget .fincalc-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
}

.fincalc-widget .fincalc-table th {
    text-align: center;
    border-bottom: 2px solid #ddd;
}

.fincalc-widget .fincalc-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.fincalc-widget .fincalc-table td.fincalc-cell-period {
    text-align: center;
    color: #777;
}

.fincalc-widget .fincalc-table td.fincalc-cell-amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---------- chart -------------------------------------------- */

.fincalc-widget .fincalc-chart-container {
    position: relative;
    /*
     * Cap chart height so it never grows to fill the whole results
     * column on tall screens.
     */
    max-height: 420px;
}

/* ---------- accessibility helpers ---------------------------- */

.fincalc-widget [hidden] {
    display: none !important;
}

.fincalc-widget .fincalc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
