/* Modern Calculator Redesign */

/* Main layout container */
.calculator-layout {
    display: flex;
    flex-direction: column;
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 2rem;
    gap: 3rem;
}

/* Input sections in a flexible grid */
.calculator-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

/* Modernized input sections */
.input-section {
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid #E5E7EB;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.input-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.08);
}

.input-section-title {
    background: #F9FAFB;
    padding: 1rem 1.5rem;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    border-bottom: 1px solid #E5E7EB;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.input-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Form styling */
.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}

.form-group input,
.form-group select {
    padding: 0.625rem 1rem;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    font-size: 0.9375rem;
    transition: all 0.15s ease;
    background: var(--white);
    color: #111827;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--sky-blue);
    box-shadow: 0 0 0 3px rgba(69, 157, 216, 0.1);
}

.input-help {
    font-size: 0.75rem;
    color: #6B7280;
    margin-top: 0.25rem;
}

/* Main analysis card - full width */
.main-analysis-card {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid #E5E7EB;
    overflow: hidden;
    transition: all 0.2s ease;
    margin-bottom: 2rem;
}

.main-analysis-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

/* Secondary results section */
.calculator-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.results-card {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid #E5E7EB;
    overflow: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.results-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border-color: #D1D5DB;
}

.results-title {
    background: linear-gradient(135deg, #033B87 0%, #1E5BA8 100%);
    padding: 1.25rem 1.5rem;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #FFFFFF;
    border-bottom: none;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.results-summary {
    padding: 1.5rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #F3F4F6;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item.main-result {
    font-size: 1.125rem;
    font-weight: 600;
    padding: 1rem 0;
    border-bottom: 2px solid #E5E7EB;
}

.result-label {
    font-size: 0.875rem;
    color: #6B7280;
}

.result-value {
    font-weight: 600;
    font-size: 1rem;
}

/* Table section - full width with better styling */
.projection-table {
    grid-column: 1 / -1;
    background: var(--white);
    border-radius: 16px;
    border: 1px solid #E5E7EB;
    overflow: hidden;
    margin-top: 2rem;
    width: 100%;
    max-width: 100%;
}

.projection-table h4 {
    background: #F9FAFB;
    padding: 1.25rem 2rem;
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    border-bottom: 1px solid #E5E7EB;
}

.projection-table p {
    padding: 0 2rem;
    margin: 1rem 0 0 0;
    font-size: 0.875rem;
    color: #6B7280;
}

.table-container {
    overflow-x: auto;
    padding: 1rem 1.5rem 1.5rem 1.5rem;
    width: 100%;
}

.projection-table table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8rem;
    table-layout: fixed;
}

.projection-table th {
    background: #F9FAFB;
    padding: 0.8rem 0.4rem;
    text-align: center;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #E5E7EB;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
    vertical-align: middle;
}

.projection-table th:first-child {
    text-align: center;
    position: sticky;
    left: 0;
    background: #F9FAFB;
    z-index: 1;
    width: 8%;
}

/* Optimize column widths for no scrolling */
.projection-table th:nth-child(2) { width: 11%; } /* Rental Income */
.projection-table th:nth-child(3) { width: 13%; } /* Tax Deductible Expenses */
.projection-table th:nth-child(4) { width: 13%; } /* Property Tax Position */
.projection-table th:nth-child(5) { width: 13%; } /* Tax Benefit/Cost */
.projection-table th:nth-child(6) { width: 11%; } /* Principal */
.projection-table th:nth-child(7) { width: 13%; } /* Add Back: Depreciation */
.projection-table th:nth-child(8) { width: 15%; } /* Net Cash Position */

.projection-table td {
    padding: 0.7rem 0.4rem;
    text-align: center;
    border-bottom: 1px solid #F3F4F6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8rem;
    vertical-align: middle;
}

.projection-table td:first-child {
    text-align: center;
    font-weight: 600;
    color: #111827;
    position: sticky;
    left: 0;
    background: var(--white);
    z-index: 1;
}

.projection-table tr:hover td {
    background: #F9FAFB;
}

/* Chart container - modern style */
.chart-container {
    grid-column: 1 / -1;
    background: var(--white);
    border-radius: 16px;
    border: 1px solid #E5E7EB;
    padding: 2rem 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    overflow-x: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chart-container canvas {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: block;
    touch-action: pan-y; /* Allow vertical scrolling but prevent horizontal on mobile */
}

/* Action buttons - centered and modern */
.calculator-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding: 2rem 0;
}

.btn-primary,
.btn-secondary {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--sky-blue);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--deep-navy);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(69, 157, 216, 0.25);
}

.btn-primary:active {
    transform: translateY(0);
    background: var(--deep-navy);
}

.btn-secondary {
    background: var(--white);
    color: var(--sky-blue);
    border: 2px solid var(--sky-blue);
}

.btn-secondary:hover {
    background: var(--sky-blue);
    color: var(--white);
    transform: translateY(-1px);
}

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

