/* Delaware Districts & Schools Explorer Styles */
.districts-schools-explorer {
    font-family: 'DM Sans', sans-serif;
    margin: 0;
    padding: 0;
    
    /* District Map Colors */
    --district-hover-fill: #245194;
    --district-hover-stroke: #1a3a6b;
    --district-selected-fill: #ff6b6b;
    --district-selected-stroke: #e74c3c;
    --district-default-stroke: #3b6a92;
}

/* Site chrome (page title h1 uses shared main#main-content h1 in styles.css) */
.districts-schools-explorer .site-chrome.container {
    max-width: 100%;
    margin: 0 auto 20px auto;
    padding: 30px;
}

.districts-schools-explorer .district-pane .pane-content {
    container-type: inline-size;
    container-name: district-pane;
}

.districts-schools-explorer #districtsList {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

@container district-pane (max-width: 960px) {
    .districts-schools-explorer #districtsList {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Three-pane layout */
.districts-schools-explorer .three-pane-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    gap: 10px;
    padding: 10px 0;
    background: #f5f7fb;
}

.districts-schools-explorer .top-section {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    min-height: 500px;
}

.districts-schools-explorer .bottom-section {
    display: flex;
    flex-direction: row;
    gap: 10px;
    min-height: 300px;
}

.districts-schools-explorer .pane {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

.districts-schools-explorer .district-pane {
    width: 66%;
    min-width: 250px;
    display: flex;
    flex-direction: column;
}

.districts-schools-explorer .map-pane {
    flex: 1;
    min-width: 400px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 12px;
    align-self: flex-start;
}

.districts-schools-explorer .school-pane {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.districts-schools-explorer .school-list-pane {
    width: 50%;
    display: flex;
    flex-direction: column;
}

.districts-schools-explorer .school-map-pane {
    width: 50%;
    display: flex;
    flex-direction: column;
}

.districts-schools-explorer .pane-header {
    background: #245194;
    color: white;
    font-family: 'Domine', serif;
    padding: 15px 20px;
    font-weight: bold;
    font-size: 1.7em;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    gap: 8px;
}

.districts-schools-explorer .pane-header svg {
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
}

/* When pane-header contains a button or year picker, use space-between layout */
.districts-schools-explorer .pane-header:has(button),
.districts-schools-explorer .pane-header:has(.pane-year-picker),
.districts-schools-explorer .school-map-pane .pane-header {
    justify-content: space-between;
}

.districts-schools-explorer .pane-header:has(.pane-year-picker) {
    flex-wrap: wrap;
    row-gap: 8px;
}

.districts-schools-explorer .pane-header .pane-header-title {
    display: inline-flex;
    align-items: center;
}

/* Year picker inside a pane header (right of the heading) */
.districts-schools-explorer .pane-header .pane-year-picker {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.55em;
    font-weight: normal;
}

.districts-schools-explorer .pane-header .pane-year-picker label {
    display: inline;
    margin: 0;
    font-weight: normal;
    color: #fff;
}

.districts-schools-explorer .pane-header .pane-year-picker select {
    font-family: inherit;
    font-size: 14px;
    font-weight: normal;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #bdc3c7;
    background: #fff;
    color: #2c3e50;
    cursor: pointer;
}

/* Zoom to Schools Button */
.districts-schools-explorer .zoom-to-schools-btn {
	background: #3498db;
	color: white;
	border: none;
	padding: 8px 16px;
	border-radius: 5px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.3s ease;
	display: flex;
	align-items: center;
	gap: 6px;
	font-family: 'DM Sans', sans-serif;
}

.districts-schools-explorer .zoom-to-schools-btn:hover {
	background: #2980b9;
	transform: translateY(-1px);
	box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.districts-schools-explorer .zoom-to-schools-btn:active {
	transform: translateY(0);
}

.districts-schools-explorer .home-icon {
    position: absolute;
    left: 20px;
    color: white !important;
    text-decoration: none;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.districts-schools-explorer .home-icon:hover {
    color: #e3f2fd;
    transform: scale(1.1);
}

.districts-schools-explorer .home-icon svg {
    width: 20px;
    height: 20px;
}

.districts-schools-explorer .pane-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* District summary styles */
.districts-schools-explorer .district-summary {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 15px;
    margin-bottom: 10px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9fa;
    vertical-align: top;
    box-sizing: border-box;
}

.districts-schools-explorer .district-summary:nth-child(odd) {
    margin-right: 10px;
}

.districts-schools-explorer .district-summary:hover,
.districts-schools-explorer .district-summary.hovered {
    border-color: #245194;
    background: #e3f2fd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.districts-schools-explorer .district-summary.selected {
    border-color: #e74c3c;
    background: #ffebee;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.districts-schools-explorer .district-name {
    font-weight: bold;
    font-size: clamp(0.875rem, 0.65rem + 0.8vw, 1.1rem);
    font-size: clamp(0.875rem, 0.65rem + 1.5cqw, 1.1rem);
    color: #2c3e50;
    margin-bottom: 5px;
}

.districts-schools-explorer .district-stats {
    font-size: 0.9em;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.districts-schools-explorer .district-info {
    font-size: 0.85em;
    color: var(--color-text-muted);
}

.districts-schools-explorer .district-links {
    margin-top: auto;
    padding-top: 8px;
}

.districts-schools-explorer .report-card-link {
    display: inline-block;
    background: #245194;
    color: white;
    padding: 6px 12px;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    transition: background 0.2s ease;
}

.districts-schools-explorer .report-card-link:hover {
    background: #1a3a6b;
    color: white;
    text-decoration: none;
}

/* District map container styles */
.districts-schools-explorer #districtMapContainer {
    flex: 1;
    display: none;
    justify-content: center;
    align-items: flex-start;
    min-height: 300px;
    overflow: hidden;
}

.districts-schools-explorer #districtMapContainer.loaded {
    display: flex;
    height: auto;
}

.districts-schools-explorer #districtMapContainer svg {
    width: 400px;
    height: auto;
    transform-origin: center;
}

/* Schools map styles */
.districts-schools-explorer .schools-map-container {
    aspect-ratio: 3/4;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 20px;
    position: relative;
    background: #f8f9fa;
    overflow: hidden;
}

.districts-schools-explorer #schoolsMap {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

.districts-schools-explorer .schools-map-container svg {
    width: 100%;
    height: 100%;
}

/* School list styles */
.districts-schools-explorer .school-item {
    padding: 15px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: white;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.2s ease;
}

.districts-schools-explorer .school-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.districts-schools-explorer .school-item.selected {
    background: #fff3e0;
    border: 1px solid #ff9800;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 152, 0, 0.3);
}

.districts-schools-explorer .school-name {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.districts-schools-explorer .school-details {
    font-size: 0.9em;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.districts-schools-explorer .school-address {
    font-size: 0.85em;
    color: var(--color-text-muted);
    margin-bottom: 10px;
    font-style: italic;
}

.districts-schools-explorer .school-grade-levels {
    font-size: 0.85em;
    color: var(--color-text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.districts-schools-explorer .school-links {
    margin-top: 8px;
}

.districts-schools-explorer .schools-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.districts-schools-explorer .schools-list-header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.districts-schools-explorer .schools-list h4 {
    margin: 0;
}

.districts-schools-explorer .district-registration-link {
    display: inline-block;
    background: #28a745;
    color: white;
    padding: 6px 12px;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    font-weight: 500;
    transition: background 0.2s ease;
}

.districts-schools-explorer .district-registration-link:hover {
    background: #218838;
    color: white;
    text-decoration: none;
}

.districts-schools-explorer .school-grade {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: bold;
    margin-right: 8px;
    color: white;
}

/* Grade color coding */
.districts-schools-explorer .grade-elementary { background: #4CAF50; color: white; }
.districts-schools-explorer .grade-middle { background: #FF9800; color: white; }
.districts-schools-explorer .grade-high { background: #F44336; color: white; }
.districts-schools-explorer .grade-early-childhood { background: #9C27B0; color: white; }
.districts-schools-explorer .grade-special { background: #607D8B; color: white; }
.districts-schools-explorer .grade-admin { background: #795548; color: white; font-size: 0.68em; }

/* School marker styles for SVG map */
.districts-schools-explorer .school-marker {
    cursor: pointer;
    transition: all 0.2s ease;
}

.districts-schools-explorer .school-marker:hover {
    stroke-width: 3;
}

.districts-schools-explorer .school-marker.grade-elementary { fill: #4CAF50; }
.districts-schools-explorer .school-marker.grade-middle { fill: #FF9800; }
.districts-schools-explorer .school-marker.grade-high { fill: #F44336; }
.districts-schools-explorer .school-marker.grade-early-childhood { fill: #9C27B0; }
.districts-schools-explorer .school-marker.grade-special { fill: #607D8B; }
.districts-schools-explorer .school-marker.grade-admin { fill: #795548; }

/* School legend styles */
.districts-schools-explorer .school-legend {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #dee2e6;
}

.districts-schools-explorer .school-legend h5 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 0.9em;
}

.districts-schools-explorer .legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.districts-schools-explorer .legend-item {
    display: flex;
    align-items: center;
    font-size: 0.8em;
    color: #495057;
}

.districts-schools-explorer .legend-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Google Maps AdvancedMarkerElement styles */
.districts-schools-explorer .gm-style .school-marker {
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    transition: transform 0.2s ease;
    width: 24px !important;
    height: 24px !important;
}

.districts-schools-explorer .gm-style .school-marker:hover {
    transform: scale(1.1);
    z-index: 1000;
}

/* AdvancedMarkerElement specific styles */
.districts-schools-explorer [data-marker-type="school"] {
    cursor: pointer;
    width: 24px !important;
    height: 24px !important;
}

.districts-schools-explorer .no-map {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-muted);
    font-style: italic;
}

/* Statistics */
.districts-schools-explorer .stats-summary {
    background: #ecf0f1;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.districts-schools-explorer .stats-title {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.districts-schools-explorer .stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 1em;
}

/* Responsive design */
@media (max-width: 1200px) {
    .districts-schools-explorer .three-pane-container {
        height: auto;
    }
    
    .districts-schools-explorer .top-section {
        flex-direction: column;
        flex: none;
    }
    
    .districts-schools-explorer .district-pane, 
    .districts-schools-explorer .map-pane {
        width: 100%;
        min-width: auto;
    }
    
    .districts-schools-explorer .map-pane {
        min-height: 400px;
        position: static;
    }
    
    .districts-schools-explorer .bottom-section {
        min-height: 300px;
        flex-direction: column;
    }
    
    .districts-schools-explorer .school-list-pane,
    .districts-schools-explorer .school-map-pane {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .districts-schools-explorer .three-pane-container {
        padding: 5px;
        gap: 5px;
    }
    
    .districts-schools-explorer .top-section {
        gap: 5px;
    }
    
    .districts-schools-explorer .district-pane {
        min-width: auto;
    }

    .districts-schools-explorer #districtsList {
        grid-template-columns: 1fr;
    }
}

/* Loading states */
.districts-schools-explorer .loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: var(--color-text-muted);
    animation: pulse 1.5s infinite;
}

.districts-schools-explorer .loading:empty::after {
    content: "Loading...";
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Safari Fix for Google Maps InfoWindow Close Button */
/* Safari doesn't render SVG content in CSS mask-image properly */
@supports (-webkit-appearance: none) {
    .gm-ui-hover-effect span[style*="mask-image"] {
        /* Fallback: Use a Unicode X character instead of masked SVG */
        mask-image: none !important;
        background-color: transparent !important;
        position: relative !important;
    }
    
    .gm-ui-hover-effect span[style*="mask-image"]::before {
        content: "×" !important;
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        color: #fff !important;
        font-size: 16px !important;
        font-weight: bold !important;
        font-family: Arial, sans-serif !important;
        line-height: 1 !important;
        pointer-events: none !important;
        z-index: 1000 !important;
        display: block !important;
    }
}

/* Alternative approach: Force visibility of the close button in Safari */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .gm-ui-hover-effect span[style*="mask-image"] {
        background-color: #5f6368 !important;
        border-radius: 2px !important;
        opacity: 0.7 !important;
    }
    
    .gm-ui-hover-effect:hover span[style*="mask-image"] {
        opacity: 1 !important;
    }
}
