/* ============================================
   EMI Calculator - Brutalist Styling
   Ray2Volt Solar Toolbox
   ============================================ */

/* Google Sans Flex for UI elements */
@import url('https://fonts.googleapis.com/css2?family=Google+Sans+Flex:wght@400;500;600;700&display=swap');

/* --- Page Header --- */
.emi-page-header {
    margin-bottom: 1.5rem;
}

.emi-page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.emi-page-header p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* --- Mode Selector --- */
.emi-mode-selector {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.1s ease;
    font-family: 'Google Sans Flex', 'Google Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
}

.mode-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.mode-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* --- Calculator Main Card --- */
.emi-calculator-card {
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 2px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.emi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

/* --- Input Section --- */
.emi-inputs-section {
    display: flex;
    flex-direction: column;
}

.emi-input-group {
    margin-bottom: 1.5rem;
}

.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.input-header label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.input-value-display {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 0.25rem 0.75rem;
    border-radius: 2px;
    border: 1px solid var(--primary);
    font-family: 'Google Sans Flex', 'Google Sans', sans-serif;
}

/* --- Enhanced Slider --- */
.emi-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-light);
    border-radius: 3px;
    outline: none;
    margin-bottom: 0.75rem;
}

.emi-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: var(--primary);
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.emi-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.emi-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: var(--primary);
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* --- Number Input --- */
.emi-input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-family: 'Google Sans Flex', 'Google Sans', sans-serif;
    border: 1px solid var(--border-medium);
    border-radius: 2px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all 0.1s ease;
}

.emi-input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: #fff;
}

.emi-input-highlight {
    border-color: var(--primary);
    background: var(--primary-light);
}

.input-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* --- Fixed EMI Container --- */
.fixed-emi-container {
    background: var(--primary-light);
    padding: 1rem;
    border-radius: 2px;
    border: 1px solid var(--primary);
}

.fixed-emi-container label {
    color: var(--primary-dark);
}

/* --- Method Toggle --- */
.emi-method-toggle {
    margin-top: 0.5rem;
}

.toggle-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.toggle-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.toggle-btn {
    flex: 1;
    padding: 0.625rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: 'Google Sans Flex', 'Google Sans', sans-serif;
    border: 1px solid var(--border-medium);
    border-radius: 2px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.1s ease;
}

.toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.toggle-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* --- Results Section --- */
.emi-results-section {
    display: flex;
    flex-direction: column;
}

/* --- Primary Result Card --- */
.emi-primary-result {
    background: var(--primary);
    color: #fff;
    padding: 1.5rem;
    border-radius: 2px;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100px;
    border: 1px solid var(--primary-dark);
}

.emi-primary-result .result-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
    margin-bottom: 0.5rem;
}

.emi-primary-result .result-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.2;
    font-family: 'Google Sans Flex', 'Google Sans', sans-serif;
}

/* --- Secondary Results --- */
.emi-secondary-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.result-item {
    background: var(--bg-body);
    padding: 1rem;
    border-radius: 2px;
    text-align: center;
    border: 1px solid var(--border-light);
}

.result-item .item-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.result-item .item-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Google Sans Flex', 'Google Sans', sans-serif;
}

/* --- Chart Wrapper --- */
.emi-chart-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--bg-body);
    border-radius: 2px;
    border: 1px solid var(--border-light);
}

.emi-chart-wrapper canvas {
    max-width: 180px;
    max-height: 180px;
    margin-bottom: 0.75rem;
}

