/* Mortgage Calculator Pro Styles - Optimized Version */

/* Reset and Base Styles */
.mortgage-calculator-container * {
    box-sizing: border-box;
}

.mortgage-calculator-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8ecef;
    line-height: 1.6;
    color: #333;
}

/* Header Section */
.mortgage-calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f2f5;
}

.mortgage-calculator-header h2 {
    color: #2c3e50;
    font-size: 28px;
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.currency-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.currency-selector label {
    font-weight: 500;
    color: #6c757d;
    font-size: 14px;
}

.currency-selector select {
    padding: 10px 14px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    min-width: 160px;
    cursor: pointer;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.currency-selector select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Form Sections */
.form-section {
    margin-bottom: 30px;
    padding: 25px;
    border: 1px solid #e8ecef;
    border-radius: 12px;
    background: #fafbfc;
    transition: border-color 0.3s ease;
}

.form-section:hover {
    border-color: #d1ecf1;
}

.form-section h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    position: relative;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-group input,
.form-group select {
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: white;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    transform: translateY(-1px);
}

.form-group input:hover,
.form-group select:hover {
    border-color: #adb5bd;
}

/* Input Error States */
.form-group input.error,
.form-group select.error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Input Toggles */
.input-toggle {
    display: flex;
    gap: 15px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.input-toggle label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin-bottom: 0;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.input-toggle label:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

.input-toggle input[type="radio"] {
    width: auto;
    margin: 0;
    accent-color: #3498db;
}

.form-group small {
    color: #6c757d;
    font-size: 12px;
    margin-top: 4px;
    font-style: italic;
}

/* Advanced Options Toggle */
.toggle-advanced {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #3498db;
    transition: color 0.3s ease;
    font-weight: 500;
}

.toggle-advanced:hover {
    color: #2980b9;
}

.toggle-icon {
    transition: transform 0.3s ease;
    font-size: 12px;
}

.toggle-icon.rotated {
    transform: rotate(-90deg);
}

.advanced-inputs-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.4s ease;
    margin-top: 15px;
}

.advanced-inputs-content.collapsed {
    max-height: 0;
    margin-top: 0;
}

/* Form Actions */
.form-actions {
    text-align: center;
    margin-top: 30px;
}

.calculate-button {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 16px 40px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 250px;
    position: relative;
    overflow: hidden;
}

.calculate-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.calculate-button:hover::before {
    left: 100%;
}

.calculate-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.3);
}

.calculate-button:active {
    transform: translateY(0);
}

