/* =================================================================
   SLF Interactive Map Styles
   Font: Source Sans 3 (aligned with cornell-ipm-core)
   Updated: 2026-02-18 (Stream 2+3)
   ================================================================= */

/* ----- Reset & Base ----- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: 'Source Sans 3', 'Liberation Sans', Arial, sans-serif;
    color: #1f2937;
}

/* =================================================================
   FULLSCREEN MAP MODE (uses cornell-ipm-core header)
   ================================================================= */
.map-fullscreen {
    height: 100vh;
    overflow: hidden;
}

.map-fullscreen .ipm-header {
    position: relative;
}

.map-fullscreen main,
.map-fullscreen #main-content {
    height: calc(100vh - 6.5rem) !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden;
}

.map-fullscreen #map-container {
    position: relative;
    height: 100% !important;
    width: 100% !important;
}

.map-fullscreen .ipm-messages,
.map-fullscreen .ipm-footer {
    display: none;
}

@media (min-width: 768px) {
    .map-fullscreen main,
    .map-fullscreen #main-content {
        height: calc(100vh - 8.5rem) !important;
    }
}

@media (min-width: 1024px) {
    .map-fullscreen main,
    .map-fullscreen #main-content {
        height: calc(100vh - 10rem) !important;
    }
}

.map-header__download-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 8px;
}

/* =================================================================
   BUTTONS
   ================================================================= */
.map-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.map-btn:active {
    transform: scale(0.97);
}

.map-btn--pdf {
    background: #2563eb;
    color: #fff;
}

.map-btn--pdf:hover {
    background: #1d4ed8;
}

.map-btn--png {
    background: #059669;
    color: #fff;
}

.map-btn--png:hover {
    background: #047857;
}

/* Floating action buttons (panel toggles) */
.map-fab {
    position: absolute;
    z-index: 800;
    top: 12px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: #fff;
    color: #374151;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.map-fab:hover {
    background: #f3f4f6;
}

.map-fab--left {
    left: 12px;
}

.map-fab--right {
    right: 12px;
}

.map-fab--left.hidden,
.map-fab--right.hidden {
    display: none;
}

/* =================================================================
   MAP CONTAINER
   ================================================================= */
#map-container {
    position: relative;
    position: relative;
    height: 100%;
    width: 100%;
}

#map {
    height: 100% !important;
    width: 100% !important;
    position: absolute;
    top: 0;
    left: 0;
    background: #e5e7eb;
}

/* =================================================================
   SIDE PANELS
   ================================================================= */
.map-panel {
    position: absolute;
    z-index: 900;
    top: 12px;
    width: 320px;
    max-height: calc(100% - 24px);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.map-panel--left {
    left: 12px;
}

.map-panel--right {
    right: 12px;
}

.map-panel.collapsed {
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
}

.map-panel--right.collapsed {
    transform: translateX(110%);
}

.map-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 8px;
    border-bottom: 1px solid #e5e7eb;
}

.map-panel__header h2 {
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.map-panel__close {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    font-size: 18px;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-panel__close:hover {
    background: #f3f4f6;
    color: #374151;
}

.map-panel__body {
    padding: 10px 14px 14px;
    overflow-y: auto;
    flex: 1;
}

/* =================================================================
   LAYER CONTROLS
   ================================================================= */
.layer-group {
    margin-bottom: 14px;
}

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

.layer-group__title {
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    cursor: pointer;
    color: #374151;
}

.layer-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #2563eb;
    cursor: pointer;
    flex-shrink: 0;
}

.layer-swatch {
    display: inline-block;
    width: 16px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.layer-swatch--outline {
    background: transparent;
    border: 2.5px solid;
}

/* State quarantine: hatched pattern (distinct from county quarantine) */
.layer-swatch--hatched {
    width: 16px;
    height: 12px;
    border-radius: 2px;
    border: 2px solid #b91c1c;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        #b91c1c 2px,
        #b91c1c 3.5px
    );
    flex-shrink: 0;
}

/* Version info at bottom of layer panel */
.layer-panel__footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e5e7eb;
}

