/* Reset and base styles for iframe compatibility */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 450px; /* Default iframe height */
    overflow: hidden;
}

/* Responsive height adjustment */
@media (min-width: 768px) and (min-height: 600px) {
    body {
        height: 90vh;
    }
}

/* Main container with flexbox layout */
.container {
    display: flex;
    height: 100%;
    width: 100%;
    gap: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

/* Control Panel Styles */
.control-panel {
    flex: 0 0 280px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Factor Group Styling */
.factor-group {
    border-radius: 8px;
    padding: 12px;
    transition: all 0.3s ease;
    border-left: 4px solid;
}

.factor-group.trigger {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    border-left-color: #c44569;
    color: white;
}

.factor-group.contributory {
    background: linear-gradient(135deg, #4834d4, #686de0);
    border-left-color: #30336b;
    color: white;
}

.factor-group.underlying {
    background: linear-gradient(135deg, #00d2d3, #54a0ff);
    border-left-color: #2ed573;
    color: white;
}

.factor-group:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Factor Header */
.factor-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 14px;
}

.category-icon {
    font-size: 16px;
}

/* Slider Container */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-container label {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.9;
}

/* Custom Slider Styles */
.factor-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    outline: none;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.factor-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.factor-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.slider-value {
    align-self: flex-end;
    font-size: 12px;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 10px;
}

/* Analyze Button */
.analyze-btn {
    background: linear-gradient(135deg, #ff9ff3, #f368e0);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(243, 104, 224, 0.3);
}

.analyze-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(243, 104, 224, 0.4);
}

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

/* Visualization Panel */
.visualization-panel {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Probability Meter */
.probability-meter {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 8px;
    padding: 15px;
    color: white;
}

.meter-header {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
}

.meter-container {
    position: relative;
}

.meter-bar {
    background: rgba(255, 255, 255, 0.2);
    height: 30px;
    border-radius: 15px;
    position: relative;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #2ed573, #ffa502, #ff6348);
    border-radius: 15px;
    transition: width 0.8s ease;
    width: 72%;
}

.meter-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    font-size: 16px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Timeline Visualization */
.timeline-container {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
}

.timeline-header {
    font-weight: 600;
    margin-bottom: 12px;
    color: #2c3e50;
    font-size: 14px;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.timeline-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.underlying-dot { background: #00d2d3; }
.contributory-dot { background: #4834d4; }
.trigger-dot { background: #ff6b6b; }

.timeline-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    font-size: 12px;
}

.timeline-year {
    font-weight: 600;
    color: #7f8c8d;
    min-width: 60px;
}

.timeline-label {
    flex: 1;
    color: #2c3e50;
}

.timeline-impact {
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    background: #ecf0f1;
    color: #2c3e50;
}

/* Impact Chart */
.impact-chart {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
}

.chart-header {
    font-weight: 600;
    margin-bottom: 12px;
    color: #2c3e50;
    font-size: 14px;
}

.chart-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chart-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bar-fill {
    height: 20px;
    border-radius: 10px;
    transition: width 0.8s ease;
    flex: 1;
    position: relative;
}

.trigger-fill { background: linear-gradient(90deg, #ff6b6b, #ee5a24); }
.contributory-fill { background: linear-gradient(90deg, #4834d4, #686de0); }
.underlying-fill { background: linear-gradient(90deg, #00d2d3, #54a0ff); }

.bar-label {
    min-width: 80px;
    font-size: 12px;
    font-weight: 500;
    color: #2c3e50;
}

/* Scenario Analysis */
.scenario-analysis {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    border-radius: 8px;
    padding: 15px;
    color: white;
}

.scenario-header {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
}

.scenario-content {
    font-size: 12px;
    line-height: 1.5;
    opacity: 0.9;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        gap: 10px;
        padding: 8px;
    }
    
    .control-panel {
        flex: 0 0 auto;
        max-height: 180px;
    }
    
    .factor-group {
        padding: 8px;
    }
    
    .visualization-panel {
        flex: 1;
        min-height: 0;
    }
    
    .timeline {
        flex-direction: row;
        overflow-x: auto;
        gap: 15px;
    }
    
    .timeline-item {
        flex-direction: column;
        min-width: 80px;
        text-align: center;
    }
    
    .timeline-content {
        flex-direction: column;
        gap: 4px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) {
    .factor-slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    .analyze-btn {
        padding: 15px 20px;
        font-size: 16px;
    }
}