:root {
    --primary-color: #2563eb;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --bg-sidebar: #f8fafc;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --font-family: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-family);
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
    display: flex;
}

#app {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Map Section */
#map-container {
    flex: 0 0 75%;
    position: relative;
    height: 100%;
}

#map {
    width: 100%;
    height: 100%;
    background: #cad2d3; /* Neutral map background */
    z-index: 1;
}

/* Controls Overlay */
#map-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.control-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-light);
}

.mode-buttons {
    display: flex;
    gap: 4px;
}

.mode-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.mode-btn:hover {
    background: #f1f5f9;
}

.mode-btn.active {
    background: var(--text-dark);
    color: white;
    border-color: var(--text-dark);
}

/* Legend */
.legend {
    position: absolute;
    bottom: 30px;
    right: 30px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    min-width: 150px;
}

/* Postcode Search */
.map-search {
    position: absolute;
    bottom: 30px;
    left: 30px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    min-width: 180px;
}

.map-search label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-light);
}

.map-search .search-row {
    display: flex;
    gap: 6px;
}

.map-search input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
}

.map-search button {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

.map-search button:hover {
    background: #f1f5f9;
}

.search-status {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-light);
}

.legend h4 {
    margin-bottom: 10px;
    font-size: 0.9rem;
    font-weight: 600;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    font-size: 0.85rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Sidebar Section */
#sidebar {
    flex: 0 0 25%;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    background: white;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.sidebar-header p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.sidebar-content {
    padding: 24px;
}

.filter-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.filter-section h3, .details-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group {
    margin-bottom: 16px;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dark);
}

select, input[type="range"] {
    width: 100%;
}

select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    background-color: white;
}

/* Details Panel */
.details-panel {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    min-height: 200px;
}

.placeholder-text {
    color: var(--text-light);
    font-style: italic;
    text-align: center;
    margin-top: 40px;
    font-size: 0.9rem;
}

.detail-stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
}

.detail-stat span:first-child {
    color: var(--text-light);
}

.detail-stat span:last-child {
    font-weight: 600;
}

.stat-high { color: #dc2626; }
.stat-med { color: #d97706; }
.stat-low { color: #16a34a; }
.stat-na { color: #9ca3af; }

/* Responsive */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    
    #map-container {
        flex: 1; 
        min-height: 50vh;
    }
    
    #sidebar {
        flex: 1;
        max-height: 50vh;
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
}

/* CSS for map labels */
.map-label {
    font-size: 10px;
    font-weight: bold;
    color: #333;
    text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff;
    text-align: center;
    white-space: nowrap;
}
.map-label { pointer-events: none; }

/* Borough Labels */
.borough-label {
    font-size: 14px;
    font-weight: 800;
    color: #1f2937;
    text-transform: uppercase;
    text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
    text-align: center;
    white-space: nowrap;
    opacity: 0.8;
}
