/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --background-color: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 40px 20px;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo-img {
    width: 50px;
    height: 50px;
    border-radius: 10px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 8px;
}

/* Main Content */
main {
    padding: 30px 0;
}

/* Cards */
.card {
    background: var(--card-background);
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.card h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

/* Asset Allocation Section */
.allocation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: center;
}

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

.input-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.input-group input[type="range"] {
    width: calc(100% - 60px);
    height: 8px;
    border-radius: 4px;
    background: var(--border-color);
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.input-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: background 0.2s;
}

.input-group input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
}

.value-display {
    display: inline-block;
    width: 50px;
    text-align: right;
    font-weight: 600;
    color: var(--primary-color);
}

.input-group input[type="number"],
.input-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.input-group input[type="number"]:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.total-allocation {
    font-size: 1.1rem;
    padding: 15px;
    background: var(--background-color);
    border-radius: var(--radius-sm);
    text-align: center;
}

.warning {
    color: var(--danger-color);
    font-weight: 500;
    margin-left: 15px;
}

.hidden {
    display: none;
}

.allocation-chart {
    display: flex;
    justify-content: center;
    align-items: center;
}

#allocation-pie-chart {
    max-width: 280px;
    max-height: 280px;
}

/* Parameters Grid */
.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* Historical Data Section */
.historical-info {
    margin-bottom: 25px;
}

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

.historical-item {
    background: var(--background-color);
    padding: 15px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.historical-item h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.historical-item p {
    margin: 5px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.positive {
    color: var(--success-color);
    font-weight: 600;
}

.neutral {
    color: var(--warning-color);
    font-weight: 600;
}

.negative {
    color: var(--danger-color);
    font-weight: 600;
}

.historical-chart-container {
    height: 300px;
    margin-top: 20px;
}

/* Risk Assessment Section */
.risk-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

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

.metric {
    background: var(--background-color);
    padding: 20px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.metric h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.risk-gauge {
    text-align: center;
}

.risk-gauge h4 {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.gauge-container {
    padding: 20px;
}

.gauge {
    height: 20px;
    background: linear-gradient(to right, #22c55e, #f59e0b, #ef4444);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.gauge-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 4px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: left 0.5s ease;
}

.gauge-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.risk-level-text {
    margin-top: 15px;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-scenario,
.btn-preset {
    background: var(--background-color);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    margin: 5px;
}

.btn-scenario:hover,
.btn-preset:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-scenario.active,
.btn-preset.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Projection Results */
.projection-results {
    margin-top: 25px;
}

.projection-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.projection-item {
    background: var(--background-color);
    padding: 20px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.projection-item h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.projection-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
}

.projection-range {
    background: var(--background-color);
    padding: 20px;
    border-radius: var(--radius-sm);
    text-align: center;
    margin-bottom: 25px;
}

.projection-range h4 {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.range-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.range-value {
    font-size: 1.3rem;
    font-weight: 700;
}

.pessimistic {
    color: var(--warning-color);
}

.optimistic {
    color: var(--success-color);
}

.range-separator {
    color: var(--text-secondary);
}

.projection-chart-container {
    height: 350px;
}

/* Scenario Analysis */
.scenario-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 20px;
}

.scenario-description {
    background: var(--background-color);
    padding: 15px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.scenario-description p {
    color: var(--text-secondary);
}

.scenario-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.scenario-card {
    background: var(--background-color);
    padding: 20px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.scenario-card h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.scenario-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.scenario-chart-container {
    height: 300px;
}

/* Portfolio Comparison */
.comparison-presets {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 20px;
}

.comparison-table-container {
    overflow-x: auto;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.comparison-table th,
.comparison-table td {
    padding: 15px 12px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.comparison-table th {
    background: var(--background-color);
    font-weight: 600;
    color: var(--text-secondary);
}

.comparison-table tbody tr:hover {
    background: var(--background-color);
}

.comparison-table tbody tr.active {
    background: rgba(37, 99, 235, 0.1);
}

/* Footer */
footer {
    background: var(--text-primary);
    color: white;
    padding: 30px 20px;
    text-align: center;
}

.powered-by {
    margin-bottom: 15px;
}

.powered-by a {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 500;
    font-size: 1.1rem;
}

.powered-by a:hover {
    text-decoration: underline;
}

.disclaimer {
    font-size: 0.85rem;
    color: #94a3b8;
    max-width: 600px;
    margin: 0 auto;
}

/* Responsive Design */
@media (max-width: 900px) {
    .allocation-grid,
    .risk-grid {
        grid-template-columns: 1fr;
    }

    .allocation-chart {
        order: -1;
        margin-bottom: 20px;
    }

    header h1 {
        font-size: 2rem;
    }
}

@media (max-width: 600px) {
    header {
        padding: 30px 15px;
    }

    .logo {
        flex-direction: column;
        gap: 10px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .card {
        padding: 20px 15px;
    }

    .card h2 {
        font-size: 1.25rem;
    }

    .params-grid {
        grid-template-columns: 1fr;
    }

    .historical-grid {
        grid-template-columns: 1fr 1fr;
    }

    .risk-metrics {
        grid-template-columns: 1fr;
    }

    .projection-summary,
    .scenario-grid {
        grid-template-columns: 1fr 1fr;
    }

    .btn-scenario,
    .btn-preset {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

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

    .comparison-table th,
    .comparison-table td {
        padding: 10px 6px;
    }
}

@media (max-width: 400px) {
    .historical-grid,
    .projection-summary,
    .scenario-grid {
        grid-template-columns: 1fr;
    }

    .range-display {
        flex-direction: column;
        gap: 10px;
    }
}

/* Canvas Chart Styles */
canvas {
    max-width: 100%;
}

/* Animation for loading states */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
