/* Custom styles for Retirement Calculator App */

/* Card styling */
.card {
    margin-bottom: 1.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.card-title {
    color: #0d6efd;
    font-weight: 600;
}

/* Form section styling */
.form-section {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}

[data-bs-theme="dark"] .form-section {
    background-color: #1e293b;
}

/* Badge colors for funding status */
.badge.bg-insufficient {
    background-color: #dc3545 !important;
}

.badge.bg-questionable {
    background-color: #ffc107 !important;
    color: #000 !important;
}

.badge.bg-sufficient {
    background-color: #28a745 !important;
}

/* Table output styling */
.table-output {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.25rem;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.4;
    white-space: pre;
    font-family: 'Courier New', Courier, monospace;
}

[data-bs-theme="dark"] .table-output {
    background-color: #1e293b;
}

/* Pre-formatted text styling */
pre {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.25rem;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
}

[data-bs-theme="dark"] pre {
    background-color: #1e293b;
}

/* Chart container styling */
canvas {
    max-height: 400px;
}

/* Responsive table wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Summary section styling */
.summary-metric {
    padding: 0.5rem 0;
}

.summary-metric strong {
    color: #495057;
}

[data-bs-theme="dark"] .summary-metric strong {
    color: #d1d5db;
}

/* List group styling for recommendations */
.list-group-item {
    border-left: 3px solid #0d6efd;
    margin-bottom: 0.5rem;
}

/* Button styling */
.btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .card {
        margin-bottom: 1rem;
    }
    
    canvas {
        max-height: 300px;
    }
    
    .table-output {
        font-size: 0.75rem;
    }
}


/* --------------------------------------------------------------------
   Calculator input layout
   Keep the calculator form readable on ultrawide displays. Without this
   the form stretches to the full width of the Bootstrap container and
   is awkward to fill out.
   -------------------------------------------------------------------- */
.calculator-form-wrapper {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* Floating-field density tweak applied to every floating-field
   on the retirement calculator form. Earlier scoped to the three
   formsets (``.asset-form-row``, ``.income-form-row``,
   ``.event-form-row``) but the user-side sections need to match
   too — otherwise the Life Events / Other Income rows look
   visually dense while the User/Spouse/Goals sections look
   spacious. Applied via the form id so other pages using
   ``.form-floating`` aren't affected.

   Key values:
     * ``label`` font-size 0.8rem with 0.75 opacity — just legible
       but visually subordinate to the value in the field.
     * ``min-height`` + padding-top/bottom tighten the control
       vertically while leaving room for the floating label. */
#retirement-calculator-form .form-floating > label {
    font-size: 0.8rem;
    opacity: 0.75;
}

#retirement-calculator-form .form-floating > .form-control,
#retirement-calculator-form .form-floating > .form-select {
    min-height: calc(2.5rem + 2px);
    padding-top: 1.1rem;
    padding-bottom: 0.3rem;
}

/* Alternating row tint on the formsets for visual grouping. */
.asset-form-row:nth-child(even),
.income-form-row:nth-child(even),
.event-form-row:nth-child(even) {
    background-color: rgba(13, 110, 253, 0.03);
    border-radius: 0.25rem;
}

/* Compact toggle labels in the Annual Savings and Inflation Settings
   card. The six switches (traditional/roth/hsa/taxable savings-
   increase flags plus the adjust-legacy-inflation and include-
   social-security toggles) live in a tight 2-column grid; trimming
   the label size prevents them from wrapping and keeps the card
   vertically balanced against the adjacent Rate Assumptions card. */
.form-check-label[for="id_savings_increase_traditional"],
.form-check-label[for="id_savings_increase_roth"],
.form-check-label[for="id_savings_increase_hsa"],
.form-check-label[for="id_savings_increase_taxable"],
.form-check-label[for="id_adjust_legacy_inflation"],
.form-check-label[for="id_include_social_security"] {
    font-size: 0.85rem;
}

.asset-form-row,
.income-form-row,
.event-form-row {
    padding: 0.25rem 0.5rem;
}

/* Disabled look for spouse fields when "Include spouse" is off — keeps
   floating labels visible but dims the whole row so it's clear it's
   inactive. */
#id_spouse_birthdate:disabled,
#id_spouse_age:disabled,
#id_spouse_annual_income:disabled,
#id_spouse_annual_pay_increase:disabled,
#id_spouse_retirement_age:disabled,
#id_spouse_life_expectancy:disabled,
#id_spouse_ss_start_age:disabled,
#id_spouse_ss_override_monthly:disabled {
    background-color: #f1f3f5;
}


