/* Energy Explorer Frontend Styles - Enhanced & Polished */

/* Import Google Fonts for Premium Typography */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Poppins:wght@400;500;600;700&family=Roboto:wght@400;500;700&display=swap');

/* CSS Variables for Customization */
.energy-explorer-wrapper {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --primary-light: #5dade2;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --background: #f4f7f6;
    --card-bg: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e2e8f0;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Wrapper */
.energy-explorer-wrapper {
    position: relative;
    margin: 0 auto;
    transition: var(--transition);
}

/* Fullscreen Button */
.fullscreen-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10001;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.fullscreen-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.fullscreen-btn svg {
    display: block;
}

/* Fullscreen Mode */
.energy-explorer-wrapper.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.energy-explorer-wrapper.fullscreen .fullscreen-btn {
    background: rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
    backdrop-filter: blur(10px);
}

.energy-explorer-wrapper.fullscreen .fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: var(--primary-color);
}

/* Container */
.energy-explorer-container {
    display: flex;
    height: 100%;
    background: var(--background);
    overflow: hidden;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

/* Map Section */
.map-section {
    flex: 1;
    position: relative;
    background: #e2e8f0;
    overflow-y: auto;
}

.energy-map {
    width: 100%;
    height: 100%;
    min-height: 500px;
    background: #cbd5e1;
}

.map-helper {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    z-index: 1000;
    pointer-events: none;
    max-width: 300px;
}

/* Details Panel */
.details-panel {
    width: 400px;
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 20px;
    gap: 20px;
}

/* Controls */
.controls-section {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.control-group {
    margin-bottom: 15px;
}

.control-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.year-slider,
.metric-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--card-bg);
    transition: var(--transition);
}

.metric-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.year-slider {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: linear-gradient(to right, var(--primary-color) 0%, var(--primary-color) 50%, var(--border-color) 50%, var(--border-color) 100%);
    outline: none;
    border-radius: 3px;
    padding: 0;
}

.year-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

.year-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.year-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

.year-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Country Header */
.country-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.country-flag {
    width: 50px;
    height: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.country-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

/* Stats */
.stats-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card.highlight {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    text-align: center;
    border-color: var(--primary-light);
}

.stat-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    display: block;
    font-size: 32px;
    font-weight: 800;
    color: var(--primary-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 15px;
}

.stat-item h4 {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 0 0 6px 0;
    font-weight: 600;
}

.stat-item .stat-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Charts */
.charts-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 15px;
    transition: var(--transition);
}

.chart-card:hover {
    box-shadow: var(--shadow-md);
}

.chart-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.chart-wrapper {
    position: relative;
    height: 200px;
}

/* Description */
.description {
    background: #f8fafc;
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    border-radius: var(--radius-sm);
}

.description p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    margin-top: 15px;
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 900px) {
    .energy-explorer-container {
        flex-direction: column;
    }

    .details-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
        order: 1;
    }

    .map-section {
        order: 2;
        min-height: 400px;
    }

    .energy-map {
        min-height: 400px;
    }

    .map-helper {
        font-size: 12px;
        padding: 10px 12px;
    }

    .fullscreen-btn {
        top: 10px;
        right: 10px;
        padding: 10px;
    }
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .details-panel {
        padding: 15px;
    }

    .country-header h2 {
        font-size: 20px;
    }

    .stat-card .stat-value {
        font-size: 24px;
    }
}

/* Leaflet Overrides */
.energy-explorer-wrapper .leaflet-container {
    background: #cbd5e1;
    font-family: inherit;
}

.energy-explorer-wrapper .leaflet-popup-content-wrapper {
    border-radius: var(--radius-sm);
}

.energy-explorer-wrapper .leaflet-popup-content {
    font-size: 13px;
}

/* Smooth Animations */
.stat-card,
.chart-card,
.control-group,
.country-header {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}