/* ═══════════════════════════════════════════════════════════════════════════
 * finance-calc.css  —  Finance Calculator Widget Styles
 * Namespace prefix: fc-  (all custom rules scoped to avoid conflicts)
 * ═══════════════════════════════════════════════════════════════════════════ */

/* ── LOCAL TOKENS (mirror site color-scheme) ─────────────────────────────── */
.fc-widget {
    --fc-accent:        #0ea5e9;
    --fc-accent-dark:   #0369a1;
    --fc-accent-light:  #e0f2fe;
    --fc-accent-hover:  #bae6fd;
    --fc-interest:      #fbbf24;
    --fc-teal:          #14b8a6;
    --fc-green:         #22c55e;
    --fc-red:           #ef4444;
    --fc-warn-text:     #b45309;
    --fc-warn-bg:       #fffbeb;
    --fc-warn-brd:      #fde68a;
    --fc-bg:            #ffffff;
    --fc-bg-soft:       #f8fafc;
    --fc-bg-muted:      #f1f5f9;
    --fc-text-primary:  #0f172a;
    --fc-text-secondary:#475569;
    --fc-text-muted:    #94a3b8;
    --fc-border:        #e2e8f0;
    --fc-border-soft:   #f1f5f9;
    --fc-shadow-focus:  0 0 0 4px rgba(14, 165, 233, 0.15);
    --fc-radius:        10px;
    --fc-radius-sm:     6px;
    --fc-transition:    0.18s ease;
}

/* ── WIDGET CARD ─────────────────────────────────────────────────────────── */
.fc-widget {
    padding: 0;
    overflow: hidden;
}

/* ── TAB NAVIGATION ──────────────────────────────────────────────────────── */
.fc-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    background: var(--fc-bg-muted);
    border-bottom: 1px solid var(--fc-border);
    padding: 8px 8px 0;
    gap: 4px;
}

.fc-tab {
    flex: 1 1 auto;
    min-width: max-content;
    padding: 8px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--fc-text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--fc-radius-sm) var(--fc-radius-sm) 0 0;
    cursor: pointer;
    transition: background var(--fc-transition), color var(--fc-transition), border-color var(--fc-transition);
    white-space: nowrap;
    line-height: 1.3;
}

.fc-tab:hover {
    background: var(--fc-accent-hover);
    color: var(--fc-accent-dark);
}

.fc-tab--active,
.fc-tab[aria-selected="true"] {
    background: var(--fc-bg);
    color: var(--fc-accent-dark);
    border-color: var(--fc-border);
    border-bottom-color: var(--fc-bg);
    margin-bottom: -1px;
    position: relative;
    z-index: 1;
}

/* ── PANELS ──────────────────────────────────────────────────────────────── */
.fc-panel {
    display: none;
}

.fc-panel--active {
    display: block;
}

.fc-panel-inner {
    padding: 20px 20px 24px;
}

/* ── INPUT GRID ──────────────────────────────────────────────────────────── */
.fc-inputs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 18px;
    margin-bottom: 18px;
}

.fc-inputs-grid--3col {
    grid-template-columns: repeat(3, 1fr);
}

.fc-input-group--full {
    grid-column: 1 / -1;
}

.fc-label {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--fc-text-primary);
    margin-bottom: 5px;
    letter-spacing: 0.01em;
}

.fc-hint {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--fc-text-muted);
    margin-left: auto;
}

.fc-input-wrap {
    display: flex;
    align-items: center;
    background: var(--fc-bg-soft);
    border: 1px solid var(--fc-border);
    border-radius: var(--fc-radius-sm);
    transition: border-color var(--fc-transition), box-shadow var(--fc-transition);
    overflow: hidden;
}

.fc-input-wrap:focus-within {
    border-color: var(--fc-accent);
    box-shadow: var(--fc-shadow-focus);
    background: var(--fc-bg);
}

.fc-prefix,
.fc-suffix {
    padding: 0 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--fc-text-muted);
    background: var(--fc-bg-muted);
    align-self: stretch;
    display: flex;
    align-items: center;
    border-right: 1px solid var(--fc-border);
    flex-shrink: 0;
}

.fc-suffix {
    border-right: none;
    border-left: 1px solid var(--fc-border);
}

.fc-input {
    flex: 1;
    padding: 8px 10px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--fc-text-primary);
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    min-width: 0;
    -moz-appearance: textfield;
}

