/* Map Hero Section */
.map-hero-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
}


.hero-stats {
    margin-top: 30px;
}

.stat-item {
    text-align: center;
    color: white;
    padding: 15px 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    transition: all 0.3s ease;
}

.stat-item:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
}

.stat-number {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    margin-top: 0;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: rgba(0,0,0,0.2);
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
}

/* Map Controls */
.map-controls-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}


.map-legend {
    display: flex;
    align-items: center;
    gap: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.legend-marker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ngo-marker {
    background: #007bff;
}

.project-marker {
    background: #dc3545;
}

.user-location-marker {
    background: #ffc107;
}

/* Map Container */
.map-container {
    position: relative;
    background: var(--bg-secondary);
}

/* Enhanced Loading and Error Overlays */
.map-loading, .map-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 249, 250, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

[data-theme="dark"] .map-loading,
[data-theme="dark"] .map-error {
    background: rgba(26, 26, 26, 0.95);
}

.loading-content, .error-content {
    text-align: center;
    max-width: 400px;
    padding: 30px;
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

[data-theme="dark"] .loading-content,
[data-theme="dark"] .error-content {
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

.loading-title, .error-title {
    color: var(--text-primary);
    margin-bottom: 15px;
}

.loading-message, .error-message {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.loading-progress {
    width: 100%;
}

.progress {
    height: 6px;
    background-color: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

/* Info Panel */
.map-info-panel {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

[data-theme="dark"] .map-info-panel {
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

.feature-card {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

[data-theme="dark"] .feature-card:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

.feature-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.feature-content h5 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.feature-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Stats Panel */
.map-stats-panel {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    height: fit-content;
}

[data-theme="dark"] .map-stats-panel {
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

.stats-grid {
    display: grid;
    gap: 20px;
    margin-top: 20px;
}

.stat-box {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 10px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-icon.text-primary {
    background: rgba(0, 123, 255, 0.1);
}

.stat-icon.text-success {
    background: rgba(40, 167, 69, 0.1);
}

.stat-icon.text-warning {
    background: rgba(255, 193, 7, 0.1);
}

.stat-icon.text-info {
    background: rgba(23, 162, 184, 0.1);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    /* color: #2d3748; */
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    /* color: #718096; */
    margin-top: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .map-hero-section {
        padding: 20px 0 !important;
    }

    .map-hero-section h1 {
        font-size: 1.75rem !important;
        line-height: 1.3;
    }

    .map-hero-section .lead {
        font-size: 0.95rem !important;
        margin-bottom: 20px !important;
    }

    .hero-stats {
        justify-content: center;
        margin-top: 20px !important;
        gap: 12px !important;
    }

    .stat-item {
        padding: 12px 16px;
        min-width: 110px;
        flex: 1;
    }

    .stat-number {
        font-size: 1.8rem !important;
        margin-bottom: 8px;
    }

    .stat-label {
        font-size: 0.75rem !important;
        font-weight: 600;
        letter-spacing: 0.5px;
        padding: 3px 6px;
    }

    /* Map Controls */
    .map-controls-bar .container {
        padding: 0 15px;
    }

    .map-legend {
        justify-content: flex-start;
        margin-bottom: 15px;
        flex-wrap: wrap;
        gap: 12px !important;
    }

    .legend-item {
        font-size: 0.8rem;
    }

    .legend-marker {
        width: 12px;
        height: 12px;
    }

    /* Filters on mobile */
    .map-filters {
        justify-content: flex-start !important;
        gap: 8px !important;
    }

    .filter-group {
        flex: 1;
        min-width: calc(50% - 4px);
    }

    .filter-group .form-select {
        width: 100%;
        font-size: 0.85rem;
        padding: 6px 10px;
    }

    .btn-group-sm > .btn {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    /* Stack button groups vertically on very small screens */
    .map-filters > .btn-group {
        flex-shrink: 0;
    }

    /* Map height on mobile */
    #ngoMap {
        height: 500px !important;
    }

    /* Feature cards */
    .feature-card {
        padding: 15px;
    }

    .feature-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .feature-content h5 {
        font-size: 1rem;
    }

    .feature-content p {
        font-size: 0.85rem;
    }

    /* Stats panel on mobile */
    .map-info-panel,
    .map-stats-panel {
        padding: 20px;
        margin-bottom: 20px;
    }

    .map-info-panel h3,
    .map-stats-panel h4 {
        font-size: 1.25rem;
    }

    .stat-value {
        font-size: 1.5rem !important;
    }

    .stat-label {
        font-size: 0.8rem !important;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 576px) {
    .map-hero-section h1 {
        font-size: 1.5rem !important;
    }

    .map-hero-section .lead {
        font-size: 0.875rem !important;
    }

    .hero-stats {
        gap: 8px !important;
    }

    .stat-item {
        padding: 10px 12px;
        min-width: 90px;
    }

    .stat-number {
        font-size: 1.5rem !important;
    }

    .stat-label {
        font-size: 0.7rem !important;
    }

    /* Stack filters vertically on very small screens */
    .map-filters {
        flex-direction: column;
        width: 100%;
    }

    .filter-group {
        width: 100%;
        min-width: 100%;
    }

    .map-filters > .btn-group {
        width: 100%;
    }

    .map-filters > .btn-group .btn {
        flex: 1;
    }

    /* Adjust map height for small phones */
    #ngoMap {
        height: 450px !important;
    }

    /* Smaller search box on phones */
    .map-search-box {
        width: calc(100% - 20px) !important;
        top: 10px !important;
        left: 10px !important;
    }

    .map-search-box .input-group {
        font-size: 0.85rem;
    }

    /* Info overlay adjustments */
    .map-info-overlay {
        left: 10px !important;
        right: 10px !important;
        bottom: 10px !important;
        min-width: auto !important;
    }

    .stat-mini-value {
        font-size: 1.2rem;
    }

    .stat-mini-label {
        font-size: 0.65rem;
    }

    /* Button text visibility */
    .btn .d-none.d-md-inline {
        display: none !important;
    }

    .btn .d-none.d-lg-inline {
        display: none !important;
    }
}



.verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: #28a745;
    margin-top: 5px;
}

/* Enhanced Map Search */
.map-search-box {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 1000;
    width: 320px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    overflow: hidden;
}

[data-theme="dark"] .map-search-box {
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

.map-search-box .form-control::placeholder {
    color: #6c757d;
}

[data-theme="dark"] .map-search-box .form-control::placeholder {
    color: var(--text-muted);
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 12px 12px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1001;
}

.suggestions-list {
    padding: 0;
}

.suggestion-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f7fafc;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.2s;
}

.suggestion-item:hover {
    background-color: #f7fafc;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    flex-shrink: 0;
}

.suggestion-icon.ngo {
    background: #007bff;
}

.suggestion-icon.project {
    background: #dc3545;
}

.suggestion-icon.location {
    background: #28a745;
}

.suggestion-content {
    flex: 1;
}

.suggestion-title {
    font-weight: 600;
    color: #2d3748;
    margin: 0;
    font-size: 0.9rem;
}

.suggestion-subtitle {
    color: #718096;
    margin: 0;
    font-size: 0.8rem;
}

/* Enhanced Filter Styling */
.filter-group {
    position: relative;
}

.filter-group .form-select {
    min-width: 120px;
    border-radius: 6px;
    transition: all 0.2s;
}

.filter-group .form-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.map-info-overlay {
    position: absolute;
    bottom: 15px;
    left: 15px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 10px;
    padding: 0;
    min-width: 200px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

.info-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.info-panel-header h6 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.info-panel-content {
    padding: 15px;
    transition: all 0.3s ease;
}

.info-panel-content.collapsed {
    display: none;
}

.stat-mini {
    text-align: center;
    padding: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
}

.stat-mini-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}

.stat-mini-label {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.8);
    margin-top: 2px;
}

/* Fullscreen mode */
.map-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: white;
}

.map-container.fullscreen #ngoMap {
    height: 100vh !important;
}

/* Enhanced marker animations */
.leaflet-marker-icon {
    transition: all 0.3s ease;
}

.leaflet-marker-icon:hover {
    transform: scale(1.2);
    filter: brightness(1.2);
}

/* Improved responsive design - Additional mobile tweaks */
@media (max-width: 768px) {
    .map-controls-bar .py-3 {
        padding-top: 15px !important;
        padding-bottom: 15px !important;
    }

    /* Better spacing for controls */
    .map-controls-bar .row {
        row-gap: 15px;
    }
}

/* Loading animation improvements */
.map-loading {
    backdrop-filter: blur(5px);
}

.map-loading .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Enhanced button styles */
.btn-outline-secondary:hover,
.btn-outline-warning:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Search input enhancements */
.map-search-box .form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Tooltip styles for map elements */
.map-tooltip {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    pointer-events: none;
    position: absolute;
    z-index: 1001;
}

/* User Location Popup Styling */
.leaflet-popup.user-location-popup .leaflet-popup-content-wrapper {
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    padding: 0;
    min-width: 180px !important;
}

.leaflet-popup.user-location-popup .leaflet-popup-content {
    margin: 0;
    min-width: 180px;
    width: auto !important;
}

.leaflet-popup.user-location-popup .leaflet-popup-tip {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Ensure popup doesn't get cut off */
.leaflet-popup-content-wrapper {
    overflow: visible !important;
}

.leaflet-popup-content {
    overflow: visible !important;
    white-space: normal !important;
}

/* Fix marker clickable area - remove extra padding */
.custom-div-icon {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

.custom-div-icon div {
    margin: 0 !important;
    padding: 0 !important;
}

/* User location marker fix */
.user-location-icon {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

/* Mobile touch optimization */
@media (max-width: 768px) {
    /* Ensure buttons have adequate touch targets (min 44x44px) */
    .btn-group-sm > .btn {
        min-height: 38px;
        min-width: 38px;
    }

    /* Better dropdown positioning on mobile */
    .dropdown-menu {
        font-size: 0.9rem;
    }

    .dropdown-item {
        padding: 10px 16px;
    }

    /* Improve map interaction on mobile */
    .leaflet-container {
        touch-action: pan-x pan-y;
    }

    /* Better popup visibility on mobile */
    .leaflet-popup-content-wrapper {
        max-width: calc(100vw - 60px);
    }

    /* Scrollable dropdown for radius selection */
    .dropdown-menu {
        max-height: 300px;
        overflow-y: auto;
    }
}

/* Landscape mode optimizations for mobile */
@media (max-width: 896px) and (orientation: landscape) {
    .map-hero-section {
        padding: 15px 0 !important;
    }

    .map-hero-section h1 {
        font-size: 1.5rem !important;
        margin-bottom: 10px !important;
    }

    .map-hero-section .lead {
        font-size: 0.875rem !important;
        margin-bottom: 15px !important;
    }

    .hero-stats {
        margin-top: 15px !important;
    }

    #ngoMap {
        height: 350px !important;
    }
}

/* Tablet-specific optimizations */
@media (min-width: 577px) and (max-width: 768px) {
    #ngoMap {
        height: 550px !important;
    }

    .stat-number {
        font-size: 2rem !important;
    }

    .map-hero-section h1 {
        font-size: 2rem !important;
    }
}
