:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --dark: #0f172a;
    --glass: rgba(255, 255, 255, 0.8);
    --glass-dark: rgba(15, 23, 42, 0.8);
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Outfit', sans-serif;
    color: var(--dark);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

header {
    height: 60px;
    background: #1e3a8a; /* Deep blue header like in screenshot */
    color: white;
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
    z-index: 1001;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-container h2 {
    margin: 0;
    font-size: 1.2rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

header nav a {
    color: white;
    text-decoration: none;
    margin-left: 20px;
    font-size: 0.9rem;
    opacity: 0.8;
}

main {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

#map {
    flex: 1;
    height: 100%;
    z-index: 1;
}

.sidebar {
    width: 350px;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e2e8f0;
    z-index: 1000;
    overflow: hidden; /* Prevent child overflow */
}

.sidebar-header {
    background: #f8fafc;
    padding: 0;
    border-bottom: 2px solid #3b82f6;
    display: flex;
    flex-direction: column;
}

.search-bar-wrapper {
    display: flex;
    align-items: center;
    padding: 12px 12px; /* Reduced padding */
    gap: 10px; /* Reduced gap */
    background: #e0f2fe;
    width: 100%;
    box-sizing: border-box;
}

.search-icon {
    color: #64748b;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.search-input-new {
    flex: 1;
    min-width: 0; /* Important: allow input to shrink */
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.95rem;
    color: #475569;
}

.header-actions {
    display: flex;
    gap: 8px; /* Reduced gap between icons */
    flex-shrink: 0;
}

.header-actions button {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.2s;
    padding: 5px;
}

.header-actions button:hover {
    color: var(--primary);
}

.filter-panel {
    padding: 15px;
    background: white;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid #e2e8f0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
}

.filter-select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    color: var(--dark);
    background: #f8fafc;
}

.filter-select:focus {
    border-color: var(--primary);
}

#sideContent {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.school-list, .school-detail {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: white;
}

.back-btn {
    background: #f1f5f9;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.back-btn:hover {
    background: #e2e8f0;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.detail-table tr {
    border-bottom: 1px solid #f1f5f9;
}

.detail-table th {
    text-align: left;
    padding: 10px 5px;
    color: #64748b;
    font-weight: 500;
    width: 40%;
    vertical-align: top;
}
.detail-section-title {
    background: #e0f2fe;
    color: #1e40af;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 800;
    margin: 20px 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-table td {
    padding: 10px 5px;
    color: #1e293b;
    font-weight: 600;
    width: 60%;
}

.school-item {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid #f1f5f9;
    cursor: pointer;
    transition: all 0.2s;
}

.school-item:hover {
    background: #f8fafc;
    border-color: var(--primary);
    transform: translateX(3px);
}

.school-item h4 {
    margin: 0 0 4px 0;
    font-size: 0.85rem;
    color: var(--dark);
    text-transform: uppercase;
}

.school-item .type-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f1f5f9;
    font-weight: 700;
}

.no-coords-badge {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #fee2e2;
    color: #ef4444;
    font-weight: 700;
    margin-left: 5px;
}

.stats-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 200px;
    background: #1e40af; /* Blue from screenshot */
    color: white;
    padding: 20px;
    border-radius: 4px;
    z-index: 1000;
    text-align: center;
}

.stats-panel .label {
    font-size: 0.7rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-transform: uppercase;
    opacity: 0.9;
}

