/* Mortgage Calculator Pro - Main Styles */
.mortgage-calculator-pro {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #111827;
    max-width: 1400px;
    margin: 0 auto;
    background: #f9fafb;
    padding: 20px;
    border-radius: 12px;
}

.mortgage-calculator-pro * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.calculator-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 40px;
}

@media (max-width: 1024px) {
    .calculator-container {
        grid-template-columns: 1fr;
    }
}

/* Icon Styles */
.mcp-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #4f46e5;
}

.mcp-icon svg {
    vertical-align: middle;
}

/* Input Panel */
.input-panel {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.panel-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 25px;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eef2ff;
}

.input-group {
    margin-bottom: 25px;
}

.input-label-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.input-label {
    font-weight: 500;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.input-unit {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 400;
    margin-left: 4px;
    opacity: 0.8;
}

.tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #4f46e5;
    cursor: help;
    width: 20px;
    height: 20px;
}

.tooltip .mcp-icon {
    width: 16px;
    height: 16px;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 250px;
    background-color: #111827;
    color: #ffffff;
    text-align: left;
    border-radius: 8px;
    padding: 12px;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85rem;
    font-weight: 400;
    line-height: 1.4;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.tooltip .tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #111827 transparent transparent transparent;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Input Wrapper Styles */
.input-wrapper {
    position: relative;
    margin-top: 8px;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s;
    background-color: #ffffff;
    color: #111827;
}

.input-wrapper input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    background-color: #ffffff;
}

/* Custom Select Styles - FIXED TEXT VISIBILITY */
.select-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

.select-wrapper select.styled-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: white;
    padding: 14px 48px 14px 16px !important; /* Fixed padding */
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s;
    color: #111827 !important; /* Force text color */
    cursor: pointer;
    width: 100%;
    height: 52px;
    line-height: 1.5;
    display: block;
    background-image: none !important; /* Remove default arrow */
}

/* Make text clearly visible */
.select-wrapper select.visible-text {
    color: #111827 !important;
    font-weight: 500;
    font-size: 1rem;
    background-color: white;
}

.select-wrapper.loan-term-select select {
    background-color: #f8fafc;
    border-color: #cbd5e1;
    font-weight: 600;
    color: #111827 !important;
}

.select-wrapper.date-select select {
    background-color: white;
    border-color: #cbd5e1;
    font-weight: 500;
    color: #111827 !important;
}

.select-wrapper select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    background-color: white;
}

.select-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #6b7280;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure text is visible in all browsers */
select option {
    padding: 12px !important;
    font-size: 1rem !important;
    background-color: white !important;
    color: #111827 !important;
}

select:focus option:checked {
    background-color: #4f46e5 !important;
    color: white !important;
}

/* Make sure selected text is visible */
select:valid {
    color: #111827 !important;
}

select:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 #111827;
}

/* Fix for Firefox */
select:-moz-ui-invalid {
    box-shadow: none;
}

select::-ms-expand {
    display: none;
}

.toggle-container {
    display: flex;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 10px;
    background: #f9fafb;
}

.toggle-option {
    flex: 1;
    text-align: center;
    padding: 12px;
    background-color: #ffffff;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    border: none;
    font-family: inherit;
    font-size: 0.95rem;
}

.toggle-option:hover {
    background-color: #f3f4f6;
}

.toggle-option.active {
    background-color: #4f46e5;
    color: white;
}

.checkbox-group {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.checkbox-group input {
    margin-right: 12px;
    width: 20px;
    height: 20px;
    accent-color: #4f46e5;
    cursor: pointer;
}

.checkbox-group label {
    font-weight: 500;
    color: #111827;
    cursor: pointer;
    font-size: 0.95rem;
}

.more-options {
    margin-top: 30px;
    border-top: 2px solid #e5e7eb;
    padding-top: 25px;
}

.more-options-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    margin-bottom: 20px;
    padding: 16px;
    background-color: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s;
}

.more-options-header:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
}

.more-options-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.more-options-header .chevron-icon {
    transition: transform 0.3s;
    color: #6b7280;
}

.more-options-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.more-options-content.show {
    display: block;
}

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

.calculate-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 20px;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.4);
}

.calculate-btn:active {
    transform: translateY(0);
}

/* Output Panel */
.output-panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.payment-summary {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.payment-summary h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eef2ff;
}

.monthly-payment {
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    margin-bottom: 30px;
    border: 2px solid #4f46e5;
    position: relative;
    overflow: hidden;
}