/* --------------------------------------------------------------------
   BS5 switch toggles used for BooleanField inputs. Bumping the size a
   touch so they read as toggles rather than large checkboxes.
   -------------------------------------------------------------------- */
.form-switch .form-check-input {
    width: 2.5em;
    height: 1.25em;
    margin-top: 0.2em;
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.form-switch .form-check-label {
    padding-left: 0.25em;
    cursor: pointer;
}


/* Gray italic styling for values populated by the birthdate↔age auto-sync.
   The class is toggled from calculator.html when a field is written to
   programmatically; any manual edit removes the class. */
.autofilled-value {
    color: #6c757d;
    font-style: italic;
}
.autofilled-value:focus {
    color: #212529;
    font-style: normal;
}

[data-bs-theme="dark"] .autofilled-value:focus {
    color: #f3f4f6;
}


/* --------------------------------------------------------------------
   Income breakdown donut + custom legend (see calculator.html)
   -------------------------------------------------------------------- */
.income-breakdown-wrapper {
    gap: 1rem;
}

.income-breakdown-chart {
    max-width: 60%;
    /* Match the fixed height of adjacent card-body canvas elements so
       this card doesn't grow taller than its row-mate. */
    height: 260px;
    position: relative;
}
.income-breakdown-chart canvas {
    max-height: 100%;
}

.income-breakdown-legend {
    flex-basis: 40%;
    max-height: 260px;
    overflow-y: auto;
    font-size: 0.875rem;
}

.income-breakdown-legend-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.income-legend-swatch {
    flex: 0 0 12px;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin: 4px 0.5rem 0 0;
}

.income-legend-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.income-legend-name {
    color: #212529;
    font-weight: 500;
    word-break: break-word;
}

[data-bs-theme="dark"] .income-legend-name {
    color: #f3f4f6;
}

.income-legend-meta {
    color: #6c757d;
    font-size: 0.78rem;
}

@media (max-width: 576px) {
    /* Stack the legend underneath on very narrow screens. */
    .income-breakdown-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    .income-breakdown-chart,
    .income-breakdown-legend {
        max-width: 100%;
        flex-basis: auto;
    }
    .income-breakdown-legend {
        margin-left: 0 !important;
        margin-top: 0.5rem;
    }
}


/* --------------------------------------------------------------------
   Recommendations grid (see templates/retirement_app/calculator.html)
   Each recommendation is a small card in a 2-up grid on desktop with a
   left accent bar colored by impact tier.
   -------------------------------------------------------------------- */
.recommendations-card .recommendation-card {
    border-left-width: 4px !important;
    background-color: #ffffff;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

[data-bs-theme="dark"] .recommendations-card .recommendation-card {
    background-color: #1e293b;
}

.recommendations-card .recommendation-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.075);
}

.recommendation-card.impact-high {
    border-left-color: #dc3545 !important;
}
.recommendation-card.impact-medium {
    border-left-color: #fd7e14 !important;
}
.recommendation-card.impact-low {
    border-left-color: #6c757d !important;
}

.recommendation-impact-badge.impact-high {
    background-color: #dc3545;
    color: #fff;
}
.recommendation-impact-badge.impact-medium {
    background-color: #fd7e14;
    color: #fff;
}
.recommendation-impact-badge.impact-low {
    background-color: #6c757d;
    color: #fff;
}

.recommendation-title {
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
    color: #212529;
}

[data-bs-theme="dark"] .recommendation-title {
    color: #f3f4f6;
}

.recommendation-detail {
    font-size: 0.9rem;
    color: #495057;
    line-height: 1.45;
}

[data-bs-theme="dark"] .recommendation-detail {
    color: #d1d5db;
}

.recommendation-benefit {
    font-size: 0.85rem;
    font-weight: 600;
}

.recommendation-category {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.7rem;
}


/* --------------------------------------------------------------------
   Recommendation "Apply this change" button + flash animation on the
   form fields the click modifies. Used by both the recommendation
   apply buttons and the Swap user/spouse button.
   -------------------------------------------------------------------- */
.recommendation-apply {
    white-space: nowrap;
}

.recommendation-flash {
    animation: recommendationFlash 1.4s ease-out;
}

@keyframes recommendationFlash {
    0%   { background-color: #fff3cd; box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.35); }
    100% { background-color: inherit; box-shadow: none; }
}