.stats-panel .count {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.overlay {
    position: absolute;
    top: 20px;
    left: 370px; /* Offset for sidebar + social distancing */
    z-index: 1000;
}

.header-card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.header-card h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

.header-card p {
    margin: 5px 0 0;
    font-size: 0.85rem;
    opacity: 0.8;
}

.search-card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3);
    padding: 15px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.search-input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.1);
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chip {
    padding: 6px 14px;
    background: white;
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover, .chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.school-popup {
    font-family: 'Outfit', sans-serif;
}

.school-popup h3 {
    margin: 0 0 5px;
    color: var(--dark);
}

.school-popup p {
    margin: 0;
    font-size: 0.85rem;
    color: #64748b;
}

.school-popup .meta {
    margin-top: 5px;
    display: flex;
    gap: 10px;
}

/* Custom Markers */
.marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    position: absolute;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.marker-pin span {
    transform: rotate(45deg);
    color: white;
    font-size: 9px;
    font-weight: 800;
}

.pin-sd { background: #ef4444; } /* Red */
.pin-smp { background: #3b82f6; } /* Blue */
.pin-sma { background: #8b5cf6; } /* Purple */
.pin-smk { background: #f59e0b; } /* Orange */
.pin-other { background: #64748b; }

/* Legend Card */
.legend-card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3);
    padding: 15px;
    border-radius: 20px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.legend-title {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-transform: uppercase;
    opacity: 0.7;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    font-size: 0.8rem;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    background: #f1f5f9;
    color: #475569;
}

.admin-link {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--dark);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.admin-link:hover {
    transform: translateY(-2px);
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-container {
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    background: white;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    overflow: hidden;
}

.modal-header {
    padding: 15px 25px;
    border-bottom: 2px solid #3b82f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.modal-header h3 {
    margin: 0;
    color: #3b82f6;
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-close-modal {
    background: #94a3b8;
    color: white;
    border: none;
    padding: 8px 25px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-close-modal:hover {
    background: #64748b;
}

.modal-body {
    flex: 1;
    overflow: auto;
    padding: 20px;
}

.table-filter-bar {
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
}

.modal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.modal-table th {
    text-align: left;
    background: #f8fafc;
    padding: 12px 15px;
    border-bottom: 2px solid #e2e8f0;
    color: #64748b;
    font-weight: 600;
    position: sticky;
    top: -20px;
}

.modal-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

.school-thumb {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

/* Unify All Leaflet Controls */
.leaflet-control-zoom,
.leaflet-control-locate,
.leaflet-control-layers,
.custom-tools-wrapper {
    border: none !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
}

.leaflet-control-zoom a, 
.leaflet-control-locate a,
.leaflet-control-layers-toggle,
.toolbox-btn {
    background-color: white !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    color: #475569 !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    width: 38px !important;
    height: 38px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s !important;
    font-size: 1.2rem !important;
    text-decoration: none !important;
}

/* Specific fix for Layer Icon */
.leaflet-control-layers-toggle {
    background-image: url('https://unpkg.com/leaflet@1.9.4/dist/images/layers.png') !important;
    background-size: 20px 20px !important;
}

/* Ensure Locate icon is visible */
.leaflet-control-locate a span {
    font-size: 1.1rem !important;
}

/* Ensure Zoom text is visible */
.leaflet-control-zoom a {
    font-weight: bold !important;
}

/* Primary/Active Style for Toolbox */
.toolbox-btn {
    background: #3b82f6 !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3) !important;
}

.toolbox-btn.active {
    background: #1e40af !important;
}

/* Adjust Layer Control to look modern */
.leaflet-control-layers {
    border-radius: 12px !important;
    padding: 5px !important;
}

.leaflet-control-layers-expanded {
    background: white !important;
    padding: 15px !important;
    font-family: 'Outfit', sans-serif !important;
    border-radius: 12px !important;
}

/* Case for Toolbox Expansion */
.leaflet-pm-toolbar {
    position: absolute !important;
    left: 45px !important;
    bottom: 0px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-20px);
    z-index: 1000 !important;
}

.leaflet-pm-toolbar.expanded {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

/* Force horizontal layout for Geoman tools */
.leaflet-pm-toolbar .leaflet-buttons-control {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    border: none !important;
    background: transparent !important;
}

.leaflet-pm-toolbar .leaflet-buttons-control a {
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    background: white !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
}

.modal-table tr:hover {
    background: #f1f5f9;
}

.stats-panel .details-btn {
    cursor: pointer;
    text-decoration: underline;
    transition: opacity 0.2s;
}

.stats-panel .details-btn:hover {
    opacity: 1;
}
