/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --sidebar-bg: #1e293b;
    --sidebar-text: #f1f5f9;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --border-color: #e2e8f0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.sidebar-header p {
    font-size: 0.8rem;
    opacity: 0.7;
}

.sidebar-content {
    padding: 20px;
    flex: 1;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--sidebar-text);
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: var(--sidebar-text);
    font-size: 0.9rem;
    transition: border-color 0.2s, background 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255,255,255,0.15);
}

.help-text {
    display: block;
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 4px;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 12px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

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

.btn-run {
    margin-top: 20px;
    background: linear-gradient(135deg, var(--success-color), #059669);
}

.btn-run:hover {
    background: linear-gradient(135deg, #059669, var(--success-color));
}

/* Validation */
.validation-error {
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 6px;
    color: #fca5a5;
    font-size: 0.8rem;
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
}

.status-idle .status-dot { background: #64748b; }
.status-loading .status-dot { background: var(--warning-color); animation: pulse 1s infinite; }
.status-success .status-dot { background: var(--success-color); }
.status-error .status-dot { background: var(--danger-color); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 24px 32px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.page-header p {
    color: #64748b;
    font-size: 1rem;
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card.stat-highlight {
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    border: 2px solid var(--primary-color);
}

.stat-card.stat-prob {
    background: linear-gradient(135deg, #d1fae5, #ecfdf5);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 4px;
}

.stat-value.positive { color: var(--success-color); }
.stat-value.negative { color: var(--danger-color); }
.stat-value.success { color: var(--success-color); }

.stat-label {
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Parameter Badges */
.params-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.param-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--card-bg);
    border-radius: 20px;
    font-size: 0.85rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card.full-width {
    grid-column: 1 / -1;
}

.card h2 {
    font-size: 1rem;
    color: var(--text-color);
    margin-bottom: 20px;
}

/* Range Bars */
.range-bars {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.range-item {
    display: grid;
    grid-template-columns: 80px 1fr 80px;
    align-items: center;
    gap: 12px;
}

.range-label {
    font-size: 0.8rem;
    color: #64748b;
}

.range-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.range-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.range-fill.positive { background: var(--success-color); }
.range-fill.warning { background: var(--warning-color); }
.range-fill.negative { background: var(--danger-color); }

.range-value {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
}

/* Assessment */
.assessment {
    text-align: center;
    padding: 20px 0;
}

.probability-badge {
    display: inline-block;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    border-radius: 50px;
    font-size: 1.4rem;
    font-weight: 700;
}

.probability-badge.warning {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
}

.probability-badge.danger {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
}

/* Histogram */
.histogram-img {
    width: 100%;
    max-width: 900px;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

/* Charts */
.chart-container {
    height: 250px;
    position: relative;
}

/* Insights */
.insights-section {
    margin-top: 0;
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.insight-item {
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
}

.insight-item h4 {
    font-size: 0.9rem;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.insight-item p {
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.5;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 40px;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.empty-state h2 {
    font-size: 1.4rem;
    margin-bottom: 12px;
    color: var(--text-color);
}

.empty-state p {
    color: #64748b;
    font-size: 1rem;
    max-width: 400px;
    margin: 0 auto;
}

/* Loading */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error Message */
.error-message {
    padding: 24px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    text-align: center;
}

.error-message h3 {
    color: var(--danger-color);
    margin-bottom: 8px;
}

.error-message p {
    color: #7f1d1d;
}

/* Footer */
.page-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .sidebar {
        width: 240px;
    }
    .main-content {
        margin-left: 240px;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .insights-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
    }
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    .stats-row {
        grid-template-columns: 1fr 1fr;
    }
}
