/* Green City Index - Main Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: #f5f5f5;
}

/* Header */
header {
    background: #2d5a27;
    color: white;
    padding: 1rem 2rem;
}

.header-nav {
    margin-bottom: 0.5rem;
}

.header-nav .nav-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.875rem;
    margin-right: 1.5rem;
}

.header-nav .nav-link:hover,
.header-nav .nav-link.active {
    color: white;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

header p {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

/* Main Layout */
main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
#sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    padding: 1rem;
}

#sidebar section {
    margin-bottom: 1.5rem;
}

#sidebar h2 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* City Selector */
#country-select,
#city-select {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.875rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
}

#country-select {
    margin-bottom: 0.5rem;
}

/* Year Selector */
.year-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#year-select {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.875rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
}

#play-pause-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

#play-pause-btn:hover:not(:disabled) {
    background: #f0f0f0;
    border-color: #2d5a27;
}

#play-pause-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#play-pause-btn.playing .play-icon {
    display: none;
}

#play-pause-btn.playing .pause-icon {
    display: inline;
}

/* Layer Controls */
#layer-controls label {
    display: block;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.875rem;
}

#layer-controls label:hover {
    background: #f0f0f0;
}

#layer-controls input[type="radio"] {
    margin-right: 0.5rem;
}

/* Stats */
#stats-content {
    font-size: 0.875rem;
    color: #666;
}

#stats-content .stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

#stats-content .stat-row:last-child {
    border-bottom: none;
}

#stats-content .stat-label {
    color: #666;
}

#stats-content .stat-value {
    font-weight: 600;
    color: #333;
}

.delta-positive {
    color: #2d5a27;
    font-weight: 500;
}

.delta-negative {
    color: #c62828;
    font-weight: 500;
}

/* Legend */
.legend-note {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-style: italic;
}

.legend-scale {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.legend-item {
    display: flex;
    align-items: center;
    padding: 0.35rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Map */
#map {
    flex: 1;
    min-height: 400px;
}

/* Footer */
footer {
    background: #333;
    color: #999;
    padding: 0.75rem 2rem;
    font-size: 0.75rem;
    text-align: center;
}

footer a {
    color: #aaa;
}

footer a:hover {
    color: white;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

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

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #eee;
    border-top-color: #2d5a27;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading-message {
    color: #666;
    font-size: 0.875rem;
}

/* Error Message */
#error-message {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: #d32f2f;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: opacity 0.3s ease;
}

#error-message.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
    opacity: 0;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-info {
    background: #333;
    color: white;
}

.toast-success {
    background: #2d5a27;
    color: white;
}

.toast-warning {
    background: #f57c00;
    color: white;
}

/* Tile Loading Indicator */
.tiles-loading #map::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid rgba(45, 90, 39, 0.3);
    border-top-color: #2d5a27;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 1000;
    pointer-events: none;
}

/* About/Methodology Page */
.note {
    background: #f0f7ef;
    border-left: 3px solid #2d5a27;
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: #555;
}

.section table td em {
    font-style: italic;
    color: #2d5a27;
}

/* Responsive */
@media (max-width: 768px) {
    main {
        flex-direction: column-reverse;
    }
    
    #sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-top: 1px solid #ddd;
    }
    
    #map {
        min-height: 300px;
    }
    
    .toast {
        left: 1rem;
        right: 1rem;
        transform: translateY(100px);
    }
    
    .toast.show {
        transform: translateY(0);
    }
}