/* Loading state for buttons */
.btn-loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
    .calculator-layout {
        padding: 0 0.5rem;
        gap: 1.5rem;
    }
    
    .calculator-inputs {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .calculator-results {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Mobile table - make it horizontally scrollable */
    .projection-table {
        margin: 0 -0.5rem;
        border-radius: 12px;
    }
    
    .projection-table h4 {
        padding: 1rem 1rem 0.75rem 1rem;
        font-size: 1rem;
    }
    
    .projection-table p {
        padding: 0 1rem;
        font-size: 0.75rem;
        margin: 0.5rem 0;
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        padding: 0.75rem 0.5rem 1rem 0.5rem;
    }
    
    .projection-table table {
        min-width: 800px; /* Ensure table doesn't compress too much */
        table-layout: auto;
        font-size: 0.7rem;
    }
    
    .projection-table th {
        padding: 0.6rem 0.3rem;
        font-size: 0.6rem;
        letter-spacing: 0;
        line-height: 1.1;
    }
    
    .projection-table td {
        padding: 0.6rem 0.3rem;
        font-size: 0.7rem;
    }
    
    /* Sticky first column on mobile */
    .projection-table th:first-child,
    .projection-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
        min-width: 50px;
    }
    
    .calculator-actions {
        flex-direction: column;
        padding: 1.5rem;
        gap: 0.75rem;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
    
    /* Mobile-optimized chart container */
    .chart-container {
        padding: 0.75rem 0.5rem;
        min-height: 280px;
        border-radius: 12px;
        margin: 0;
    }
    
    /* Ensure chart scales properly on mobile */
    .chart-container canvas {
        max-width: 100%;
        height: auto !important;
    }
    
    /* Add scroll indicator for table */
    .table-container::after {
        content: '← Swipe to see more →';
        display: block;
        text-align: center;
        font-size: 0.7rem;
        color: #9CA3AF;
        padding: 0.5rem;
        font-style: italic;
    }
    
    /* Mobile-optimized breakdown section */
    .results-breakdown {
        padding: 0;
    }
    
    .results-breakdown h4 {
        font-size: 0.75rem;
        padding: 0.875rem 1rem;
    }
    
    .breakdown-item {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
        gap: 0.5rem;
        flex-wrap: wrap;
        align-items: flex-start;
    }
    
    .breakdown-item span:first-child {
        flex: 1 1 auto;
        min-width: 0;
        padding-right: 0.5rem;
        font-size: 0.85rem;
    }
    
    .breakdown-item span:last-child {
        flex: 0 0 auto;
        text-align: right;
        white-space: nowrap;
        font-size: 0.9rem;
    }
    
    .breakdown-item small {
        flex-basis: 100%;
        margin-top: 0.25rem;
        margin-left: 0;
        font-size: 0.7rem !important;
        display: block;
    }
    
    .breakdown-item.total {
        padding: 1rem;
        margin-top: 0;
    }
    
    .breakdown-item.total span:first-child {
        font-size: 0.9rem;
    }
    
    .breakdown-item.total span:last-child {
        font-size: 1.1rem;
    }
    
    /* Mobile results card */
    .results-card {
        padding: 0;
        border-radius: 10px;
    }
    
    .results-title {
        font-size: 0.85rem;
        padding: 1rem;
    }
}

/* Modern colors for positive/negative values */
.projection-table td.positive {
    color: #059669;
    font-weight: 600;
}

.projection-table td.negative {
    color: #DC2626;
    font-weight: 600;
}

.projection-table td.neutral {
    color: #6B7280;
}

.result-value.positive {
    color: #059669;
}

.result-value.negative {
    color: #DC2626;
}

/* Clean disclaimer styling */
.disclaimer-card {
    grid-column: 1 / -1;
    background: #F3F4F6;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.disclaimer-card h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    color: #374151;
    font-weight: 600;
}

.disclaimer-card p {
    margin: 0;
    font-size: 0.8125rem;
    color: #6B7280;
    line-height: 1.6;
}

/* Results breakdown styling */
.results-breakdown {
    padding: 0;
    border-top: none;
}

.results-breakdown h4 {
    margin: 0;
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #F9FAFB;
    border-bottom: 1px solid #E5E7EB;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.5rem;
    font-size: 0.9rem;
    border-bottom: 1px solid #F3F4F6;
    transition: background-color 0.2s ease;
}

.breakdown-item:hover {
    background-color: #F9FAFB;
}

.breakdown-item span:first-child {
    color: #374151;
    font-weight: 500;
}

.breakdown-item span:last-child {
    font-weight: 700;
    color: #111827;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.breakdown-item.separator {
    border-top: 2px solid #E5E7EB;
    margin-top: 0;
    padding-top: 0.875rem;
}

.breakdown-item.total {
    background: linear-gradient(135deg, #F0F7FF 0%, #E6F2FF 100%);
    border-top: 3px solid #459DD8;
    border-bottom: none;
    margin-top: 0;
    padding: 1.25rem 1.5rem;
    font-weight: 700;
}

.breakdown-item.total:hover {
    background: linear-gradient(135deg, #E6F2FF 0%, #D9ECFF 100%);
}

.breakdown-item.total span:first-child {
    color: #033B87;
    font-weight: 700;
    font-size: 1rem;
}

.breakdown-item.total span:last-child {
    color: #033B87;
    font-size: 1.25rem;
}
