/* ═══════════════════════════════════════════════════════════════════════════
 * annuity-calc.css  —  CalculatorFix Annuity Calculator
 * All selectors prefixed with  #ac-  or  .ac-  to avoid conflicts.
 * Color tokens pulled from the site-wide :root (color-scheme.md).
 * ═══════════════════════════════════════════════════════════════════════════ */

/* ── Widget Card Layout ──────────────────────────────────────────────────── */

#ac-calculator-container .calc-widget-heading {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--clr-text-primary);
    margin: 0 0 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--clr-border);
}

/* ── Inputs Grid ─────────────────────────────────────────────────────────── */

.ac-inputs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
}

@media (max-width: 600px) {
    .ac-inputs-grid {
        grid-template-columns: 1fr;
    }
}

.ac-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

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

.ac-input-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--clr-text-primary);
    line-height: 1.3;
}

.ac-input-hint {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--clr-text-muted);
    background: var(--clr-bg-muted);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

.ac-input-wrap {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--clr-border);
    border-radius: 8px;
    background: var(--clr-bg);
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ac-input-wrap:focus-within {
    border-color: var(--clr-accent);
    box-shadow: var(--shadow-focus);
}

.ac-input-prefix,
.ac-input-suffix {
    padding: 0 0.6rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--clr-text-muted);
    background: var(--clr-bg-soft);
    align-self: stretch;
    display: flex;
    align-items: center;
    white-space: nowrap;
    border-right: 1px solid var(--clr-border);
    user-select: none;
}

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

.ac-calc-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    padding: 0.5rem 0.6rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--clr-text-primary);
    -moz-appearance: textfield;
}

.ac-calc-input::-webkit-inner-spin-button,
.ac-calc-input::-webkit-outer-spin-button {
    opacity: 0.4;
}

.ac-input-desc {
    font-size: 0.72rem;
    color: var(--clr-text-muted);
    line-height: 1.4;
}

/* ── Radio Group (Annuity Timing) ────────────────────────────────────────── */

.ac-radio-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.15rem;
}

.ac-radio-label {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    cursor: pointer;
    padding: 0.55rem 0.9rem;
    border: 1.5px solid var(--clr-border);
    border-radius: 8px;
    background: var(--clr-bg);
    transition: border-color 0.15s, background 0.15s;
    flex: 1;
    min-width: 160px;
}

.ac-radio-label:hover {
    border-color: var(--clr-accent);
    background: var(--clr-accent-light);
}

.ac-radio-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.ac-radio-label input[type="radio"]:checked ~ .ac-radio-custom {
    background: var(--clr-accent);
    border-color: var(--clr-accent);
}

.ac-radio-label input[type="radio"]:checked ~ .ac-radio-custom::after {
    opacity: 1;
}

.ac-radio-label:has(input[type="radio"]:checked) {
    border-color: var(--clr-accent);
    background: var(--clr-accent-light);
}

.ac-radio-custom {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border-radius: 50%;
    border: 2px solid var(--clr-border);
    background: var(--clr-bg);
    margin-top: 2px;
    position: relative;
    transition: all 0.15s;
}

.ac-radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    opacity: 0;
    transition: opacity 0.15s;
}

.ac-radio-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    line-height: 1.3;
}

.ac-radio-text strong {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--clr-text-primary);
}

.ac-radio-text small {
    font-size: 0.7rem;
    color: var(--clr-text-muted);
}

/* ── Action Buttons ──────────────────────────────────────────────────────── */

.ac-btn-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.ac-submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.ac-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--clr-text-secondary);
    background: var(--clr-bg-soft);
    border: 1.5px solid var(--clr-border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1;
}

.ac-clear-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

/* ── Results Panel ───────────────────────────────────────────────────────── */

.ac-results-panel {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px dashed var(--clr-border);
    animation: ac-fadeIn 0.3s ease;
}

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

/* ── Results Summary Cards ───────────────────────────────────────────────── */

.ac-results-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 768px) {
    .ac-results-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 420px) {
    .ac-results-grid {
        grid-template-columns: 1fr;
    }
}

