:root {
    --primary-color: #007aff;
    --bg-dark: #0a0a0c;
    --panel-bg: rgba(20, 20, 25, 0.8);
    --text-main: #ffffff;
    --text-dim: #a0a0a5;
    --accent-glow: rgba(0, 122, 255, 0.4);
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    outline: none; /* Hide focus ring */
}

.leaflet-interactive {
    outline: none; /* Hide focus ring on shapes */
}

/* Glassmorphism Panel */
.ui-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    width: 320px;
    padding: 24px;
    background: var(--panel-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
}

header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, #007aff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    margin: 4px 0 20px 0;
    font-size: 13px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stats-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.stat-item:last-child { margin-bottom: 0; }

.stat-item .label {
    font-size: 12px;
    color: var(--text-dim);
}

.stat-item .value {
    font-size: 14px;
    font-weight: 600;
    color: #ffd700; /* Gold for area values */
}

/* Custom Select Redesign */
.search-container {
    position: relative;
    width: 100%;
}

.custom-select {
    position: relative;
    width: 100%;
    user-select: none;
}

.select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.select-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
}

.custom-select.active .select-trigger {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.select-trigger .arrow {
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    transition: transform 0.3s ease;
}

.custom-select.active .arrow {
    transform: rotate(180deg);
}

.select-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--panel-bg);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 2000;
    display: none;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.custom-select.active .select-options {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.select-options .option {
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.select-options .option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.select-options .option.selected {
    background: var(--primary-color);
    color: white;
}

/* Custom Scrollbar for Dropdown */
.select-options::-webkit-scrollbar {
    width: 6px;
}
.select-options::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

/* Mobile Responsive Refinements */
@media (max-width: 768px) {
    .ui-panel {
        top: auto;
        bottom: 20px;
        left: 15px;
        right: 15px;
        width: auto;
        padding: 18px;
        border-radius: 16px;
    }

    header {
        display: flex;
        align-items: baseline;
        gap: 8px;
        margin-bottom: 12px;
    }

    header h1 { font-size: 18px; margin: 0; }
    header p { 
        display: block !important; 
        font-size: 10px; 
        margin: 0;
        opacity: 0.7;
        letter-spacing: 0;
    }
    
    .stats-card {
        padding: 10px;
        margin-bottom: 15px;
        display: flex;
        justify-content: space-between;
        background: rgba(255,255,255,0.03);
    }

    .stat-item {
        margin-bottom: 0;
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-item .label { font-size: 10px; }
    .stat-item .value { font-size: 12px; }

    .search-container select {
        padding: 8px 12px;
        font-size: 13px;
    }

    .info-text { display: none; } /* Hide info text on mobile */

    /* Custom Select Mobile Overrides: Expand UPWARDS */
    .select-options {
        top: auto;
        bottom: calc(100% + 8px);
        max-height: 200px;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.6);
    }

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

    /* Move Leaflet controls out of the way of the bottom panel */
    .leaflet-bottom.leaflet-right {
        bottom: 140px !important;
    }
}

/* Tooltip Styles */
.area-tooltip {
    text-align: center;
    pointer-events: none;
}

.area-tooltip .name {
    font-weight: 600;
    font-size: 13px;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    background: rgba(0,0,0,0.4);
    padding: 2px 6px;
    border-radius: 4px;
}

.area-tooltip .area {
    font-size: 10px;
    color: #ffd700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.leaflet-tooltip {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Permanent Province Labels (Redesigned for Minimalism) */
.permanent-province-tooltip {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

.province-badge {
    pointer-events: none;
    text-align: center;
    background: transparent; /* No more bulky box */
    padding: 0;
    transition: all 0.3s ease;
}

.province-badge .p-name {
    font-weight: 600;
    font-size: 11px; /* Smaller font */
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-shadow: 0 0 4px rgba(0,0,0,1), 0 0 8px rgba(0,0,0,0.8);
}

.province-badge .p-area {
    font-size: 8px; /* Micro area text */
    font-weight: 400;
    color: #ffd700;
    margin-top: -1px;
    text-shadow: 0 0 3px rgba(0,0,0,1);
    opacity: 0.8;
}

/* Hide area when zoomed out very far to declutter */
.map-zoomed-out .province-badge .p-area {
    display: none;
}

/* Custom Loader */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loader {
    width: 48px;
    height: 48px;
    border: 3px solid #FFF;
    border-bottom-color: var(--primary-color);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