.monthly-payment::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #4f46e5 0%, #818cf8 100%);
}

.monthly-payment-label {
    font-size: 1.1rem;
    color: #6b7280;
    margin-bottom: 15px;
    font-weight: 500;
}

.monthly-payment-amount {
    font-size: 3rem;
    font-weight: 700;
    color: #4f46e5;
    letter-spacing: -1px;
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.breakdown-table th,
.breakdown-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.95rem;
}

.breakdown-table th {
    font-weight: 600;
    color: #6b7280;
    background-color: #f9fafb;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.breakdown-table tr:last-child td {
    border-bottom: none;
    font-weight: 600;
    background-color: #f9fafb;
    font-size: 1rem;
}

.breakdown-table .total-row {
    font-weight: 700;
    color: #111827;
    background-color: #f3f4f6;
}

.charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

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

.chart-card {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.chart-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.pie-chart-container,
.line-chart-container {
    height: 300px;
    position: relative;
    margin-bottom: 20px;
}

.pie-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    padding: 6px 12px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.loan-summary {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 640px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }
}

.summary-item {
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s;
}

.summary-item:hover {
    background: #f3f4f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.summary-label {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-size: 1.3rem;
    font-weight: 600;
    color: #111827;
}

/* Amortization Schedule */
.amortization-section {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    margin-top: 30px;
}

.amortization-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid #eef2ff;
}

.amortization-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.tabs {
    display: flex;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #f9fafb;
}

.tab {
    padding: 12px 24px;
    background-color: #ffffff;
    color: #6b7280;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    border: none;
    font-family: inherit;
    font-size: 0.95rem;
    white-space: nowrap;
}

.tab:hover {
    background-color: #f3f4f6;
}

.tab.active {
    background-color: #4f46e5;
    color: white;
}

.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    margin-top: 20px;
}

.amortization-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.amortization-table th,
.amortization-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.95rem;
}

.amortization-table th {
    font-weight: 600;
    color: #6b7280;
    background-color: #f9fafb;
    position: sticky;
    top: 0;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e5e7eb;
}

.amortization-table tr:hover {
    background-color: #f9fafb;
}

.amortization-table tr:last-child td {
    border-bottom: none;
}

/* Date inputs layout */
.date-inputs {
    margin-top: 10px;
}

.date-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Disclaimer */
.mcp-disclaimer {
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    font-size: 0.9rem;
    color: #6b7280;
    text-align: center;
    border-left: 4px solid #4f46e5;
}

.mcp-disclaimer p {
    margin: 0;
    line-height: 1.6;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .mortgage-calculator-pro {
        padding: 15px;
    }
    
    .input-panel,
    .payment-summary,
    .chart-card,
    .loan-summary,
    .amortization-section {
        padding: 20px;
    }
    
    .monthly-payment-amount {
        font-size: 2.2rem;
    }
    
    .amortization-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .tabs {
        align-self: flex-start;
        width: 100%;
    }
    
    .tab {
        flex: 1;
        text-align: center;
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .date-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .select-wrapper {
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    .panel-title {
        font-size: 1.2rem;
    }
    
    .input-wrapper input,
    .select-wrapper select {
        padding: 12px 14px !important;
        font-size: 0.95rem;
    }
    
    .calculate-btn {
        padding: 16px;
        font-size: 1rem;
    }
    
    .payment-summary h2,
    .amortization-header h2 {
        font-size: 1.4rem;
    }
    
    .chart-title {
        font-size: 1.1rem;
    }
}

/* Number input spinner adjustments */
input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Loading state */
.calculate-btn.loading {
    position: relative;
    color: transparent;
}

.calculate-btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Print styles */
@media print {
    .mortgage-calculator-pro {
        background: white;
        padding: 0;
    }
    
    .calculate-btn,
    .tooltip,
    .more-options-header {
        display: none !important;
    }
    
    .more-options-content {
        display: block !important;
    }
    
    .select-arrow {
        display: none !important;
    }
}

/* Additional fixes for text visibility */
.select-wrapper select option:first-child {
    color: #6b7280;
}

.select-wrapper select:required:invalid {
    color: #6b7280;
}

.select-wrapper select option {
    color: #111827;
    padding: 12px;
}

/* Force text to be visible in all states */
select,
select:focus,
select:hover,
select:active {
    color: #111827 !important;
    background-color: white !important;
}

/* Fix for dark mode compatibility */
@media (prefers-color-scheme: dark) {
    .select-wrapper select {
        color: #111827 !important;
        background-color: white !important;
    }
}