/* Monte Carlo Analysis Popup Styles */

.monte-carlo-analysis-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    /*backdrop-filter: blur(4px);*/
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.monte-carlo-analysis-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 1200px;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
}

.monte-carlo-analysis-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.analysis-header {
    background: linear-gradient(135deg, #667eea 0%, #4b58a2 100%);
    color: white;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.analysis-title h2 {
    margin: 0 0 4px 0;
    font-size: 28px;
    font-weight: 600;
}

.analysis-subtitle {
    font-size: 16px;
    opacity: 0.9;
    font-weight: 400;
}

.success-rate-badge {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 16px 24px;
    text-align: center;
    font-size: 32px;
    font-weight: 700;
    min-width: 120px;
}

.success-rate-badge.excellent {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
}

.success-rate-badge.good {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
}

.success-rate-badge.fair {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.4);
}

.success-rate-badge.poor {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

.badge-label {
    font-size: 14px;
    font-weight: 500;
    margin-top: 4px;
    opacity: 0.9;
}

/* Close Button */
.analysis-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.analysis-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Tab Navigation */
.analysis-tabs {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 32px;
    display: flex;
    gap: 4px;
}

.tab-button {
    background: none;
    border: none;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.2s;
    position: relative;
}

.tab-button:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.tab-button.active {
    background: white;
    color: #3b82f6;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #3b82f6;
}

/* Tab Content */
.analysis-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Overview Tab Styles */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.metric-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.metric-card.success-rate {
    border-left: 4px solid #10b981;
}

.metric-card.median-balance {
    border-left: 4px solid #3b82f6;
}

.metric-card.best-case {
    border-left: 4px solid #22c55e;
}

.metric-card.depletion-age {
    border-left: 4px solid #f59e0b;
}

.metric-icon {
    font-size: 24px;
    margin-bottom: 12px;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 4px;
}

.metric-label {
    font-size: 16px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.metric-detail {
    font-size: 14px;
    color: #64748b;
}

.success-probability-chart {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    margin-top: 24px;
}

.success-probability-chart h4 {
    margin: 0 0 16px 0;
    color: #1e293b;
    font-size: 18px;
}

.chart-placeholder {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 48px;
    text-align: center;
    color: #64748b;
    font-size: 16px;
}

/* Risk Analysis Tab */
.risk-analysis {
    display: grid;
    gap: 24px;
}

.risk-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.risk-factors, .failure-analysis {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
}

.risk-factors h4, .failure-analysis h4 {
    margin: 0 0 20px 0;
    color: #1e293b;
    font-size: 18px;
}

.risk-list, .failure-breakdown {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.risk-item, .failure-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.risk-item:last-child, .failure-item:last-child {
    border-bottom: none;
}

.risk-level {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.risk-level.high {
    background: #fee2e2;
    color: #dc2626;
}

.risk-level.medium {
    background: #fef3c7;
    color: #d97706;
}

.risk-level.low {
    background: #dcfce7;
    color: #16a34a;
}

.failure-percent {
    font-weight: 600;
    color: #1e293b;
}

.failure-item.success .failure-percent {
    color: #16a34a;
}

/* Scenarios Tab */
.scenario-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.scenario-card {
    border-radius: 8px;
    padding: 12px;
    color: white;
    position: relative;
    overflow: hidden;
}

.scenario-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
}

.scenario-card.danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.scenario-card.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.scenario-card.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.scenario-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.scenario-icon {
    font-size: 24px;
}

.scenario-title {
    font-size: 18px;
    font-weight: 600;
}

.scenario-content {
    position: relative;
    z-index: 1;
}

.scenario-metric {
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.scenario-metric .metric-label {
    font-size: 16px;
    opacity: 0.9;
}

.scenario-metric .metric-value {
    font-size: 16px;
    font-weight: 700;
}

/* Recommendations Tab */
.recommendations-grid {
    display: grid;
    gap: 24px;
}

.recommendation-section {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
}

.recommendation-section h4 {
    margin: 0 0 20px 0;
    font-size: 18px;
    color: #1e293b;
}

.recommendation-section.critical {
    border-left: 4px solid #ef4444;
    background: #fef2f2;
}

.recommendation-section.actions {
    border-left: 4px solid #3b82f6;
}

.recommendation-section.optimization {
    border-left: 4px solid #10b981;
}

.recommendation-section.improvements {
    border-left: 4px solid #8b5cf6;
}

.recommendation-item {
    margin-bottom: 16px;
    padding: 16px;
    border-radius: 8px;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.recommendation-item:last-child {
    margin-bottom: 0;
}

.recommendation-item.critical {
    border-left: 3px solid #ef4444;
}

.recommendation-text {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}

.recommendation-impact, 
.recommendation-benefit, 
.recommendation-detail {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 4px;
}

.recommendation-improvement {
    font-size: 14px;
    color: #10b981;
    font-weight: 600;
}

.improvement-change {
    font-weight: 600;
    color: #1e293b;
}

.improvement-benefit {
    font-size: 16px;
    color: #10b981;
    font-weight: 600;
}

/* Export Button */
.analysis-footer {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.analysis-params {
    font-size: 14px;
    color: #64748b;
}

.analysis-actions {
    display: flex;
    gap: 12px;
}

.export-btn, .new-simulation-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.export-btn {
    background: #f1f5f9;
    color: #475569;
}

.export-btn:hover {
    background: #e2e8f0;
}

.new-simulation-btn {
    background: #3b82f6;
    color: white;
}

.new-simulation-btn:hover {
    background: #2563eb;
}

/* Balance Trajectories Table */
.balance-trajectories-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 14px;
}

.balance-trajectories-table th,
.balance-trajectories-table td {
    text-align: right;
  
    border-bottom: 1px solid #eee;
}

.balance-trajectories-table th:first-child,
.balance-trajectories-table td:first-child {
    text-align: left;
}

.balance-trajectories-table th {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 1;
}

.balance-trajectories-table th:hover {
    background: linear-gradient(135deg, #5a6269 0%, #3d4449 100%);
}

.balance-trajectories-table th.sortable::after {
    content: " ↕";
    opacity: 0.7;
    color: white;
}

.balance-trajectories-table th.sorted-asc::after {
    content: " ↑";
    opacity: 1;
    color: white;
}

.balance-trajectories-table th.sorted-desc::after {
    content: " ↓";
    opacity: 1;
    color: white;
}

.balance-trajectories-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-top: 10px;
}

.trajectories-info {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .monte-carlo-analysis-overlay {
        padding: 10px;
    }
    
    .monte-carlo-analysis-modal {
        max-height: 95vh;
    }
    
    .analysis-header {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }
    
    .analysis-tabs {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .tab-button {
   
        font-size: 14px;
    }
    
    .analysis-content {
        padding: 20px;
    }
    
    .metric-grid {
        grid-template-columns: 1fr;
    }
    
    .risk-sections {
        grid-template-columns: 1fr;
    }
    
    .scenario-cards {
        grid-template-columns: 1fr;
    }
    
    .analysis-footer {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
}

/* Animations */
@keyframes slideInFromTop {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.monte-carlo-analysis-modal {
    animation: slideInFromTop 0.3s ease-out;
}

.tab-pane.active {
    animation: slideInFromTop 0.2s ease-out;
} 