/* Excel Organization Map Styles */

/* Base map container */
.excel-organization-map {
    width: 67%;
    height: 400px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

/* Map canvas */
.organization-map-canvas {
    width: 100%;
    height: 100%;
}

/* Error messages */
.error-message {
    color: #d32f2f;
    padding: 10px;
    background-color: #ffebee;
    border-radius: 4px;
    margin: 10px 0;
    text-align: center;
}

/* Details panel that slides in from the right */
.organization-details-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 33%;
    background-color: var(--bricks-color-gjalye);
    border-left: 1px solid #000000;
    padding: var(--space-2xs);
    box-sizing: border-box;
    height: 100%;
    overflow-y: auto;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
}
@media only screen and (max-width: 1024px) {
    .organization-details-panel {
        width: 50%;
    }
}

.organization-details-panel.active {
    transform: translateX(0);
}

.organization-details-panel.active p {
    margin-bottom: calc(var(--space-3xs) * 0.5);
    font-size: var(--step--2);
    line-height: 1em;
}

.organization-details-panel.active p strong {
    display: block;
    width: 100%;
}

.org-detail-close {
    position: absolute;
    top: 6px;
    right: 6px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.org-name {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: var(--step--2);
    color: var(--bricks-color-vxgyua);
    margin-bottom: var(--space-2xs);
    text-transform: capitalize;
    text-wrap: balance;
}

/* Marker transition styles */
.leaflet-marker-icon {
    transition: filter 0.4s ease-in-out, opacity 0.4s ease-in-out;
    opacity: 0.6
}

/* Override opacity for PNG markers at high zoom levels */
.test-png-marker,
.leaflet-marker-icon.test-png-marker {
    opacity: 1 !important;
    filter: none !important;
    width: 48px !important;
    height: 72px !important;
    min-width: 48px !important;
    min-height: 72px !important;
    max-width: 48px !important;
    max-height: 72px !important;
    box-sizing: border-box !important;
}

.marker-active {
    z-index: 1000 !important;
    opacity: 1 !important;
    filter: drop-shadow(0 0 10px rgba(112, 193, 111, 0.8)) !important;
    transition: all 0.3s ease !important;
}

.marker-inactive {
    opacity: 0.4 !important;
    filter: grayscale(50%) !important;
    transition: all 0.3s ease !important;
}

/* Loading spinner */
.excel-map-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 999;
}

.excel-map-loading .spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--bricks-color-npbuep);
    animation: spin 2s linear infinite;
}

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