.calculate-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.secondary-button {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    margin: 5px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.secondary-button:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

/* AdSense Placements */
.adsense-placement {
    margin: 30px 0;
    text-align: center;
    padding: 20px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.adsense-placement::before {
    content: 'Advertisement';
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 10px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.adsense-placement:empty::after {
    content: 'AdSense Placement Area';
    color: #adb5bd;
    font-style: italic;
}

/* Results Section */
.mortgage-calculator-results {
    margin-top: 40px;
    padding: 30px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    border: 1px solid #dee2e6;
    animation: slideInUp 0.6s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-header h3 {
    color: #2c3e50;
    font-size: 24px;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 600;
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8ecef;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3498db, #9b59b6);
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.summary-card.main-payment {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    border: none;
}

.summary-card.main-payment::before {
    background: rgba(255, 255, 255, 0.3);
}

.card-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.main-payment .card-title {
    opacity: 1;
    color: rgba(255, 255, 255, 0.9);
}

.card-value {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
    font-variant-numeric: tabular-nums;
}

.main-payment .card-value {
    color: white;
    font-size: 28px;
}

/* Chart Section */
.results-chart {
    background: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    text-align: center;
    border: 1px solid #e8ecef;
    position: relative;
}

.results-chart canvas {
    max-width: 100%;
    height: auto;
    max-height: 300px;
}

/* Payment Breakdown Alternative */
.payment-breakdown {
    display: grid;
    gap: 15px;
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e8ecef;
    transition: background-color 0.2s ease;
}

.breakdown-item:last-child {
    border-bottom: none;
}

.breakdown-item:hover {
    background-color: rgba(52, 152, 219, 0.05);
    margin: 0 -10px;
    padding-left: 10px;
    padding-right: 10px;
    border-radius: 6px;
}

.breakdown-label {
    font-weight: 500;
    color: #495057;
}

.breakdown-value {
    font-weight: 600;
    color: #2c3e50;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

/* Loan Summary */
.loan-summary {
    background: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #e8ecef;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #f0f2f5;
    transition: background-color 0.2s ease;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row:hover {
    background-color: rgba(52, 152, 219, 0.05);
    margin: 0 -15px;
    padding-left: 15px;
    padding-right: 15px;
    border-radius: 6px;
}

.summary-row .label {
    font-weight: 500;
    color: #495057;
}

.summary-row .value {
    font-weight: 600;
    color: #2c3e50;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

.additional-options {
    text-align: center;
    margin-top: 25px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Amortization Schedule */
.amortization-schedule {
    margin-top: 30px;
    background: white;
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #e8ecef;
}

.amortization-schedule h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 600;
}

.amortization-table-container {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

#amortization-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin: 0;
}

#amortization-table th {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 12px 10px;
    text-align: left;
    position: sticky;
    top: 0;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    z-index: 10;
}

#amortization-table td {
    padding: 10px;
    border-bottom: 1px solid #f0f2f5;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

#amortization-table td:first-child {
    text-align: center;
}

#amortization-table td:nth-child(2) {
    text-align: left;
}

#amortization-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

#amortization-table tbody tr:hover {
    background: #e3f2fd;
}

/* Affiliate Section */
.affiliate-section {
    margin-top: 40px;
    padding: 30px;
    background: linear-gradient(135deg, #fff8e1, #fff3c4);
    border-radius: 12px;
    border: 2px solid #ffd54f;
    position: relative;
}

.affiliate-section::before {
    content: '💰';
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    opacity: 0.7;
}

.affiliate-section h3 {
    color: #f57c00;
    font-size: 22px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
}

.lender-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.lender-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid #e8ecef;
    position: relative;
    overflow: hidden;
}

.lender-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #f57c00, #ff9800);
}

.lender-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.lender-card h4 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 600;
}

.lender-card p {
    color: #6c757d;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

.lender-card a {
    display: inline-block;
    background: linear-gradient(135deg, #f57c00, #e65100);
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lender-card a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(245, 124, 0, 0.3);
}

/* Comparison Section */
.comparison-section {
    margin-top: 30px;
    background: white;
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #e8ecef;
}

.comparison-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 600;
}

.comparison-table-container {
    overflow-x: auto;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

#comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 700px;
}

#comparison-table th {
    background: linear-gradient(135deg, #6c757d, #495057);
    color: white;
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

#comparison-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #e8ecef;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

#comparison-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

#comparison-table tbody tr:hover {
    background: #e3f2fd;
}

.remove-scenario {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.remove-scenario:hover {
    background: #c0392b;
}

/* Export Options */
.export-options {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.export-options .secondary-button {
    min-width: 120px;
}

/* Extra Payment Info */
.extra-payment-info {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border-left: 4px solid #28a745;
    padding: 20px;
    margin-top: 20px;
    border-radius: 0 8px 8px 0;
    position: relative;
}

.extra-payment-info::before {
    content: '💡';
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 20px;
}

.extra-payment-info strong {
    color: #155724;
    display: block;
    margin-bottom: 8px;
}

/* Loading States */
.mortgage-calculator-container.calculating {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.mortgage-calculator-container.calculating::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 1000;
    border-radius: 12px;
}

.mortgage-calculator-container.calculating::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border: 4px solid #3498db;
    border-top: 4px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
    z-index: 1001;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 400px;
    animation: slideInRight 0.4s ease-out;
    font-weight: 500;
}

.notification-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #3498db;
}

.notification-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.notification-error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.notification-warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
}

.notification-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    opacity: 0.8;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.notification-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalAppear 0.3s ease-out;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e8ecef;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #e9ecef;
    color: #495057;
}

.modal-body {
    padding: 25px;
}

/* Scrollbar Styling */
.amortization-table-container::-webkit-scrollbar,
.comparison-table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.amortization-table-container::-webkit-scrollbar-track,
.comparison-table-container::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.amortization-table-container::-webkit-scrollbar-thumb,
.comparison-table-container::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.amortization-table-container::-webkit-scrollbar-thumb:hover,
.comparison-table-container::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* Tooltip Styles */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

.tooltip::before {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #2c3e50;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}

.tooltip:hover::after,
.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin: 12px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    border-radius: 4px;
    transition: width 0.5s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-image: linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.2) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.2) 75%,
        transparent 75%,
        transparent
    );
    background-size: 50px 50px;
    animation: move 2s linear infinite;
}

@keyframes move {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 50px 50px;
    }
}

/* Block Editor Styles */
.mortgage-calculator-block-editor {
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    background: #f9f9f9;
    text-align: center;
}

.mortgage-calculator-preview {
    max-width: 400px;
    margin: 0 auto;
}

.wp-block-mortgage-calculator-calculator {
    margin: 20px 0;
    clear: both;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin: 8px 0;
}

.skeleton-title {
    height: 24px;
    margin: 12px 0;
    width: 60%;
}

