/* City Builder - Stylesheet */

:root {
    --primary: #00aa7c;
    --primary-dark: #008f69;
    --primary-light: #00d498;
    --primary-glow: rgba(0, 170, 124, 0.15);
    --natural: #00a854;
    --produced: #7c3aed;
    --human: #f97316;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-dark);
    line-height: 1.6;
    overflow: hidden;
    background: var(--bg-light);
}

/* Main Layout */
main {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

aside {
    background: var(--bg-white);
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(0, 170, 124, 0.03) 0%, transparent 30%),
        radial-gradient(circle at 80% 60%, rgba(0, 170, 124, 0.02) 0%, transparent 25%);
    padding: 1.25rem;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

#controls {
    width: 400px;
    border-right: 1px solid var(--border);
}

#map {
    flex: 1;
    background: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 100%);
    position: relative;
}

#info {
    width: 420px;
    border-left: 1px solid var(--border);
    font-size: 0.75rem;
}

#info h2 {
    font-size: 0.95rem;
}

#info h3 {
    font-size: 0.85rem;
}

#info p {
    font-size: 0.75rem;
    line-height: 1.5;
}

#info ul {
    font-size: 0.75rem;
}

#info li {
    margin-bottom: 0.5rem;
}

/* Custom Scrollbar */
aside::-webkit-scrollbar {
    width: 6px;
}

aside::-webkit-scrollbar-track {
    background: var(--bg-light);
}

aside::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

aside::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Sidebar Title */
.sidebar-title {
    color: var(--primary);
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Language Toggle */
.language-toggle {
    display: flex;
    gap: 0.15rem;
    background: var(--bg-light);
    padding: 0.2rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.lang-btn {
    padding: 0.25rem 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
    min-width: 32px;
}

.lang-btn:hover {
    background: var(--primary-glow);
    color: var(--primary);
}

.lang-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 3px rgba(0, 170, 124, 0.3);
}

/* Typography */
h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

h2:first-of-type {
    margin-top: 0;
}

h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
}

/* Slider Group */
.slider-group {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.slider-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.slider-item label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dark);
}

.slider-label {
    color: var(--text-dark);
}

.slider-value-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.slider-emoji {
    font-size: 1.1rem;
    transition: transform 0.2s;
}

.slider-value {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
    min-width: 42px;
    text-align: right;
}

.slider-description {
    font-size: 0.7rem;
    color: #64748b;
    margin: 0.25rem 0 0.35rem 0;
    line-height: 1.2;
    font-style: italic;
}

.slider-hints {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    margin-top: 0.2rem;
    padding: 0 0.25rem;
    font-weight: 500;
}

/* Range Slider Styling */
.slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #dc2626 0%, #fbbf24 50%, #16a34a 100%);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    border: 1px solid var(--border);
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 170, 124, 0.3);
    transition: all 0.2s;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 170, 124, 0.3);
    transition: all 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 170, 124, 0.4);
}

.slider::-moz-range-thumb:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 170, 124, 0.4);
}

/* Color-coded sliders */
.natural-slider::-webkit-slider-thumb {
    background: var(--natural);
}

.natural-slider::-moz-range-thumb {
    background: var(--natural);
}

.produced-slider::-webkit-slider-thumb {
    background: var(--produced);
}

.produced-slider::-moz-range-thumb {
    background: var(--produced);
}

.human-slider::-webkit-slider-thumb {
    background: var(--human);
}

.human-slider::-moz-range-thumb {
    background: var(--human);
}

/* Search Button */
.search-button {
    width: 100%;
    padding: 0.85rem;
    margin-top: 0.8rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 170, 124, 0.2);
}

.search-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 170, 124, 0.3);
}

.search-button:active {
    transform: translateY(0);
}

.search-button.needs-update {
    background: #f97316;
    animation: pulse 2s infinite;
}

.search-button.needs-update:hover {
    background: #ea580c;
}

.search-button.calculating {
    background: var(--primary-dark);
    cursor: wait;
}

.button-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 2px 4px rgba(249, 115, 22, 0.2);
    }
    50% {
        box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
    }
}

/* Layer Selection */
.layer-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.layer-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.layer-checkbox:hover {
    background-color: #f8f9fa;
}

.layer-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 0.75rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.layer-checkbox span {
    color: #1e293b;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Map Loading Overlay */
.map-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000 !important;
    transition: opacity 0.3s ease-in-out;
}

.map-loading-overlay.hidden {
    display: none !important;
}

/* City Labels */
.city-label {
    background: transparent;
    border: none;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    text-shadow: 
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff,
        0 0 4px rgba(255, 255, 255, 0.9);
    pointer-events: none;
}

.city-label.provincial {
    color: #ff006e;
    font-size: 0.8rem;
}

.city-label.national {
    color: #d4af37;
    font-size: 1rem;
    font-weight: 800;
}

/* Links */
.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-dark);
    background: var(--bg-light);
    border: 1px solid var(--border);
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.sidebar-link:hover {
    background: var(--primary-glow);
    border-color: var(--primary-light);
    color: var(--primary);
    transform: translateX(-2px);
}

.sidebar-link svg {
    flex-shrink: 0;
}

/* Loading Screen */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s;
}

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

.loader-container {
    position: relative;
    width: 80px;
    height: 80px;
}

.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
    border: 4px solid var(--bg-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 2;
}

.loader-rings {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    margin: -40px 0 0 -40px;
}

.ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid transparent;
    border-top-color: var(--primary);
    border-radius: 50%;
    opacity: 0.3;
}

.ring:nth-child(1) {
    animation: spin 2s linear infinite;
}

.ring:nth-child(2) {
    animation: spin 3s linear infinite reverse;
    border-top-color: #00d498;
}

.ring:nth-child(3) {
    animation: spin 4s linear infinite;
    border-top-color: #008f69;
}

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

#loading p {
    margin-top: 1rem;
    color: var(--text-light);
    font-weight: 500;
}

/* Leaflet customization */
.leaflet-container {
    background: #e0f2fe;
    font-family: inherit;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    padding: 0;
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    margin: 1rem;
    font-size: 0.9rem;
    line-height: 1.6;
}

.leaflet-popup-tip {
    box-shadow: var(--shadow);
}

/* City circle styling */
.city-circle {
    fill: var(--primary);
    fill-opacity: 0.25;
    stroke: var(--primary);
    stroke-width: 2;
    stroke-opacity: 0.8;
    transition: all 0.3s ease;
}

.city-circle:hover {
    fill-opacity: 0.35;
    stroke-width: 3;
    stroke-opacity: 1;
}

/* Province boundaries */
.province-boundary {
    fill: none;
    stroke: var(--text-dark);
    stroke-width: 2;
    stroke-opacity: 0.5;
    pointer-events: none;
}

/* Tooltip */
.leaflet-tooltip {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    line-height: 1.6;
}

.leaflet-tooltip strong {
    color: var(--primary);
    display: block;
    margin-bottom: 0.25rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    #controls,
    #info {
        width: 280px;
    }
}

@media (max-width: 900px) {
    aside {
        width: 100%;
        height: auto;
        max-height: 40vh;
        border: none;
        border-bottom: 1px solid var(--border);
    }
    
    main {
        flex-direction: column;
    }
    
    #controls {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    #info {
        display: none;
    }
    
    #map {
        height: 60vh;
    }
}

/* Utility classes */
.hidden {
    display: none !important;
}

