/* Mortgage Calculator Specific Styles */

/* Layout Fixes */
.calculator-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
}

.content-grid {
    display: flex;
    gap: 30px;
    position: relative;
    align-items: flex-start;
}

.calculator-section {
    flex: 1;
    min-width: 0;
    position: relative;
}

.sidebar {
    width: 300px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
}

/* Ensure proper stacking order */
.calculator-page main {
    position: relative;
    z-index: 1;
}

.mortgage-calculator-page {
    background-color: #f5f5f5;
    min-height: 100vh;
    padding: 20px 0;
    overflow-x: hidden;
}

/* Calculator Card */
.calculator-card {
    background: white;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.calculator-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #e8f4f8;
    border-radius: 4px;
}

.info-icon {
    font-size: 20px;
    color: #4472c4;
}

.calculator-header p {
    margin: 0;
    color: #333;
    font-size: 14px;
}

/* Form Styles */
.calculator-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.form-row label {
    flex: 0 0 140px;
    font-size: 14px;
    color: #333;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.info-tooltip {
    font-size: 12px;
    color: #4472c4;
    cursor: help;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
}

.form-input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.form-input:focus {
    border-color: #4472c4;
}

.form-input.small {
    width: 100px;
}

.year-input {
    width: 80px;
}

.currency-symbol,
.percentage-symbol,
.unit-text {
    font-size: 14px;
    color: #666;
}

.small-select,
.month-select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.month-select {
    width: 80px;
}

.percentage-group {
    max-width: 200px;
}

/* Taxes & Costs Section */
.taxes-costs-section {
    margin-top: 20px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 15px;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.taxes-costs-details {
    margin-top: 15px;
}

.section-subtitle {
    font-size: 13px;
    color: #666;
    margin-bottom: 15px;
    font-style: italic;
}

.more-options-link {
    text-align: right;
    margin-top: 10px;
}

.more-options-link a {
    color: #4472c4;
    text-decoration: none;
    font-size: 14px;
}

.more-options-link a:hover {
    text-decoration: underline;
}

/* Additional Options Section */
.additional-options-section {
    margin-top: 15px;
    padding: 15px;
    background-color: #f0f6fc;
    border-radius: 4px;
    border: 1px solid #d4e3f4;
}

.additional-options-section .form-row {
    margin-bottom: 10px;
}

.additional-options-section .form-row:last-child {
    margin-bottom: 0;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.calculate-btn {
    background-color: #5cb85c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.3s;
}

.calculate-btn:hover {
    background-color: #4cae4c;
}

.btn-icon {
    font-size: 12px;
}

.clear-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.clear-btn:hover {
    background-color: #5a6268;
}

/* Results Section */
.results-section {
    margin-top: 30px;
    margin-bottom: 40px;
    position: relative;
    z-index: 10;
}

.results-card {
    background: white;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    margin-bottom: 30px;
}

.monthly-payment-display {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background-color: #5cb85c;
    color: white;
    border-radius: 6px;
    margin-bottom: 25px;
}

.monthly-payment-display .label {
    font-size: 18px;
    font-weight: 500;
}

.monthly-payment-display .amount {
    font-size: 32px;
    font-weight: bold;
}

.copy-btn {
    background: transparent;
    border: 1px solid white;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    margin-left: auto;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Payment Breakdown Table */
.payment-breakdown {
    margin-bottom: 25px;
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
}

.breakdown-table th,
.breakdown-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.breakdown-table th {
    font-weight: 600;
    color: #666;
    font-size: 14px;
    background-color: #f9f9f9;
}

.breakdown-table td {
    font-size: 14px;
    color: #333;
}

.mortgage-payment-row {
    background-color: #f0f7ff;
}

.total-row td {
    border-top: 2px solid #333;
    border-bottom: none;
    padding-top: 15px;
    font-size: 16px;
}

/* Payment Chart */
.payment-chart {
    display: flex;
    gap: 30px;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 6px;
    position: relative;
    overflow: visible;
}

#paymentPieChart {
    max-width: 200px;
    max-height: 200px;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.color-box {
    width: 16px;
    height: 16px;
    border-radius: 2px;
}

.color-box.principal {
    background-color: #5090D3;
}

.color-box.property-tax {
    background-color: #81C855;
}

.color-box.home-insurance {
    background-color: #F5A623;
}

.color-box.other {
    background-color: #E94F37;
}

/* Summary Table */
.summary-table {
    margin-bottom: 25px;
}

.summary-table table {
    width: 100%;
    border-collapse: collapse;
}

.summary-table td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

.summary-table td:first-child {
    color: #666;
}

.summary-table td:last-child {
    text-align: right;
    font-weight: 500;
}

/* Latest Rates */
.latest-rates {
    padding: 20px;
    background-color: #f0f7ff;
    border-radius: 6px;
    margin-top: 25px;
}

.latest-rates h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
}

.latest-rates p {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #666;
}

.rate {
    font-weight: 600;
    color: #4472c4;
}

.rate-links {
    display: flex;
    gap: 20px;
}

.rate-link {
    color: #4472c4;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 15px;
    border: 1px solid #4472c4;
    border-radius: 4px;
    transition: all 0.3s;
}

.rate-link:hover {
    background-color: #4472c4;
    color: white;
}

/* Amortization Section */
.amortization-section {
    margin-top: 30px;
    margin-bottom: 40px;
    background: white;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    clear: both;
}

.amortization-section h2 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #333;
}

.schedule-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    border: 1px solid #ddd;
    background: white;
    color: #666;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.3s;
}