.layer-panel__version {
    font-size: 10px;
    color: #9ca3af;
    letter-spacing: 0.02em;
}

/* =================================================================
   LEGEND (standalone usage if needed)
   ================================================================= */
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 12.5px;
    color: #374151;
}

.legend-swatch {
    display: inline-block;
    width: 18px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-swatch--outline {
    background: transparent;
    border: 2.5px solid;
}

.legend-swatch--hatched {
    border: 2px solid #b91c1c;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        #b91c1c 2px,
        #b91c1c 3.5px
    );
}

.legend-separator {
    height: 1px;
    background: #e5e7eb;
    margin: 8px 0;
}

/* =================================================================
   POPUP (GetFeatureInfo)
   ================================================================= */
.slf-popup {
    font-family: 'Source Sans 3', 'Liberation Sans', Arial, sans-serif;
    min-width: 200px;
}

.slf-popup__title {
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e5e7eb;
}

.slf-popup__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-size: 12.5px;
}

.slf-popup__label {
    color: #6b7280;
}

.slf-popup__value {
    font-weight: 600;
}

.slf-popup__separator {
    height: 1px;
    background: #e5e7eb;
    margin: 8px 0;
}

.slf-popup__badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.slf-popup__badge--infestation {
    background: #dbeafe;
    color: #1e40af;
}

.slf-popup__badge--sighting {
    background: #ede9fe;
    color: #5b21b6;
}

.slf-popup__badge--quarantine {
    background: #fee2e2;
    color: #991b1b;
}

.slf-popup__badge--state-quarantine {
    background: #fef2f2;
    color: #7f1d1d;
    border: 1.5px solid #b91c1c;
}

.slf-popup__badge--none {
    background: #f3f4f6;
    color: #6b7280;
}

/* =================================================================
   PDF / PNG OVERLAY
   ================================================================= */
.pdf-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-overlay__content {
    background: #fff;
    padding: 32px 48px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.pdf-overlay__content p {
    margin-top: 16px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.pdf-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =================================================================
   BREADCRUMB NAVIGATION (for About/Downloads pages)
   ================================================================= */
.maps-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    font-size: 13px;
    color: #6b7280;
}

.maps-breadcrumb a {
    color: #2563eb;
    text-decoration: none;
}

.maps-breadcrumb a:hover {
    text-decoration: underline;
}

/* =================================================================
   CONTENT PAGES (About, Downloads)
   ================================================================= */
.maps-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

html:has(.maps-page), html:has(.maps-page) body {
    height: auto;
    overflow: auto;
}

.maps-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    overflow: hidden;
}

.maps-card .card-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid #e5e7eb;
}

.maps-card .card-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
}

.maps-card .card-body {
    padding: 16px 20px 20px;
}

.maps-card .card-body h2 {
    font-size: 17px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 10px;
}

.maps-card .card-body p {
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
    margin-bottom: 10px;
}

.maps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.maps-table th,
.maps-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.maps-table th {
    font-weight: 700;
    color: #1f2937;
    background: #f9fafb;
}

.maps-table td {
    color: #374151;
}

.maps-citation {
    font-size: 13px;
    line-height: 1.6;
    color: #374151;
    padding: 12px 16px;
    background: #f9fafb;
    border-left: 3px solid #2563eb;
    border-radius: 4px;
}

.maps-disclaimer {
    font-size: 12px;
    line-height: 1.5;
    color: #6b7280;
    background: #fefce8;
    border-left: 3px solid #ca8a04;
    padding: 12px 16px;
    border-radius: 4px;
}

/* Utility */
.btn-outline-ipm {
    display: inline-block;
    padding: 8px 20px;
    border: 2px solid #2563eb;
    color: #2563eb;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.btn-outline-ipm:hover {
    background: #2563eb;
    color: #fff;
}