.fc-input::-webkit-outer-spin-button,
.fc-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.fc-select-wrap {
    border-radius: var(--fc-radius-sm);
}

.fc-select {
    flex: 1;
    padding: 8px 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--fc-text-primary);
    background: var(--fc-bg-soft);
    border: none;
    outline: none;
    cursor: pointer;
    width: 100%;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

/* Budget sub-label */
.fc-budget-sub {
    font-size: 0.78rem;
    color: var(--fc-text-secondary);
    margin: -6px 0 12px;
    font-style: italic;
}

/* ── BUTTON ROW ──────────────────────────────────────────────────────────── */
.fc-btn-row {
    display: flex;
    gap: 10px;
    margin-bottom: 0;
}

.fc-btn-calc {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    font-size: 0.875rem;
    font-weight: 700;
    color: #fff;
    background: var(--fc-accent);
    border: none;
    border-radius: var(--fc-radius-sm);
    cursor: pointer;
    transition: background var(--fc-transition), transform 0.1s ease, box-shadow var(--fc-transition);
    letter-spacing: 0.01em;
}

.fc-btn-calc:hover {
    background: var(--fc-accent-dark);
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.3);
}

.fc-btn-calc:active {
    transform: translateY(1px);
}

.fc-btn-clear {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--fc-text-secondary);
    background: var(--fc-bg-muted);
    border: 1px solid var(--fc-border);
    border-radius: var(--fc-radius-sm);
    cursor: pointer;
    transition: background var(--fc-transition), color var(--fc-transition);
}

.fc-btn-clear:hover {
    background: var(--fc-border);
    color: var(--fc-text-primary);
}

/* ── RESULTS SECTION ─────────────────────────────────────────────────────── */
.fc-results {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--fc-border-soft);
    animation: fc-fadeIn 0.3s ease;
}

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

.fc-results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.fc-results-grid--4col {
    grid-template-columns: repeat(4, 1fr);
}

.fc-results-grid--2col {
    grid-template-columns: repeat(2, 1fr);
}

.fc-result-card {
    background: var(--fc-bg-soft);
    border: 1px solid var(--fc-border);
    border-radius: var(--fc-radius-sm);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: box-shadow var(--fc-transition);
}

.fc-result-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.fc-result-primary {
    background: var(--fc-accent-light);
    border-color: rgba(14, 165, 233, 0.25);
    grid-column: 1 / -1;
}

.fc-result-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--fc-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.fc-result-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--fc-text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.fc-result-primary .fc-result-value {
    font-size: 1.55rem;
    color: var(--fc-accent-dark);
}

/* ── BREAKDOWN BAR ───────────────────────────────────────────────────────── */
.fc-breakdown {
    margin-bottom: 14px;
}

.fc-breakdown-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--fc-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 8px;
}

.fc-bar {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background: var(--fc-bg-muted);
    margin-bottom: 8px;
}

.fc-bar-principal {
    background: var(--fc-accent);
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 5px 0 0 5px;
}

.fc-bar-interest {
    background: var(--fc-interest);
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 0 5px 5px 0;
}

.fc-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.fc-legend-item {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--fc-text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.fc-legend-item::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.fc-legend-principal::before { background: var(--fc-accent); }
.fc-legend-interest::before  { background: var(--fc-interest); }

/* ── AMORTISATION TABLE ──────────────────────────────────────────────────── */
.fc-amort-wrap {
    margin-top: 14px;
}

.fc-amort-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--fc-accent-dark);
    background: none;
    border: 1px solid var(--fc-accent-light);
    border-radius: var(--fc-radius-sm);
    padding: 7px 12px;
    cursor: pointer;
    transition: background var(--fc-transition);
}

.fc-amort-toggle:hover {
    background: var(--fc-accent-light);
}

.fc-amort-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.fc-amort-toggle svg {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.fc-amort-table-wrap {
    margin-top: 10px;
}

.fc-amort-scroll {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--fc-border);
    border-radius: var(--fc-radius-sm);
}