/* Layout containers */
.excel-organization-map-container {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.excel-organization-map-filters {
    padding: var(--space-2xs) var(--space-2xs) 0 var(--space-2xs);
    box-sizing: border-box;
    position: relative;
    width: 33%
}

/* Filter elements */
.filter-count-subhead {
    font-size: var(--step--2);
    font-weight: 400;
    margin-bottom: 4px;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-count {
    display: none; /* Deprecated dynamic count hidden */
}

.filter-heading {
    font-weight: bold;
    margin-bottom: var(--space-2xs);
    color: white;
}

.filter-buttons {
    overflow-y: auto;
    max-height: 50vh;
    overscroll-behavior: contain; /* Prevent page scroll when at boundary */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    transform: translateZ(0); /* Create stacking context */
    position: relative;
    z-index: 100;
    scrollbar-width: thin; /* Firefox */
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 4px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    background-color: #333333;
}

/* Gradient overlay at the bottom */
.filter-buttons-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none; /* Allow clicks to pass through */
    opacity: 1;
    z-index: 101;
}

/* Bottom-left dynamic stats box */
.org-stats-box {
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 800; /* below details panel (1000), above map */
    background: rgba(0,0,0,0.75);
    color: #fff;
    padding: 14px 16px;
    border-radius: 6px;
    max-width: 340px;
    backdrop-filter: blur(2px);
}
.org-stats-title {
    font-size: var(--step--1);
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.org-stats-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: var(--step--2);
    line-height: 1.2;
    margin-top: 4px;
}
.org-stats-row .label { color: #e8e8e8; }
.org-stats-row .value { color: var(--bricks-color-npbuep); font-weight: 700; }

/* Style scrollbar for webkit browsers */
.filter-buttons::-webkit-scrollbar {
    width: 8px !important;
}

.filter-buttons::-webkit-scrollbar-track {
    background: rgba(71, 71, 71, 1) !important;
    border-radius: 4px !important;
}

.filter-buttons::-webkit-scrollbar-thumb {
    background-color: var(--bricks-color-gjalye) !important;
    border-radius: 4px !important;
}

.filter-button {
    display: block;
    margin-bottom: 5px;
    padding: var(--space-3xs);
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
    flex-shrink: 0;
    min-height: 35px;
    font-size: var(--step--2);
}

.filter-button:hover {
    background: #e5e5e5;
}

.filter-button.active {
    background: var(--bricks-color-gjalye);
    color: black;
}

.filter-button-all {
    margin-bottom: 10px;
    font-weight: bold;
}

/* Choropleth map styles */
.choropleth-polygon {
    stroke: #fff;
    stroke-width: 1;
    stroke-opacity: 0.8;
    transition: all 0.3s ease;
}

.choropleth-polygon.interactive {
    cursor: pointer;
}

.choropleth-polygon.no-data {
    cursor: default;
    pointer-events: none;
}

.choropleth-polygon.interactive:hover {
    stroke-width: 2;
    stroke: #000;
    fill-opacity: 0.8;
}

.choropleth-polygon.interactive.active {
    stroke-width: 2;
    stroke: #000;
    fill-opacity: 0.9;
}

.choropleth-polygon.interactive.highlight {
    stroke-width: 2;
    stroke: #000;
    fill-opacity: 0.7;
}

/* Support for patterned fills using CSS */
.leaflet-patterned-path {
    position: relative;
    overflow: hidden;
}

.leaflet-patterned-path::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Style for striped patterns */
.leaflet-striped-pattern::before {
    background-size: 200% 200%;
}

/* Color scale for choropleth using EFB theme colors */
.choropleth-scale-1 { fill: var(--bricks-color-npbuep); } /* Sapling (green) */
.choropleth-scale-2 { fill: var(--bricks-color-nhofrh); } /* Gold */
.choropleth-scale-3 { fill: var(--bricks-color-olyyze); } /* Cyan */
.choropleth-scale-4 { fill: var(--bricks-color-gjalye); } /* Peach */
.choropleth-scale-5 { fill: var(--bricks-color-knqnjn); } /* Yellow */
.choropleth-scale-6 { fill: var(--bricks-color-vxgyua); } /* EFB Emerald */

/* Info control styles - commented out as info control is not needed with popups */
/*
.info {
    padding: 8px 10px;
    font: 14px/16px Arial, Helvetica, sans-serif;
    background: white;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    border-radius: 5px;
    border: 1px solid #ccc;
}

.info h4 {
    margin: 0 0 5px;
    color: #333;
    font-weight: bold;
}
*/

/* Legend styles */
.legend {
    line-height: 18px;
    color: #555;
    background: white;
    background: rgba(255,255,255,0.9);
    padding: 10px 12px;
    border-radius: 5px;
    border: 1px solid #ccc;
    max-width: 220px;
}

.legend h4 {
    margin: 0 0 8px;
    color: #333;
    font-weight: bold;
    font-size: 14px;
    text-align: center;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

.legend i {
    width: 18px;
    height: 18px;
    float: left;
    margin-right: 8px;
    opacity: 0.8;
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: 3px;
}

/* Style for striped indicator in the legend */
.legend i.striped {
    background-size: 10px 10px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

.legend .legend-item {
    margin-bottom: 5px;
    clear: both;
    overflow: hidden; /* Ensures floating elements are contained */
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* EFB theme colors for choropleth */
.choropleth-efb-0 { fill: #f5f5f5; } /* No data */
.choropleth-efb-1 { fill: var(--bricks-color-npbuep); } /* Sapling (green) */
.choropleth-efb-2 { fill: var(--bricks-color-nhofrh); } /* Gold */
.choropleth-efb-3 { fill: var(--bricks-color-olyyze); } /* Cyan */
.choropleth-efb-4 { fill: var(--bricks-color-gjalye); } /* Peach */
.choropleth-efb-5 { fill: var(--bricks-color-knqnjn); } /* Yellow */

ul.governorate-org-list {
    padding: 0 0 0 10px;
    margin: 0;
}

.governorate-org-list li {
    padding: 0 0 0 5px;
    margin: 0;
    line-height: 1.2em;
    margin-bottom: 0.5em;
    font-size: var(--step--2);
}

/* Government type headers */
.organization-details-panel h4.government-type {
    font-size: var(--step-0);
    margin-bottom: var(--space-3xs);
    color: var(--bricks-color-vxgyua);
    font-weight: bold;
}

/* Add top margin to all government type headers except the first one */
.organization-details-panel h4.government-type:not(:first-of-type) {
    margin-top: var(--space-2xs);
    padding-top: var(--space-2xs);
    border-top: 1px solid var(--bricks-color-vxgyua);
}

/* Responsive styles */
@media (max-width: 478px) {
    :root {
        --rtk-coverage-height: 40vh !important;
    }
    .excel-organization-map-container {
        flex-direction: column;
        height: auto;
    }
    
    .excel-organization-map,
    .excel-organization-map-filters {
        width: 100% !important;
    }
    
    .excel-organization-map-filters {
        padding: 10px;
        margin-top: 0;
        max-height: 40vh;
        overflow-y: auto;
        border: none;
        border-radius: none;
    }
    .filter-buttons {
        max-height: 35vh;
        padding: 10px 10px 100px 0px;
    }
}

/* PNG Marker active and inactive states */
.png-marker.marker-active {
    z-index: 1000 !important;
    filter: drop-shadow(0 0 10px rgba(112, 193, 111, 0.8)) brightness(1.1) !important;
    transition: all 0.3s ease !important;
}

.png-marker.marker-inactive {
    opacity: 0.4 !important;
    filter: grayscale(50%) !important;
    transition: all 0.3s ease !important;
}

/* Cluster map marker highlighting - comprehensive selectors */
.leaflet-marker-icon.marker-active,
.leaflet-div-icon.marker-active,
.custom-png-marker.marker-active,
.clustered-organization-marker.marker-active,
.clustered-individual-marker.marker-active {
    z-index: 1000 !important;
    filter: drop-shadow(0 0 10px rgba(112, 193, 111, 0.8)) !important;
    transition: all 0.3s ease !important;
}

.leaflet-marker-icon.marker-inactive,
.leaflet-div-icon.marker-inactive,
.custom-png-marker.marker-inactive,
.clustered-organization-marker.marker-inactive,
.clustered-individual-marker.marker-inactive {
    opacity: 0.4 !important;
    filter: grayscale(50%) !important;
    transition: all 0.3s ease !important;
}

/* Clustering styles */
.leaflet-pane-grid-markers-pane .leaflet-interactive {
    fill: #70c16f !important; /* EFB Sapling green */
    stroke: white !important;
}

.leaflet-pane-grid-texts-pane .leaflet-marker-icon {
    color: white !important;
    font-weight: bold !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3) !important;
    font-size: 12px !important;
}

/* Cluster marker circles */
.leaflet-regular-grid-cluster-marker {
    border-radius: 50% !important;
}

/* Individual marker styles when clustering is enabled */
.clustered-individual-marker {
    fill: #70c16f !important; /* EFB Sapling green */
    stroke: white !important;
    stroke-width: 2px !important;
}

/* Grid cluster component overrides */
.leaflet-pane-grid-markers-pane circle {
    fill: #70c16f !important; /* EFB Sapling green */
    stroke: white !important;
    stroke-width: 2px !important;
}

.leaflet-pane-grid-texts-pane text {
    fill: white !important;
    font-weight: bold !important;
    font-size: 12px !important;
    text-anchor: middle !important;
    dominant-baseline: central !important;
} 