.tab-btn.active {
    background-color: #4472c4;
    color: white;
    border-color: #4472c4;
}

.tab-btn:hover:not(.active) {
    background-color: #f0f0f0;
}

/* Amortization Table */
.schedule-table-container {
    margin-bottom: 30px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.amortization-table {
    width: 100%;
    border-collapse: collapse;
}

.amortization-table th {
    position: sticky;
    top: 0;
    background-color: #f9f9f9;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #666;
    font-size: 14px;
    border-bottom: 2px solid #ddd;
}

.amortization-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

.amortization-table tr:hover {
    background-color: #f5f5f5;
}

/* Amortization Chart */
.amortization-chart {
    height: 400px;
    margin-top: 30px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .content-grid {
        gap: 20px;
    }
    
    .sidebar {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .content-grid {
        flex-direction: column;
        gap: 20px;
    }
    
    .sidebar {
        width: 100%;
        position: static;
        order: 2;
    }
    
    .calculator-section {
        order: 1;
    }
    
    .calculator-container {
        padding: 0 15px;
    }
    
    /* Form improvements */
    .form-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 20px;
    }
    
    .form-row label {
        flex: none;
        width: 100%;
        margin-bottom: 8px;
        font-size: 15px;
    }
    
    .input-group {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .form-input {
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
        flex: 1;
        min-width: 120px;
    }
    
    .form-input.small {
        width: 100%;
        max-width: 150px;
    }
    
    .year-input {
        width: 100%;
        max-width: 100px;
    }
    
    .currency-symbol,
    .percentage-symbol {
        padding: 12px;
        font-size: 15px;
    }
    
    .small-select,
    .month-select {
        padding: 12px;
        font-size: 16px;
        width: 100%;
        max-width: 150px;
        margin-left: 0;
        margin-top: 8px;
    }
    
    .percentage-group {
        max-width: 100%;
        width: 100%;
    }
    
    /* Taxes & Costs Section Mobile */
    .taxes-costs-section {
        padding: 15px;
    }
    
    .taxes-costs-details .form-row {
        margin-bottom: 15px;
    }
    
    /* Form Actions */
    .form-actions {
        flex-direction: column;
        gap: 12px;
        margin-top: 25px;
    }
    
    .calculate-btn,
    .clear-btn {
        width: 100%;
        padding: 15px 20px;
        font-size: 16px;
        min-height: 48px; /* Better touch target */
    }
    
    /* Results Section Mobile */
    .monthly-payment-display {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 20px;
        position: relative;
    }
    
    .monthly-payment-display .label {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .monthly-payment-display .amount {
        font-size: 2.2rem;
        margin: 10px 0;
        width: 100%;
    }
    
    .copy-btn {
        position: static;
        margin: 15px 0 0 0;
        padding: 10px 15px;
        min-height: 44px;
        font-size: 14px;
    }
    
    /* Payment Chart Mobile */
    .payment-chart {
        flex-direction: column;
        align-items: center;
        gap: 20px;
        padding: 15px;
    }
    
    #paymentPieChart {
        max-width: 250px;
        max-height: 250px;
    }
    
    .chart-legend {
        width: 100%;
        max-width: 300px;
    }
    
    .legend-item {
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid #eee;
    }
    
    .legend-item:last-child {
        border-bottom: none;
    }
    
    /* Tables Mobile */
    .breakdown-table {
        font-size: 14px;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .breakdown-table thead,
    .breakdown-table tbody,
    .breakdown-table th,
    .breakdown-table td,
    .breakdown-table tr {
        display: block;
    }
    
    .breakdown-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .breakdown-table tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 4px;
        background: #f9f9f9;
    }
    
    .breakdown-table td {
        border: none;
        position: relative;
        padding: 8px 8px 8px 25%;
        white-space: normal;
        text-align: left;
    }
    
    .breakdown-table td:before {
        content: attr(data-label) ": ";
        position: absolute;
        left: 6px;
        width: 20%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 600;
        color: #666;
    }
    
    .total-row {
        background: #e8f5e8 !important;
        border: 2px solid #28a745;
    }
    
    .total-row td {
        font-weight: 600;
    }
    
    /* Summary Table Mobile */
    .summary-table table {
        display: block;
        overflow-x: auto;
    }
    
    .summary-table tr {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 0;
        border-bottom: 1px solid #eee;
    }
    
    .summary-table td {
        padding: 0;
        border: none;
        flex: 1;
    }
    
    .summary-table td:first-child {
        font-weight: 600;
        color: #495057;
    }
    
    .summary-table td:last-child {
        text-align: right;
        font-weight: 600;
        color: #28a745;
    }
    
    /* Latest Rates Mobile */
    .latest-rates {
        padding: 15px;
        text-align: center;
    }
    
    .rate-links {
        flex-direction: column;
        gap: 10px;
        margin-top: 15px;
    }
    
    .rate-link {
        text-align: center;
        padding: 12px 20px;
        display: block;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Amortization Section Mobile */
    .amortization-section {
        padding: 20px;
        margin-bottom: 30px;
    }
    
    .amortization-section h2 {
        font-size: 20px;
        text-align: center;
    }
    
    .schedule-tabs {
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .tab-btn {
        flex: 1;
        min-width: 120px;
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    
    /* Amortization Table Mobile */
    .schedule-table-container {
        max-height: 300px;
        border-radius: 6px;
    }
    
    .amortization-table {
        font-size: 13px;
    }
    
    .amortization-table th {
        padding: 10px 8px;
        font-size: 12px;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .amortization-table td {
        padding: 8px;
        font-size: 13px;
    }
    
    /* Amortization Chart Mobile */
    .amortization-chart {
        height: 250px;
        margin-top: 20px;
    }
}

@media (max-width: 480px) {
    .calculator-container {
        padding: 0 10px;
    }
    
    .calculator-card,
    .results-card,
    .amortization-section {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .calculator-header {
        padding: 12px;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    /* Extra small form adjustments */
    .form-input {
        padding: 14px;
        font-size: 16px;
    }
    
    .input-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .currency-symbol,
    .percentage-symbol {
        border-radius: 4px 4px 0 0;
        border-bottom: none;
        text-align: center;
    }
    
    .form-input {
        border-radius: 0 0 4px 4px;
    }
    
    .small-select,
    .month-select {
        margin-top: 8px;
        width: 100%;
    }
    
    /* Results adjustments */
    .monthly-payment-display .amount {
        font-size: 1.8rem;
    }
    
    #paymentPieChart {
        max-width: 200px;
        max-height: 200px;
    }
    
    /* Table improvements for very small screens */
    .breakdown-table tr {
        margin-bottom: 15px;
        padding: 12px;
    }
    
    .breakdown-table td {
        padding: 6px 6px 6px 30%;
        font-size: 13px;
    }
    
    .breakdown-table td:before {
        width: 25%;
        font-size: 12px;
    }
    
    /* Amortization improvements */
    .amortization-table {
        font-size: 12px;
    }
    
    .amortization-table th,
    .amortization-table td {
        padding: 6px 4px;
    }
    
    .amortization-chart {
        height: 200px;
    }
    
    .tab-btn {
        padding: 10px 12px;
        font-size: 13px;
        min-width: 100px;
    }
}

/* Landscape phone optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .form-actions {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .calculate-btn,
    .clear-btn {
        width: 48%;
    }
    
    .monthly-payment-display {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        text-align: left;
    }
    
    .monthly-payment-display .amount {
        width: auto;
        margin: 0;
    }
    
    .copy-btn {
        position: static;
        margin: 0;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .form-input:focus {
        border-color: #4472c4;
        box-shadow: 0 0 0 3px rgba(68, 114, 196, 0.2);
    }
    
    .calculate-btn:active,
    .clear-btn:active {
        transform: scale(0.98);
    }
    
    .tab-btn:active {
        transform: scale(0.98);
    }
    
    .copy-btn:active,
    .rate-link:active {
        transform: scale(0.95);
    }
}

/* SEO Content Section */
.seo-content {
    background-color: #fff;
    margin-top: 40px;
    padding: 40px 0;
    border-top: 1px solid #e0e0e0;
    position: relative;
    clear: both;
    z-index: 1;
}

.seo-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.seo-content h2 {
    color: #333;
    font-size: 28px;
    margin-bottom: 20px;
    font-weight: 600;
}

.seo-content h3 {
    color: #4472c4;
    font-size: 22px;
    margin-top: 30px;
    margin-bottom: 15px;
    font-weight: 600;
}

.seo-content h4 {
    color: #555;
    font-size: 18px;
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 600;
}

.seo-content p {
    color: #666;
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 15px;
}

.seo-content ol,
.seo-content ul {
    margin-left: 30px;
    margin-bottom: 20px;
}

.seo-content ol li,
.seo-content ul li {
    color: #666;
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 10px;
}

.seo-content ol li strong,
.seo-content ul li strong {
    color: #333;
}

/* Definition List Styling */
.seo-content dl {
    margin-bottom: 20px;
}

.seo-content dt {
    color: #333;
    font-size: 16px;
    font-weight: 600;
    margin-top: 15px;
    margin-bottom: 5px;
}

.seo-content dd {
    color: #666;
    font-size: 16px;
    line-height: 1.8;
    margin-left: 20px;
    margin-bottom: 10px;
}

/* FAQ Section */
.faq-section {
    background-color: #f9f9f9;
    padding: 30px;
    border-radius: 8px;
    margin-top: 30px;
    margin-bottom: 30px;
}

.faq-section h4 {
    color: #333;
    font-size: 18px;
    margin-bottom: 10px;
    font-weight: 600;
}

.faq-section p {
    color: #666;
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 20px;
}

.faq-section p:last-child {
    margin-bottom: 0;
}

/* Disclaimer */
.disclaimer {
    background-color: #f0f7ff;
    border-left: 4px solid #4472c4;
    padding: 20px;
    margin-top: 30px;
    border-radius: 4px;
}

.disclaimer p {
    color: #555;
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
}

/* Print Styles */
@media print {
    .search-box,
    .quick-links-box,
    .category-tabs,
    .form-actions,
    .more-options-link,
    .copy-btn {
        display: none;
    }
    
    .calculator-card,
    .results-card,
    .amortization-section {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
    
    .seo-content {
        page-break-before: always;
    }
}