.fc-amort-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.fc-amort-tbl th {
    background: var(--fc-bg-muted);
    color: var(--fc-text-secondary);
    font-weight: 700;
    text-align: right;
    padding: 7px 10px;
    border-bottom: 1px solid var(--fc-border);
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.fc-amort-tbl th:first-child { text-align: center; }

.fc-amort-tbl td {
    text-align: right;
    padding: 6px 10px;
    border-bottom: 1px solid var(--fc-border-soft);
    color: var(--fc-text-primary);
    font-weight: 500;
}

.fc-amort-tbl td:first-child {
    text-align: center;
    color: var(--fc-text-muted);
    font-weight: 600;
}

.fc-amort-tbl tr:nth-child(even) td {
    background: var(--fc-bg-soft);
}

.fc-amort-tbl tr:last-child td {
    border-bottom: none;
}

/* ── ROI INDICATOR ───────────────────────────────────────────────────────── */
.fc-roi-indicator {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: var(--fc-radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.5;
}

.fc-roi-indicator--positive {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.fc-roi-indicator--negative {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* ── BUDGET 50/30/20 ─────────────────────────────────────────────────────── */
.fc-budget-503020 {
    margin-top: 14px;
    padding: 14px;
    background: var(--fc-bg-soft);
    border: 1px solid var(--fc-border);
    border-radius: var(--fc-radius-sm);
}

.fc-503020-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.fc-503020-row {
    display: grid;
    grid-template-columns: 90px 1fr 80px;
    align-items: center;
    gap: 10px;
}

.fc-503020-label {
    font-size: 0.73rem;
    font-weight: 700;
    color: var(--fc-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.fc-503020-track {
    height: 8px;
    background: var(--fc-bg-muted);
    border-radius: 4px;
    position: relative;
    overflow: visible;
}

.fc-503020-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
    position: relative;
    max-width: 100%;
}

.fc-503020-fill--needs   { background: var(--fc-accent); }
.fc-503020-fill--wants   { background: var(--fc-teal); }
.fc-503020-fill--savings { background: var(--fc-green); }

.fc-503020-fill--over {
    background: var(--fc-red) !important;
}

.fc-503020-target-line {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    background: rgba(0,0,0,0.3);
    border-radius: 1px;
}

.fc-503020-values {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--fc-text-secondary);
    text-align: right;
    white-space: nowrap;
}

/* ── RETIREMENT STATUS ───────────────────────────────────────────────────── */
.fc-ret-status {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: var(--fc-radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.5;
}

.fc-ret-status--good {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.fc-ret-status--warn {
    background: var(--fc-warn-bg);
    border: 1px solid var(--fc-warn-brd);
    color: var(--fc-warn-text);
}

.fc-ret-status--danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* ── CURRENCY NOTE ───────────────────────────────────────────────────────── */
.fc-cur-note {
    font-size: 0.75rem;
    color: var(--fc-text-muted);
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--fc-warn-bg);
    border: 1px solid var(--fc-warn-brd);
    border-radius: var(--fc-radius-sm);
    color: var(--fc-warn-text);
}

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

/* ── Tablet (≤ 900px) ── */
@media (max-width: 900px) {
    .fc-inputs-grid--3col {
        grid-template-columns: repeat(2, 1fr);
    }

    .fc-results-grid--4col {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Mobile (≤ 640px) ── */
@media (max-width: 640px) {
    .fc-tabs {
        padding: 6px 6px 0;
        gap: 3px;
    }

    .fc-tab {
        padding: 6px 8px;
        font-size: 0.72rem;
    }

    .fc-panel-inner {
        padding: 14px 14px 18px;
    }

    .fc-inputs-grid,
    .fc-inputs-grid--3col {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .fc-results-grid,
    .fc-results-grid--4col,
    .fc-results-grid--2col {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .fc-result-primary {
        grid-column: 1 / -1;
    }

    .fc-result-value {
        font-size: 1rem;
    }

    .fc-result-primary .fc-result-value {
        font-size: 1.25rem;
    }

    .fc-btn-row {
        flex-direction: column;
    }

    .fc-btn-calc,
    .fc-btn-clear {
        width: 100%;
        justify-content: center;
    }

    .fc-503020-row {
        grid-template-columns: 65px 1fr 60px;
    }

    .fc-amort-tbl {
        font-size: 0.68rem;
    }

    .fc-amort-tbl th,
    .fc-amort-tbl td {
        padding: 5px 7px;
    }
}

/* ── Very small (≤ 380px) ── */
@media (max-width: 380px) {
    .fc-results-grid,
    .fc-results-grid--4col {
        grid-template-columns: 1fr;
    }

    .fc-tab {
        font-size: 0.65rem;
        padding: 5px 6px;
    }
}