.skeleton-button {
    height: 40px;
    margin: 16px 0;
    width: 120px;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.mb-4 { margin-bottom: 2rem !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mt-4 { margin-top: 2rem !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 0.5rem !important; }
.p-2 { padding: 1rem !important; }
.p-3 { padding: 1.5rem !important; }

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }

.hidden { display: none !important; }
.visible { display: block !important; }

.font-weight-normal { font-weight: 400 !important; }
.font-weight-medium { font-weight: 500 !important; }
.font-weight-semibold { font-weight: 600 !important; }
.font-weight-bold { font-weight: 700 !important; }

.text-muted { color: #6c757d !important; }
.text-primary { color: #3498db !important; }
.text-success { color: #28a745 !important; }
.text-danger { color: #dc3545 !important; }
.text-warning { color: #ffc107 !important; }
.text-info { color: #17a2b8 !important; }

.bg-primary { background-color: #3498db !important; }
.bg-success { background-color: #28a745 !important; }
.bg-danger { background-color: #dc3545 !important; }
.bg-warning { background-color: #ffc107 !important; }
.bg-info { background-color: #17a2b8 !important; }
.bg-light { background-color: #f8f9fa !important; }
.bg-dark { background-color: #343a40 !important; }

.border { border: 1px solid #dee2e6 !important; }
.border-0 { border: 0 !important; }
.border-top { border-top: 1px solid #dee2e6 !important; }
.border-bottom { border-bottom: 1px solid #dee2e6 !important; }
.border-left { border-left: 1px solid #dee2e6 !important; }
.border-right { border-right: 1px solid #dee2e6 !important; }

.rounded { border-radius: 0.375rem !important; }
.rounded-0 { border-radius: 0 !important; }
.rounded-circle { border-radius: 50% !important; }

.shadow-sm { box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important; }
.shadow { box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; }
.shadow-lg { box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175) !important; }

/* Responsive Design */
@media (max-width: 1200px) {
    .mortgage-calculator-container {
        max-width: 100%;
        margin: 0 10px;
    }
}

@media (max-width: 992px) {
    .mortgage-calculator-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .currency-selector {
        justify-content: center;
    }
    
    .results-summary {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .lender-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .mortgage-calculator-container {
        padding: 15px;
        margin: 5px;
        border-radius: 8px;
    }
    
    .mortgage-calculator-header h2 {
        font-size: 24px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .form-section {
        padding: 20px 15px;
    }
    
    .results-summary {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .calculate-button {
        width: 100%;
        min-width: auto;
        padding: 14px 20px;
        font-size: 16px;
    }
    
    .additional-options {
        flex-direction: column;
        gap: 10px;
    }
    
    .secondary-button {
        width: 100%;
        margin: 0;
    }
    
    .export-options {
        flex-direction: column;
        align-items: stretch;
    }
    
    .export-options .secondary-button {
        width: 100%;
        max-width: none;
    }
    
    .lender-grid {
        grid-template-columns: 1fr;
    }
    
    .summary-row {
        font-size: 14px;
        padding: 12px 0;
    }
    
    .card-value {
        font-size: 20px;
    }
    
    .main-payment .card-value {
        font-size: 24px;
    }
    
    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .modal-content {
        margin: 10px;
        max-width: none;
        width: calc(100% - 20px);
    }
    
    .breakdown-item {
        font-size: 14px;
    }
    
    .amortization-table-container,
    .comparison-table-container {
        font-size: 12px;
    }
    
    #amortization-table th,
    #amortization-table td,
    #comparison-table th,
    #comparison-table td {
        padding: 8px 4px;
    }
}

@media (max-width: 576px) {
    .mortgage-calculator-container {
        padding: 10px;
        margin: 0;
        border-radius: 0;
    }
    
    .mortgage-calculator-header h2 {
        font-size: 20px;
    }
    
    .form-section {
        padding: 15px 10px;
        margin-bottom: 20px;
    }
    
    .currency-selector select {
        width: 100%;
        min-width: auto;
    }
    
    .form-group input,
    .form-group select {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .input-toggle {
        justify-content: center;
        gap: 20px;
    }
    
    .summary-card {
        padding: 15px;
    }
    
    .affiliate-section,
    .mortgage-calculator-results {
        padding: 15px;
    }
    
    .modal-header {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .notification {
        top: 10px;
        right: 5px;
        left: 5px;
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .breakdown-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
        padding: 10px 0;
    }
    
    .breakdown-value {
        font-size: 18px;
        color: #3498db;
        font-weight: 700;
    }
    
    .extra-payment-info {
        padding: 15px;
        font-size: 14px;
    }
    
    #amortization-table,
    #comparison-table {
        font-size: 11px;
    }
    
    .results-chart {
        padding: 15px;
    }
}

/* Responsive Utilities */
@media (min-width: 576px) {
    .d-sm-none { display: none !important; }
    .d-sm-inline { display: inline !important; }
    .d-sm-inline-block { display: inline-block !important; }
    .d-sm-block { display: block !important; }
    .d-sm-flex { display: flex !important; }
    .d-sm-grid { display: grid !important; }
}

@media (min-width: 768px) {
    .d-md-none { display: none !important; }
    .d-md-inline { display: inline !important; }
    .d-md-inline-block { display: inline-block !important; }
    .d-md-block { display: block !important; }
    .d-md-flex { display: flex !important; }
    .d-md-grid { display: grid !important; }
}

@media (min-width: 992px) {
    .d-lg-none { display: none !important; }
    .d-lg-inline { display: inline !important; }
    .d-lg-inline-block { display: inline-block !important; }
    .d-lg-block { display: block !important; }
    .d-lg-flex { display: flex !important; }
    .d-lg-grid { display: grid !important; }
}

@media (min-width: 1200px) {
    .d-xl-none { display: none !important; }
    .d-xl-inline { display: inline !important; }
    .d-xl-inline-block { display: inline-block !important; }
    .d-xl-block { display: block !important; }
    .d-xl-flex { display: flex !important; }
    .d-xl-grid { display: grid !important; }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .mortgage-calculator-container {
        background: #1e2329;
        color: #e9ecef;
        border-color: #495057;
    }
    
    .form-section {
        background: #2c3e50;
        border-color: #495057;
    }
    
    .form-group input,
    .form-group select {
        background: #34495e;
        border-color: #495057;
        color: #e9ecef;
    }
    
    .form-group input:focus,
    .form-group select:focus {
        border-color: #3498db;
        background: #3c5068;
    }
    
    .summary-card {
        background: #2c3e50;
        color: #e9ecef;
        border-color: #495057;
    }
    
    .mortgage-calculator-results {
        background: linear-gradient(135deg, #2c3e50, #34495e);
        border-color: #495057;
    }
    
    .loan-summary,
    .results-chart,
    .amortization-schedule,
    .comparison-section {
        background: #2c3e50;
        border-color: #495057;
    }
    
    #amortization-table tbody tr:nth-child(even),
    #comparison-table tbody tr:nth-child(even) {
        background: #34495e;
    }
    
    #amortization-table tbody tr:hover,
    #comparison-table tbody tr:hover {
        background: #495057;
    }
    
    .lender-card {
        background: #2c3e50;
        border-color: #495057;
        color: #e9ecef;
    }
    
    .modal-content {
        background: #2c3e50;
        color: #e9ecef;
    }
    
    .modal-header {
        background: #34495e;
        border-color: #495057;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .mortgage-calculator-container {
        border: 3px solid #000;
        background: #fff;
        color: #000;
    }
    
    .form-group input,
    .form-group select {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }
    
    .calculate-button {
        background: #000;
        border: 2px solid #000;
        color: #fff;
    }
    
    .summary-card {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }
    
    .main-payment {
        background: #000 !important;
        color: #fff !important;
    }
    
    .secondary-button {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .mortgage-calculator-results {
        animation: none;
    }
    
    .notification {
        animation: none;
    }
    
    .modal-content {
        animation: none;
    }
    
    .progress-fill::after {
        animation: none;
    }
}

/* Focus Management */
.mortgage-calculator-container:focus-within {
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* Better Focus Indicators */
.mortgage-calculator-container *:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
    border-radius: 4px;
}

.mortgage-calculator-container button:focus {
    outline-offset: 4px;
}

/* Screen Reader Only */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Print Styles */
@media print {
    .mortgage-calculator-container {
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
        background: white !important;
        color: black !important;
    }
    
    .adsense-placement,
    .affiliate-section,
    .form-actions,
    .additional-options,
    .export-options,
    .notification,
    .modal-overlay {
        display: none !important;
    }
    
    .results-summary {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .amortization-schedule {
        page-break-before: always;
    }
    
    #amortization-table,
    #comparison-table {
        font-size: 10px;
    }
    
    #amortization-table th,
    #amortization-table td,
    #comparison-table th,
    #comparison-table td {
        padding: 4px 2px;
    }
    
    .summary-card {
        border: 1px solid #000;
        box-shadow: none;
        background: white !important;
        color: black !important;
    }
    
    .main-payment {
        background: #f0f0f0 !important;
        color: black !important;
    }
    
    .mortgage-calculator-results {
        background: white !important;
        border: 1px solid #000;
    }
    
    .loan-summary,
    .results-chart,
    .comparison-section {
        background: white !important;
        border: 1px solid #000;
    }
}

/* Performance Optimizations */
.mortgage-calculator-container {
    contain: layout style;
    will-change: auto;
}

.summary-card,
.lender-card {
    contain: layout;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}