/* Campsite Map Styles */
#campsite-map {
    height: 65vh;
    min-height: 450px;
    width: 100%;
    border-radius: 0.5rem;
    border: 2px solid var(--tt-orange);
    z-index: 1;
}

.map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 65vh;
    min-height: 450px;
    background: #f0f0f0;
    border-radius: 0.5rem;
    border: 2px solid var(--tt-orange);
}

.map-legend {
    background: #fff;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.map-legend .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-right: 1.25rem;
    font-size: 0.875rem;
}

.map-legend .legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.map-legend .legend-dot.campground {
    background: #2d7d46;
}

.map-legend .legend-dot.facility {
    background: #2563eb;
}

.map-legend .legend-dot.visitor-center {
    background: #d97706;
}

.map-legend .legend-dot.other {
    background: #6b7280;
}

.map-stats {
    font-size: 0.85rem;
    color: #666;
}

/* Leaflet popup overrides */
.facility-popup h6 {
    margin: 0 0 0.35rem 0;
    font-size: 0.95rem;
    color: var(--tt-dark);
}

.facility-popup .popup-type {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.facility-popup .popup-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    font-weight: 600;
}

.facility-popup .popup-badge.reservable {
    background: #dcfce7;
    color: #166534;
}

.facility-popup .popup-badge.walk-in {
    background: #fef3c7;
    color: #92400e;
}

.facility-popup .popup-badge.usfs-badge {
    background: #d1fae5;
    color: #065f46;
}

.map-legend .legend-dot.usfs {
    background: #059669;
    border: 2px solid #fbbf24;
}

/* Cluster styling */
.marker-cluster-small {
    background-color: rgba(45, 125, 70, 0.4) !important;
}

.marker-cluster-small div {
    background-color: rgba(45, 125, 70, 0.7) !important;
    color: #fff !important;
    font-weight: 600;
}

.marker-cluster-medium {
    background-color: rgba(255, 152, 0, 0.4) !important;
}

.marker-cluster-medium div {
    background-color: rgba(255, 152, 0, 0.7) !important;
    color: #fff !important;
    font-weight: 600;
}

.marker-cluster-large {
    background-color: rgba(220, 53, 69, 0.4) !important;
}

.marker-cluster-large div {
    background-color: rgba(220, 53, 69, 0.7) !important;
    color: #fff !important;
    font-weight: 600;
}

.filter-bar .form-check {
    cursor: pointer;
}

.filter-bar .form-check-input:checked {
    background-color: var(--tt-orange);
    border-color: var(--tt-orange);
}

/* Map search */
.map-search-wrapper {
    position: relative;
    max-width: 500px;
}

.map-search-wrapper .input-group-text {
    background: #fff;
    border-right: 0;
    color: #6b7280;
}

.map-search-wrapper .form-control {
    border-left: 0;
}

.map-search-wrapper .form-control:focus {
    box-shadow: none;
    border-color: var(--tt-orange, #e97a2b);
}

.map-search-wrapper .form-control:focus + .btn,
.map-search-wrapper .form-control:focus ~ .input-group-text {
    border-color: var(--tt-orange, #e97a2b);
}

.map-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid #dee2e6;
    border-top: 0;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    max-height: 320px;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0;
}

.map-search-results.active {
    display: block;
}

.map-search-results li {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #1a1a1a;
    border-bottom: 1px solid #f3f4f6;
}

.map-search-results li:last-child {
    border-bottom: 0;
}

.map-search-results li:hover,
.map-search-results li.active {
    background: #f8f9fa;
}

.map-search-results li .search-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    color: var(--tt-orange, #e97a2b);
    margin-top: 0.1rem;
}

.map-search-results li .search-info {
    flex: 1;
    min-width: 0;
}

.map-search-results li .search-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-search-results li .search-detail {
    font-size: 0.75rem;
    color: #6b7280;
}

.map-search-results li .search-source {
    flex-shrink: 0;
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 0.75rem;
    font-weight: 600;
    align-self: center;
}

.map-search-results li .search-source.source-ridb {
    background: #dbeafe;
    color: #1e40af;
}

.map-search-results li .search-source.source-usfs {
    background: #d1fae5;
    color: #065f46;
}

.map-search-results li .search-source.source-place {
    background: #fef3c7;
    color: #92400e;
}

.map-search-results .search-empty {
    padding: 1rem;
    text-align: center;
    color: #9ca3af;
    font-size: 0.85rem;
}

.map-search-results .search-loading {
    padding: 0.75rem;
    text-align: center;
    color: #9ca3af;
}

/* USFS dropdown filter */
.usfs-filter-menu {
    max-height: 400px;
    overflow-y: auto;
    min-width: 260px;
    padding: 0.25rem 0;
    font-size: 0.875rem;
    background: #fff;
    color: #1a1a1a;
}

.usfs-filter-menu .dropdown-item-text {
    padding: 0.15rem 0.75rem;
}

.usfs-filter-menu .form-check {
    margin-bottom: 0;
}

.usfs-filter-menu .form-check-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
    font-size: 0.825rem;
    cursor: pointer;
    color: #1a1a1a;
}

.usfs-filter-menu .form-check-input:checked {
    background-color: var(--tt-orange);
    border-color: var(--tt-orange);
}

#usfsFilterDropdown .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    #campsite-map {
        height: 55vh;
        min-height: 350px;
    }

    .map-legend .legend-item {
        margin-right: 0.75rem;
        font-size: 0.8rem;
    }

    .usfs-filter-menu {
        max-height: 300px;
        min-width: 220px;
    }
}