.small { font-size: 12px; }
.text-muted { color: #6b7280; }

/* =================================================================
   LEAFLET OVERRIDES
   ================================================================= */
.leaflet-control-attribution {
    font-size: 10px !important;
    background: rgba(255, 255, 255, 0.85) !important;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-popup-content {
    margin: 12px 14px !important;
}

/* =================================================================
   RESPONSIVE
   ================================================================= */
@media (max-width: 768px) {
    .map-btn--pdf span,
    .map-btn--png span {
        display: none;
    }

    .map-panel {
        width: 260px;
    }
}

@media (max-width: 480px) {
    .map-panel {
        width: 220px;
        top: 8px;
    }

    .map-panel--left {
        left: 8px;
    }

    .map-panel--right {
        right: 8px;
    }
}

/* ==========================================================================
   Floating Map Controls (positioned like Leaflet zoom controls)
   ========================================================================== */
.map-floating-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.map-float-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s, box-shadow 0.15s;
    color: #fff;
    line-height: 1;
}

.map-float-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.map-float-btn:active {
    transform: translateY(0);
}

/* PNG button - green */
#btn-png.map-float-btn {
    background: #16a34a;
}
#btn-png.map-float-btn:hover {
    background: #15803d;
}

/* PDF button - blue */
#btn-pdf.map-float-btn {
    background: #2563eb;
}
#btn-pdf.map-float-btn:hover {
    background: #1d4ed8;
}

/* Mobile: icon-only floating buttons */
@media (max-width: 767px) {
    .map-float-btn span {
        display: none;
    }
    .map-float-btn {
        padding: 10px;
    }
}


/* Floating map title - matches legend panel width */
.map-floating-title {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1000;
    width: 320px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 16px;
    border-radius: 10px 10px 0 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a3c5a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    letter-spacing: -0.01em;
    pointer-events: none;
}

/* Push legend panel below the floating title */
.map-panel--left {
    left: 12px;
    top: 56px;
}

@media (max-width: 767px) {
    .map-floating-title {
        width: 260px;
        font-size: 0.95rem;
        padding: 8px 12px;
    }
    .map-panel--left {
        top: 50px;
    }
}
@media (max-width: 480px) {
    .map-floating-title {
        width: 220px;
        font-size: 0.85rem;
        padding: 6px 10px;
        left: 8px;
        top: 8px;
    }
    .map-panel--left {
        top: 42px;
        left: 8px;
    }
}

/* ==========================================================================
   MERGED LEGEND PANEL — title + layers + downloads in one component
   Replaces separate .map-floating-title and .map-floating-controls
   ========================================================================== */

/* Panel now starts at the very top (no floating title above it) */
.map-panel--left {
    left: 12px;
    top: 12px;
}

/* Header with title and close button */
.map-panel__title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.map-panel__title {
    font-size: 1rem;
    font-weight: 700;
    color: #1a3c5a;
    line-height: 1.25;
    margin: 0;
    letter-spacing: -0.01em;
}

/* Footer: downloads + version */
.map-panel__footer {
    padding: 10px 16px 12px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-panel__downloads {
    display: flex;
    gap: 8px;
}

.map-panel__dl-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 0;
    border: none;
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #fff;
    cursor: pointer;
    transition: filter 0.15s;
    line-height: 1;
}

.map-panel__dl-btn:hover {
    filter: brightness(0.9);
}

.map-panel__dl-btn--png {
    background: #16a34a;
}

.map-panel__dl-btn--pdf {
    background: #2563eb;
}

/* Remove old floating elements (keep rules empty to override if cached) */
.map-floating-title {
    display: none;
}

.map-floating-controls {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .map-panel--left {
        top: 8px;
        left: 8px;
    }

    .map-panel__title {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .map-panel--left {
        top: 8px;
        left: 8px;
    }

    .map-panel__title {
        font-size: 0.85rem;
    }
}