body,
html {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
    /* Prevent horizontal scrolling */
}

main {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.card {
    margin-bottom: 1rem;
}

#map-container {
    height: 500px;
    /* Fixed height for the map container */
}

#mapid {
    height: 100%;
    width: 100%;
    z-index: 1;
}

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

.leaflet-popup-content {
    font-size: 14px;
    line-height: 1.6;
}

/* Hospital ranking results styling */
#hospital-ranking-results {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-top: 1rem;
    min-height: 200px;
}

/* Responsive map container */
@media (max-width: 768px) {
    #map-container {
        height: 400px;
    }
}

@media (max-width: 576px) {
    #map-container {
        height: 350px;
    }
}

.ranking-section {
    margin-bottom: 2rem;
}

.ranking-section:last-child {
    margin-bottom: 0;
}

.ranking-section h6 {
    color: #495057;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.badge-layer {
    font-size: 0.75rem;
}

.badge-level-1 {
    background-color: #dc3545;
}

.badge-level-2 {
    background-color: #0dcaf0;
}

.badge-pediatric {
    background-color: #ffc107;
    color: #212529;
}

.loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Search functionality styling */
.search-container {
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.15s ease-in-out;
}

.search-result-item:hover {
    background-color: #f8f9fa;
}

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

.search-result-item .town-name {
    font-weight: 600;
    color: #212529;
}

.search-result-item .town-state {
    font-size: 0.875rem;
    color: #6c757d;
}

.search-result-item .town-county {
    font-size: 0.75rem;
    color: #adb5bd;
}

.search-highlight {
    background-color: #fff3cd;
    padding: 0.1rem 0.2rem;
    border-radius: 0.2rem;
}

/* Responsive search */
@media (max-width: 768px) {
    .search-container .input-group {
        width: 250px !important;
    }
}

/* Mobile navbar fixes for Safari */
@media (max-width: 991px) {
    .navbar .container-fluid {
        flex-wrap: nowrap;
    }

    .navbar-brand {
        flex: 1;
        text-align: center;
        margin: 0;
    }

    .navbar-toggler {
        order: 3;
        margin-left: auto;
    }

    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #343a40;
        z-index: 1000;
    }
}

@media (max-width: 576px) {
    .search-container .input-group {
        width: 200px !important;
    }

    .card-header .d-flex {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch !important;
    }

    .search-container {
        order: 2;
    }
}

/* Mobile-optimized popup styles */
.popup-content-mobile {
    max-width: 280px;
    font-size: 0.9rem;
}

.popup-content-mobile h6 {
    font-size: 1rem;
    margin-bottom: 0.25rem !important;
}

.popup-content-mobile .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

.popup-content-mobile small {
    font-size: 0.75rem;
}

.popup-content-mobile strong {
    font-size: 0.85rem;
}

/* Ensure popup button is always visible */
.rank-hospitals-popup-btn {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    margin-top: 0.25rem;
}

/* Mobile-specific popup adjustments */
@media (max-width: 768px) {
    .leaflet-popup-content {
        margin: 0.25rem;
        min-width: 250px;
        max-width: 300px;
    }

    .popup-content-mobile {
        max-width: 100%;
    }

    .popup-content-mobile h6 {
        font-size: 0.9rem;
        margin-bottom: 0.125rem !important;
    }

    .popup-content-mobile .badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
    }

    .popup-content-mobile small {
        font-size: 0.65rem;
    }

    .popup-content-mobile strong {
        font-size: 0.75rem;
    }

    .rank-hospitals-popup-btn {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
        margin-top: 0.125rem;
    }

    /* Mobile ranking table optimizations */
    .ranking-section h6 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .ranking-section .table {
        font-size: 0.75rem;
    }

    .ranking-section .table th,
    .ranking-section .table td {
        padding: 0.25rem 0.5rem;
    }

    .ranking-section .badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
    }
}

.legend {
    line-height: 18px;
    color: #555;
    background-color: white;
    padding: 6px 8px;
    font-family: Arial, Helvetica, sans-serif;
    border-radius: 5px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}

.legend i {
    width: 18px;
    height: 18px;
    float: left;
    margin-right: 8px;
    opacity: 0.7;
}

/* Benefit Comparison Page Styles */
.custom-hospital-marker {
    background: transparent;
    border: none;
}

.benefit-comparison-controls {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.time-threshold-input {
    max-width: 100px;
}

.designation-checkboxes {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.5rem;
}

.results-summary {
    font-size: 0.9rem;
    color: #6c757d;
}

.table-success {
    background-color: rgba(25, 135, 84, 0.1) !important;
}

.search-container {
    position: relative;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 0.9rem;
}

.town-info-details {
    font-size: 0.9rem;
}

.hospital-marker-green {
    background-color: #28a745;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.hospital-marker-red {
    background-color: #dc3545;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.selected-town-marker {
    background: transparent;
    border: none;
}

.selected-town-marker div {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}