/* Map Layers dropdown */
.map-layers-menu {
    min-width: 240px;
    padding: 0.25rem 0;
    font-size: 0.875rem;
    background: #fff;
    color: #1a1a1a;
}

.map-layers-menu .dropdown-item-text {
    padding: 0.2rem 0.75rem;
}

.map-layers-menu .form-check {
    margin-bottom: 0;
}

.map-layers-menu .form-check-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    font-size: 0.825rem;
    cursor: pointer;
    color: #1a1a1a;
}

.map-layers-menu .form-check-label i {
    width: 16px;
    text-align: center;
}

.map-layers-menu .form-check-input:checked {
    background-color: var(--tt-orange);
    border-color: var(--tt-orange);
}

/* Layer opacity slider */
.layer-opacity-slider {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0 0.1rem 1.6rem;
}

.layer-opacity-slider .form-range {
    flex: 1;
    height: 4px;
    cursor: pointer;
    accent-color: var(--tt-orange, #e97a2b);
    min-width: 80px;
}

.layer-opacity-slider .layer-opacity-value {
    font-size: 0.68rem;
    color: #6b7280;
    min-width: 30px;
    text-align: right;
    white-space: nowrap;
}

#mapLayersDropdown .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
}

/* Detail Overlay */
.facility-detail-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.45);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.facility-detail-panel {
    position: relative;
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    max-width: 520px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 1.5rem;
    animation: detailSlideIn 0.2s ease-out;
}

@keyframes detailSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.facility-detail-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: background 0.15s;
}

.facility-detail-close:hover {
    background: #f3f4f6;
    color: #111;
}

.detail-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.15rem;
    color: var(--tt-dark, #1a1a1a);
    padding-right: 2rem;
}

.detail-type-badge {
    display: inline-block;
    font-size: 0.78rem;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    background: #e0e7ff;
    color: #3730a3;
    font-weight: 600;
}

.detail-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-row {
    display: flex;
    gap: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

.detail-label {
    flex: 0 0 120px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.detail-label i {
    width: 16px;
    text-align: center;
    color: var(--tt-orange, #e97a2b);
    margin-right: 0.25rem;
}

.detail-value {
    flex: 1;
    color: #4b5563;
    word-break: break-word;
}

.detail-value a {
    color: var(--tt-orange, #e97a2b);
    text-decoration: none;
}

.detail-value a:hover {
    text-decoration: underline;
}

.facility-popup .facility-detail-btn {
    font-size: 0.78rem;
    padding: 0.2rem 0.6rem;
}

@media (max-width: 576px) {
    .facility-detail-panel {
        max-width: 100%;
        max-height: 90vh;
        margin: 0.5rem;
        padding: 1rem;
    }

    .detail-row {
        flex-direction: column;
        gap: 0.15rem;
    }

    .detail-label {
        flex: none;
        font-size: 0.8rem;
    }
}

/* Map Layer Legend (Leaflet control) */
.map-layer-legend {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 0;
    font-size: 0.78rem;
    color: #1a1a1a;
    max-height: 50vh;
    overflow-y: auto;
    min-width: 200px;
    max-width: 280px;
    line-height: 1.4;
}

.map-layer-legend:empty {
    display: none;
}

.map-layer-legend .legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0.5rem 0.5rem 0 0;
}

.map-layer-legend .legend-header-title {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #374151;
}

.map-layer-legend .legend-header-title i {
    color: var(--tt-orange, #e97a2b);
    margin-right: 0.2rem;
}

.map-layer-legend .legend-collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 0.75rem;
    padding: 0.15rem 0.35rem;
    border-radius: 0.25rem;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.map-layer-legend .legend-collapse-btn:hover {
    color: #374151;
    background: #e5e7eb;
}

.map-layer-legend .legend-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 0.4rem;
    cursor: pointer;
    color: #374151;
    font-size: 0.9rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    transition: color 0.15s, background 0.15s;
}

.map-layer-legend .legend-toggle-btn:hover {
    background: #fff;
    color: var(--tt-orange, #e97a2b);
}

/* When collapsed, reset sizing so only the icon button shows */
.map-layer-legend.collapsed {
    min-width: auto;
    max-width: none;
    max-height: none;
    overflow: visible;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
}

.map-layer-legend .legend-section {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.map-layer-legend .legend-section:last-child {
    border-bottom: none;
}

.map-layer-legend .legend-section-title {
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.map-layer-legend .legend-entry {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.1rem 0;
}

.map-layer-legend .legend-line {
    flex-shrink: 0;
    width: 24px;
    height: 0;
    display: inline-block;
}

.map-layer-legend .legend-line-solid {
    border-top-style: solid;
}

.map-layer-legend .legend-line-dash {
    border-top-style: dashed;
}

.map-layer-legend .legend-swatch {
    flex-shrink: 0;
    width: 16px;
    height: 12px;
    display: inline-block;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.map-layer-legend .legend-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    .map-layer-legend {
        font-size: 0.7rem;
        min-width: 170px;
        max-width: 220px;
        max-height: 40vh;
    }
}

/* Topo hillshade overlay — multiply blend makes white transparent */
.topo-hillshade-layer {
    mix-blend-mode: multiply;
}

/* GPX / KML Import */
.gpx-route-stats {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.375rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    color: #991b1b;
    margin-bottom: 0.5rem;
}

.gpx-waypoint-icon {
    background: transparent !important;
    border: none !important;
}