.chart-legend {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-color.principal {
    background: #06B6D4;
}

.legend-color.interest {
    background: #FBBF24;
}

/* --- Amortization Card --- */
.emi-amortization-card {
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 2px;
    padding: 1.5rem;
    overflow: hidden;
}

.emi-amortization-card .section-title {
    margin-bottom: 1rem;
}

.table-wrapper {
    max-height: 400px;
    overflow-y: auto;
    border-radius: 2px;
    border: 1px solid var(--border-medium);
}

.emi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.emi-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.emi-table th {
    background: var(--primary);
    color: #fff;
    padding: 0.875rem 1rem;
    font-weight: 600;
    text-align: left;
}

.emi-table th:first-child {
    border-radius: 0;
}

.emi-table th:last-child {
    border-radius: 0;
}

.emi-table td {
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.emi-table tbody tr:nth-child(even) {
    background: var(--bg-body);
}

.emi-table tbody tr:hover {
    background: var(--primary-light);
}

.emi-table td:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Responsive Design --- */

/* Tablet */
@media screen and (max-width: 1024px) {
    .emi-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .emi-secondary-results {
        grid-template-columns: 1fr 1fr;
    }

    .emi-chart-wrapper canvas {
        max-width: 160px;
        max-height: 160px;
    }
}

/* Mobile */
@media screen and (max-width: 768px) {
    .emi-page-header {
        margin-bottom: 1rem;
    }

    .emi-page-header h1 {
        font-size: 1.5rem;
    }

    .emi-page-header p {
        font-size: 0.875rem;
    }

    .emi-mode-selector {
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .mode-btn {
        flex: 1;
        min-width: calc(50% - 0.25rem);
        padding: 0.625rem 0.75rem;
        justify-content: center;
    }

    .mode-icon {
        font-size: 0.9rem;
    }

    .mode-text {
        font-size: 0.8rem;
    }

    .emi-calculator-card {
        padding: 1rem;
        border-radius: 12px;
    }

    .section-title {
        font-size: 0.9rem;
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
    }

    .emi-input-group {
        margin-bottom: 1.25rem;
    }

    .input-header label {
        font-size: 0.8rem;
    }

    .input-value-display {
        font-size: 0.8rem;
        padding: 0.2rem 0.6rem;
    }

    .emi-slider {
        height: 8px;
        /* Larger for touch */
    }

    .emi-slider::-webkit-slider-thumb {
        width: 26px;
        height: 26px;
    }

    .emi-slider::-moz-range-thumb {
        width: 26px;
        height: 26px;
    }

    .emi-input-field {
        padding: 0.875rem 1rem;
        font-size: 1rem;
        /* Prevent zoom on iOS */
    }

    .toggle-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }

    .toggle-btn {
        padding: 0.75rem 1rem;
    }

    .emi-primary-result {
        padding: 1.25rem;
        min-height: 90px;
    }

    .emi-primary-result .result-label {
        font-size: 0.75rem;
    }

    .emi-primary-result .result-value {
        font-size: 1.5rem;
    }

    .emi-secondary-results {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .result-item {
        padding: 0.75rem;
    }

    .result-item .item-label {
        font-size: 0.7rem;
    }

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

    .emi-chart-wrapper {
        padding: 0.75rem;
    }

    .emi-chart-wrapper canvas {
        max-width: 140px;
        max-height: 140px;
    }

    .chart-legend {
        gap: 1rem;
    }

    .legend-item {
        font-size: 0.75rem;
    }

    .emi-amortization-card {
        padding: 1rem;
        border-radius: 12px;
    }

    .table-wrapper {
        max-height: 300px;
        border-radius: 8px;
    }

    .emi-table {
        font-size: 0.8rem;
    }

    .emi-table th {
        padding: 0.625rem 0.5rem;
        font-size: 0.75rem;
    }

    .emi-table td {
        padding: 0.5rem;
    }
}

/* Small Mobile */
@media screen and (max-width: 480px) {
    .emi-mode-selector {
        flex-direction: column;
    }

    .mode-btn {
        width: 100%;
        min-width: 100%;
    }

    .emi-secondary-results {
        grid-template-columns: 1fr;
    }

    .emi-table th,
    .emi-table td {
        padding: 0.5rem 0.375rem;
        font-size: 0.7rem;
    }

    /* Hide less important columns on very small screens */
    .emi-table th:nth-child(4),
    .emi-table td:nth-child(4) {
        display: none;
    }
}