/* styles.css - Professional Investment UX */

:root {
    --primary: #0a4b6e;
    --primary-dark: #06344d;
    --secondary: #2e8b57;
    --danger: #dc3545;
    --warning: #ffc107;
    --success: #28a745;
    --dark: #2c3e50;
    --light: #f8f9fa;
    --gray: #6c757d;
    --border: #dee2e6;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f4f8;
    color: var(--dark);
    line-height: 1.6;
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.app-header {
    margin-bottom: 30px;
}

.app-header h1 {
    font-size: 2rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    background: var(--secondary);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* Layout */
.main-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 25px;
}

/* Input Panel */
.input-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

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

.input-section h3 {
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray);
}

.input-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(10, 75, 110, 0.1);
}

.input-group input.error {
    border-color: var(--danger);
}

.validation-message {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 3px;
}

/* Advanced Settings Toggle */
.advanced-toggle {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    padding: 10px 0;
    width: 100%;
    text-align: left;
}

.advanced-settings {
    display: none;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 10px;
}

.advanced-settings.show {
    display: block;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.kpi-card.risk-very-safe { border-left: 5px solid #28a745; }
.kpi-card.risk-safe { border-left: 5px solid #5cb85c; }
.kpi-card.risk-moderate { border-left: 5px solid #ffc107; }
.kpi-card.risk-risky { border-left: 5px solid #fd7e14; }
.kpi-card.risk-very-risky { border-left: 5px solid #dc3545; }

.kpi-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--gray);
    margin-bottom: 5px;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 600;
    line-height: 1.2;
}

.kpi-sub {
    font-size: 0.9rem;
    color: var(--gray);
    margin-top: 5px;
}

/* DSCR Colors */
.dscr-excellent { color: #28a745; }
.dscr-good { color: #5cb85c; }
.dscr-warning { color: #ffc107; }
.dscr-danger { color: #dc3545; }

/* Risk Simulator */
.risk-simulator {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.simulator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.slider-group {
    margin-bottom: 15px;
}

.slider-group label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.slider-group input[type=range] {
    width: 100%;
    margin: 5px 0;
}

.slider-value {
    font-weight: 600;
    color: var(--primary);
}

/* Investor Timeline */
.timeline {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.timeline-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.timeline-item {
    text-align: center;
}

.timeline-year {
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary);
}

.timeline-label {
    font-size: 0.9rem;
    color: var(--gray);
}

/* Loading States */
.loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

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

/* Responsive */
@media (max-width: 768px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .app-container {
        padding: 10px;
    }

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

    .app-header h1 {
        font-size: 1.5rem;
        flex-wrap: wrap;
    }

    .badge {
        font-size: 0.8rem;
        padding: 3px 10px;
    }

    /* KPI Grid */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .kpi-value {
        font-size: 1.2rem;
    }

    /* Scenario Toggles */
    .scenario-toggles {
        width: 100%;
        justify-content: center;
    }

    .toggle-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    /* Charts Row */
    .charts-row {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .chart-container {
        height: 200px !important;
    }

    /* Comparison Grid */
    #comparisonSection .grid {
        grid-template-columns: 1fr !important;
    }

    /* ROE Analysis Cards */
    #roeAnalysis .flex {
        flex-direction: column;
        gap: 15px !important;
    }

    #roeAnalysis .flex > div {
        width: 100%;
    }

    /* Timeline */
    .timeline .flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 15px;
    }

    .timeline [style*="position: relative"] {
        width: 100%;
    }

    /* Projection Table */
    .table-wrapper {
        padding: 15px !important;
    }

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

    .projection-table th,
    .projection-table td {
        padding: 10px 8px !important;
        white-space: nowrap;
    }

    /* Summary Cards */
    [id="20yrSummary"] .grid,
    .summary-cards {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    /* Risk Simulator */
    .simulator-grid {
        grid-template-columns: 1fr !important;
    }

    .slider-group {
        margin-bottom: 15px;
    }

    /* Investor Timeline Cards */
    .timeline > div {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .timeline [style*="width: 60px"] {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.2rem !important;
    }

    /* Hide less important elements on mobile */
    .debug-status {
        display: none;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .app-header h1 {
        font-size: 1.2rem;
    }

    .input-section h3 {
        font-size: 0.9rem;
    }

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

    .input-group input {
        padding: 8px;
        font-size: 0.9rem;
    }

    /* Comparison metrics grid */
    [id="comparisonSection"] .grid-cols-4,
    .comparison-metrics {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* KPI sections */
    .kpi-section-title {
        font-size: 0.7rem;
    }

    .kpi-note {
        font-size: 0.6rem;
    }

    /* Timeline stats */
    .timeline-stats {
        grid-template-columns: 1fr !important;
    }

    /* Projection table adjustments */
    .table-wrapper {
        margin: 15px -10px;
        border-radius: 0;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .toggle-btn,
    .reset-btn,
    .advanced-toggle {
        min-height: 44px;
    }

    input[type="range"] {
        min-height: 44px;
    }

    .kpi-card {
        cursor: default;
    }
}

/* Landscape mode */
@media (max-width: 896px) and (orientation: landscape) {
    .main-grid {
        grid-template-columns: 1fr 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}