/* 401(k) Calculator Specific Styles */

/* Form Styles */
#calculatorForm {
    margin-bottom: 24px;
}

/* Section Styling */
.input-section {
    margin-bottom: 24px;
}

.input-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: #003049;
    margin-bottom: 16px;
    padding-left: 12px;
    letter-spacing: 0.3px;
    line-height: 1.2;
    display: flex;
    align-items: center;
    background: linear-gradient(to right, rgba(0, 48, 73, 0.05), transparent);
    padding: 8px 12px;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Input Groups and Error Handling */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #4b5563;
}

.input-wrapper {
    position: relative;
}

.input-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 16px;
    transition: all 0.2s ease;
    background-color: #fff;
    color: #111827;
}

.input-group input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Input hints */
.input-hint {
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
    margin-bottom: 0;
}

/* Error States */
.input-group input.error {
    border-color: #dc2626;
    background-color: #fff5f5;
    animation: errorShake 0.4s ease-in-out;
}

.input-group input.error:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.error-message {
    display: none;
    color: #dc2626;
    font-size: 14px;
    margin-top: 4px;
    padding-left: 4px;
}

.error-message.visible {
    display: block;
}

/* Return Rate Group */
.return-rate-group input {
    width: 100px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 16px;
    transition: all 0.2s ease;
}

.return-rate-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.return-rate-group input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Preset Buttons */
.preset-buttons {
    display: flex;
    gap: 8px;
}

.preset-btn {
    padding: 9px 12px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.preset-btn:hover {
    background: #e5e7eb;
}

/* Action Buttons */
.button-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.calculate-button, .reset-button {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.calculate-button {
    background: #003049;
    color: white;
    border: 1px solid #003049;
}

.calculate-button:hover {
    background: #00436b;
    border-color: #00436b;
}

.reset-button {
    background: white;
    border: 1px solid #ddd;
    color: #333;
}

.reset-button:hover {
    background: #f5f5f5;
    border-color: #003049;
}

/* Results Section */
.results-section {
    background: #f8fafc;
    border-radius: 4px;
    padding: 16px;
    margin-top: 8px;
    width: 100%;
    box-sizing: border-box;
}

.results-section.hidden {
    display: none;
}

.results-section h2 {
    color: #1e40af;
    font-size: 16px;
    margin-bottom: 16px;
}

.result-card {
    background: white;
    border-radius: 4px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.result-card.primary-result {
    border-left: 4px solid #2563eb;
}

.result-card h3 {
    font-size: 14px;
    color: #4b5563;
    margin-bottom: 4px;
}

.result-value {
    font-size: 24px;
    font-weight: 600;
    color: #1e40af;
    margin: 8px 0;
}

.result-note {
    font-size: 12px;
    color: #6b7280;
}

.result-details {
    margin-top: 20px;
}

.result-details h3 {
    font-size: 14px;
    color: #4b5563;
    margin-bottom: 12px;
}

.breakdown {
    background: white;
    border-radius: 4px;
    padding: 16px;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.breakdown-item:last-child {
    border-bottom: none;
}

.breakdown-item.highlight {
    background: rgba(37, 99, 235, 0.05);
    margin: 8px -16px -8px;
    padding: 12px 16px;
    border-radius: 0 0 4px 4px;
    border-bottom: none;
}

.breakdown-label {
    font-size: 14px;
    color: #4b5563;
}

.breakdown-value {
    font-size: 14px;
    font-weight: 500;
    color: #1e40af;
}

/* Annual Breakdown */
.annual-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.annual-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.annual-item.total {
    border-top: 1px solid #e5e7eb;
    padding-top: 12px;
    margin-top: 4px;
}

.annual-label {
    font-size: 14px;
    color: #4b5563;
}

.annual-value {
    font-size: 14px;
    font-weight: 500;
    color: #1e40af;
}

.annual-item.total .annual-label,
.annual-item.total .annual-value {
    font-weight: 600;
}

/* Year-by-Year Section */
.year-by-year-section {
    margin-top: 16px;
}

.toggle-breakdown-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-breakdown-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.toggle-breakdown-btn .chevron-icon {
    transition: transform 0.3s ease;
}

.toggle-breakdown-btn.active .chevron-icon {
    transform: rotate(180deg);
}

.year-by-year-table {
    margin-top: 12px;
    background: white;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.year-by-year-table.hidden {
    display: none;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.year-by-year-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.year-by-year-table th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    padding: 10px 8px;
    text-align: right;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.year-by-year-table th:first-child {
    text-align: center;
}

.year-by-year-table td {
    padding: 8px;
    text-align: right;
    border-bottom: 1px solid #f3f4f6;
    color: #4b5563;
}

.year-by-year-table td:first-child {
    text-align: center;
    font-weight: 500;
    color: #374151;
}

.year-by-year-table tbody tr:hover {
    background: #f9fafb;
}

.year-by-year-table tbody tr:last-child {
    background: rgba(37, 99, 235, 0.05);
    font-weight: 500;
}

.year-by-year-table tbody tr:last-child td {
    color: #1e40af;
}

/* Stack Layout */
.input-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    .input-section h2 {
        font-size: 14px;
        margin-bottom: 12px;
        padding: 6px 10px;
        padding-left: 10px;
        border-left-width: 2px;
        letter-spacing: 0.2px;
    }

    .input-section {
        margin-bottom: 20px;
    }

    .input-group label {
        font-size: 14px;
        margin-bottom: 4px;
        line-height: 1.3;
    }

    .input-group input {
        font-size: 14px;
        padding: 10px;
        -webkit-appearance: none;
        appearance: none;
        min-height: 44px;
    }

    .input-hint {
        font-size: 12px;
    }

    .error-message {
        font-size: 12px;
    }

    .return-rate-group input {
        width: 100%;
        font-size: 14px;
        min-height: 44px;
    }

    .return-rate-container {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .return-rate-group {
        margin-bottom: 16px;
    }

    .preset-buttons {
        flex-direction: column;
        width: 100%;
    }

    .preset-btn {
        width: 100%;
        text-align: center;
    }

    .year-by-year-table {
        font-size: 12px;
    }

    .year-by-year-table th,
    .year-by-year-table td {
        padding: 6px 4px;
    }
}

/* Deep Mobile Optimizations */
@media (max-width: 480px) {
    .calculator-content {
        padding: 16px;
    }

    .button-group {
        flex-direction: column;
    }

    .calculate-button, .reset-button {
        width: 100%;
        font-size: 16px;
        padding: 14px;
    }

    .result-value {
        font-size: 20px;
    }

    .error-message {
        position: relative;
        padding-top: 4px;
    }

    .input-wrapper {
        width: 100%;
    }

    .breakdown-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .breakdown-item.highlight {
        flex-direction: row;
        align-items: center;
    }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
