/* Reset and base styles */
* {
    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%);
    color: #333;
    overflow-x: hidden;
}

/* Container setup for iframe compatibility */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 15px;
    gap: 10px;
}

/* Adjust height for full browser view */
@media (min-height: 600px) {
    .container {
        height: 90vh;
    }
}

/* Control panel styling */
.control-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    align-items: center;
    min-height: 60px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.control-group label {
    font-weight: 600;
    font-size: 12px;
    color: #555;
    white-space: nowrap;
}

/* Input styling for better touch/mouse interaction */
input[type="range"] {
    width: 120px;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: #2196F3;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    min-width: 100px;
}

select:hover, select:focus {
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* Checkbox group styling */
.checkbox-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.checkbox-group label:hover {
    background-color: rgba(33, 150, 243, 0.1);
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Chart container */
.chart-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 15px;
    position: relative;
    overflow: hidden;
}

#mainChart {
    flex: 1;
    cursor: crosshair;
    border-radius: 4px;
}

/* Legend styling */
.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 12px;
}

.legend-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.legend-item.inactive {
    opacity: 0.4;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Tooltip styling */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip.visible {
    opacity: 1;
}

.tooltip-content {
    text-align: center;
}

#tooltipTitle {
    font-weight: bold;
    margin-bottom: 4px;
}

#tooltipValue {
    font-size: 14px;
    color: #4CAF50;
}

#tooltipYear {
    font-size: 10px;
    color: #ccc;
    margin-top: 2px;
}

/* Info panel */
.info-panel {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.insight-card h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #333;
    text-align: center;
}

#insights {
    font-size: 11px;
    line-height: 1.4;
}

#insights p {
    margin-bottom: 4px;
    color: #666;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .control-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .control-group {
        justify-content: space-between;
    }
    
    .checkbox-group {
        justify-content: space-around;
    }
    
    .legend {
        gap: 10px;
    }
    
    .legend-item {
        font-size: 10px;
    }
}

/* Animation for smooth transitions */
.chart-container, .control-panel, .info-panel {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hover effects for better interaction feedback */
.control-group:hover {
    transform: translateY(-1px);
    transition: transform 0.2s;
}

/* Year display styling */
#yearDisplay {
    font-weight: bold;
    color: #2196F3;
    min-width: 40px;
    text-align: center;
}