.ac-result-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.875rem 1rem;
    background: var(--clr-bg-soft);
    border: 1px solid var(--clr-border);
    border-radius: 10px;
}

.ac-result-card--primary {
    background: var(--clr-accent-light);
    border-color: var(--clr-accent);
}

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

.ac-result-card--primary .ac-result-label {
    color: var(--clr-accent-dark);
}

.ac-result-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--clr-text-primary);
    line-height: 1.2;
}

.ac-result-card--primary .ac-result-value {
    font-size: 1.3rem;
    color: var(--clr-accent-dark);
}

/* ── Breakdown Bar ───────────────────────────────────────────────────────── */

.ac-breakdown {
    margin-bottom: 1.5rem;
}

.ac-breakdown-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--clr-text-secondary);
    margin-bottom: 0.5rem;
}

.ac-breakdown-bar {
    display: flex;
    height: 16px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--clr-bg-muted);
    margin-bottom: 0.5rem;
}

.ac-bar-principal {
    background: var(--clr-accent);
    transition: width 0.4s ease;
    height: 100%;
}

.ac-bar-additions {
    background: var(--clr-teal);
    transition: width 0.4s ease;
    height: 100%;
}

.ac-bar-interest {
    background: var(--clr-interest);
    transition: width 0.4s ease;
    height: 100%;
}

.ac-breakdown-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.ac-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.775rem;
    color: var(--clr-text-secondary);
}

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

.ac-legend-principal::before { background: var(--clr-accent); }
.ac-legend-additions::before  { background: var(--clr-teal); }
.ac-legend-interest::before   { background: var(--clr-interest); }

/* ── Schedule Tabs ───────────────────────────────────────────────────────── */

.ac-schedule-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.ac-schedule-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--clr-text-primary);
    margin: 0;
}

.ac-schedule-tabs {
    display: flex;
    border: 1.5px solid var(--clr-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--clr-bg-soft);
}

.ac-tab-btn {
    padding: 0.35rem 0.9rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--clr-text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}

.ac-tab-btn + .ac-tab-btn {
    border-left: 1px solid var(--clr-border);
}

.ac-tab-btn--active {
    background: var(--clr-accent);
    color: #fff;
    font-weight: 600;
}

/* ── Schedule Tables ─────────────────────────────────────────────────────── */

.ac-schedule-wrap {
    border: 1px solid var(--clr-border);
    border-radius: 10px;
    overflow: hidden;
    max-height: 360px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--clr-border) transparent;
}

.ac-schedule-wrap--hidden {
    display: none;
}

.ac-schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.ac-schedule-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.ac-schedule-table th {
    padding: 0.55rem 0.75rem;
    text-align: right;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--clr-text-secondary);
    background: var(--clr-bg-muted);
    border-bottom: 1px solid var(--clr-border);
    white-space: nowrap;
}

.ac-schedule-table th:first-child { text-align: left; }

.ac-schedule-table td {
    padding: 0.45rem 0.75rem;
    text-align: right;
    color: var(--clr-text-secondary);
    border-bottom: 1px solid var(--clr-border-soft);
}

.ac-schedule-table td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--clr-text-primary);
}

.ac-schedule-table tbody tr:last-child td {
    border-bottom: none;
}

.ac-schedule-table tbody tr:hover td {
    background: var(--clr-accent-light);
}

/* Year separator rows */
.ac-year-sep td {
    background: var(--clr-bg-muted) !important;
    font-weight: 700 !important;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--clr-text-secondary) !important;
    padding-top: 0.35rem !important;
    padding-bottom: 0.35rem !important;
}

/* ── Responsive tweaks ───────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .ac-schedule-table th,
    .ac-schedule-table td {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }

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

    .ac-result-card--primary .ac-result-value {
        font-size: 1.15rem;
    }

    .ac-btn-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ac-clear-btn {
        justify-content: center;
    }

    .ac-radio-group {
        flex-direction: column;
    }

    .ac-radio-label {
        min-width: 0;
    }
}
