:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --warehouse-color: #ef4444;
    --school-in-color: #10b981;
    --school-out-color: #64748b;
    --radius-fill: rgba(59, 130, 246, 0.2);
    --radius-border: #3b82f6;
    --font-family: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Typography */
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; }
h3 { font-size: 0.875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
p.subtitle { color: var(--text-secondary); font-size: 0.875rem; margin-top: 0.25rem; }

/* Glass Panels */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--panel-border);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
}

.glass-panel-sm {
    background: var(--panel-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* Sidebar */
.sidebar {
    width: 320px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    z-index: 1000; /* Above map */
    position: relative;
    gap: 1rem;
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--panel-border);
    border-radius: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-color);
}
.logo i {
    font-size: 1.25rem;
}
.logo h1 {
    color: var(--text-primary);
}

/* Controls */
.control-group {
    display: flex;
    flex-direction: column;
}

.custom-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2394a3b8%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem top 50%;
    background-size: 0.65rem auto;
}
.custom-select:hover, .custom-select:focus {
    border-color: var(--accent-color);
}
.custom-select option {
    background-color: var(--bg-color);
}

/* Warehouse Checklist */
.warehouse-checklist-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 180px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 0.5rem;
}

.warehouse-checklist-container::-webkit-scrollbar {
    width: 4px;
}
.warehouse-checklist-container::-webkit-scrollbar-thumb {
    background: var(--panel-border);
    border-radius: 4px;
}

.warehouse-check-item {
    padding: 0.5rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.2s;
}
.warehouse-check-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}
.warehouse-check-item.active {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
}

.warehouse-check-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.warehouse-checkbox {
    margin-top: 0.2rem;
    accent-color: var(--accent-color);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.warehouse-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    line-height: 1.4;
    flex-grow: 1;
}

/* Inline Slider */
.inline-slider-container {
    display: none; /* Hidden by default until checked */
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.25rem;
    padding-left: 1.75rem; /* Indent to align with text */
}
.warehouse-check-item.active .inline-slider-container {
    display: flex;
}

.inline-slider-container input[type=range] {
    flex-grow: 1;
}
.inline-slider-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-color);
    min-width: 45px;
    text-align: right;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    margin-top: -8px;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    transition: transform 0.1s;
}
input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: var(--panel-border);
    border-radius: 2px;
}
.slider-value {
    text-align: right;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}
.slider-value span {
    color: var(--accent-color);
}

/* Stats */
.stats-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.stat-card {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}
.school-icon {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.stat-info h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

/* Report Section */
.report-section {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.report-header h3 {
    margin-bottom: 0;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:disabled {
    background: var(--panel-border);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.school-list-container {
    max-height: 180px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 0.5rem;
}

.school-list-container::-webkit-scrollbar {
    width: 4px;
}
.school-list-container::-webkit-scrollbar-thumb {
    background: var(--panel-border);
    border-radius: 4px;
}

.school-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.school-item {
    padding: 0.5rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    transition: all 0.2s;
}

.school-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.school-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.school-dist {
    font-size: 0.75rem;
    color: var(--accent-color);
    font-weight: 500;
}

.empty-state {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Map Section */
.map-section {
    flex-grow: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    background: #0f172a; /* Fallback */
    z-index: 1;
}

.map-legend {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.25rem;
    z-index: 1000;
}

.map-legend h4 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}
.legend-item:last-child {
    margin-bottom: 0;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.warehouse-color { background-color: var(--warehouse-color); border: 2px solid white; box-shadow: 0 0 8px var(--warehouse-color); }
.school-in-color { background-color: var(--school-in-color); border: 2px solid white; box-shadow: 0 0 8px var(--school-in-color); }
.school-out-color { background-color: var(--school-out-color); border: 2px solid white;}

/* Custom Map Marker styles override */
.custom-div-icon {
    background: transparent;
    border: none;
}
.marker-pin {
    width: 24px;
    height: 24px;
    border-radius: 50% 50% 50% 0;
    background: var(--accent-color);
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -15px 0 0 -15px;
    border: 2px solid #fff;
    box-shadow: 0 3px 10px rgba(0,0,0,0.5);
}
.marker-pin::after {
    content: '';
    width: 10px;
    height: 10px;
    margin: 5px 0 0 5px;
    background: #fff;
    position: absolute;
    border-radius: 50%;
}
.warehouse-marker .marker-pin { background: var(--warehouse-color); }
.school-in-marker .marker-pin { background: var(--school-in-color); }
.school-out-marker .marker-pin { background: var(--school-out-color); width: 16px; height: 16px; margin: -11px 0 0 -11px; }
.school-out-marker .marker-pin::after { width: 6px; height: 6px; margin: 3px 0 0 3px; }

/* Dark mode overrides for Leaflet */
.leaflet-container .leaflet-control-attribution {
    background: rgba(15, 23, 42, 0.7);
    color: var(--text-secondary);
}
.leaflet-container .leaflet-control-attribution a {
    color: var(--accent-color);
}
.leaflet-bar a, .leaflet-bar a:hover {
    background-color: var(--panel-bg);
    color: var(--text-primary);
    border-bottom: 1px solid var(--panel-border);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
    }
    .map-section {
        height: 50vh;
    }
    .map-legend {
        bottom: 1rem;
        right: 1rem;
    }
}
