/* Custom styles for Near Me page */

/* Home Page Hero Section - Mobile improvements */
.hero-section {
    position: relative;
    overflow: hidden;
}

@media (max-width: 640px) {
    .hero-section {
        min-height: auto; /* Remove fixed height on mobile */
        padding: 1.5rem 1rem; /* Further reduced padding */
    }
    
    .hero-section .container {
        padding: 0;
    }
    
    .hero-section h1 {
        font-size: 1.5rem; /* Even smaller for mobile */
        line-height: 1.2;
        margin-bottom: 0.75rem;
    }
    
    .hero-section p {
        font-size: 0.875rem; /* Smaller subtitle */
        line-height: 1.4;
        margin-bottom: 1rem;
    }
    
    .hero-button {
        font-size: 0.875rem;
        padding: 0.75rem 1.5rem;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .hero-section {
        padding: 1rem 0.75rem;
    }
    
    .hero-section h1 {
        font-size: 1.375rem;
    }
    
    .hero-section p {
        font-size: 0.8125rem;
        margin-bottom: 0.875rem;
    }
    
    .hero-button {
        font-size: 0.8125rem;
        padding: 0.625rem 1.25rem;
    }
}

/* Small mobile devices (max width: 400px) */
@media (max-width: 400px) {
    .hero-section {
        padding: 0.75rem 0.5rem;
    }
    
    .hero-section h1 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }
    
    .hero-section p {
        font-size: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .hero-button {
        font-size: 0.75rem;
        padding: 0.5rem 1rem;
    }
}

/* Hero Section - Mobile improvements */
.hero-section {
    padding: 2rem 1rem; /* Reduced padding for mobile */
}

@media (max-width: 640px) {
    .hero-section h1 {
        font-size: 1.75rem; /* Smaller heading for mobile */
        line-height: 1.2;
    }
    
    .hero-section p {
        font-size: 1rem; /* Smaller subtitle for mobile */
        line-height: 1.5;
    }
}

/* Search Section - Mobile improvements */
.search-section {
    padding: 1.5rem 1rem; /* Reduced padding for mobile */
}

.search-container {
    padding: 1rem; /* Reduced padding inside search box */
}

@media (max-width: 640px) {
    .search-container {
        padding: 0.75rem;
        border-radius: 0.5rem;
    }
    
    /* Category select for mobile */
    #category-select {
        font-size: 1rem; /* Larger font for better readability */
        padding: 0.75rem; /* Larger touch target */
        min-height: 48px; /* Minimum touch target size */
    }
    
    /* Search button for mobile */
    #search-btn {
        width: 100%; /* Full width button on mobile */
        padding: 0.875rem 1.5rem; /* Larger touch target */
        font-size: 1rem; /* Larger font */
        min-height: 48px; /* Minimum touch target size */
        margin-top: 0.5rem; /* Add some space above */
    }
}

/* Map container */
#map {
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

@media (max-width: 640px) {
    #map {
        height: 250px !important; /* Smaller map on mobile */
        margin: 0 -1rem; /* Extend to edges */
        border-radius: 0; /* Remove border radius at edges */
    }
    
    .map-section {
        padding: 1rem 0; /* Reduced padding */
    }
    
    .map-header {
        padding: 0.75rem 1rem; /* Adjust header padding */
    }
}

/* Search progress bar */
#search-progress {
    animation: fadeIn 0.3s ease-in-out;
    padding: 0 1rem; /* Add horizontal padding on mobile */
}

.progress-bar {
    transition: width 0.3s ease;
}

/* Results container */
#results-container {
    /* Removed max-height and overflow to show results normally on screen */
}

@media (max-width: 640px) {
    .results-section {
        padding: 1rem 0; /* Reduced padding */
    }
    
    .results-header {
        padding: 0.75rem 1rem; /* Adjust header padding */
        flex-direction: column; /* Stack elements vertically */
        align-items: flex-start; /* Align to start */
        gap: 0.75rem; /* Add gap between elements */
    }
    
    .results-count {
        font-size: 1rem; /* Larger font for mobile */
    }
    
    #refresh-btn {
        width: 100%; /* Full width button */
        padding: 0.75rem 1rem; /* Larger touch target */
        min-height: 44px; /* Minimum touch target size */
        justify-content: center; /* Center content */
    }
}

/* Result cards */
.result-card {
    transition: all 0.2s ease;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
    padding: 1rem; /* Consistent padding */
    margin-bottom: 1rem; /* Consistent spacing */
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

@media (max-width: 640px) {
    .result-card {
        padding: 1rem; /* Consistent padding */
        margin: 0 1rem 1rem 1rem; /* Add horizontal margins */
        border-radius: 0.75rem; /* Slightly larger radius */
    }
    
    .result-card h3 {
        font-size: 1.125rem; /* Larger font for better readability */
        line-height: 1.3;
        margin-bottom: 0.5rem;
        word-break: break-word; /* Prevent long text overflow */
    }
    
    .result-card p {
        font-size: 0.9375rem; /* Readable font size */
        line-height: 1.4;
        margin-bottom: 1rem;
        word-break: break-word; /* Prevent long text overflow */
    }
    
    .result-card .flex {
        flex-direction: column; /* Stack buttons vertically on mobile */
        gap: 0.5rem; /* Add gap between buttons */
    }
    
    .action-button {
        width: 100%; /* Full width buttons */
        padding: 0.875rem 1rem; /* Larger touch targets */
        font-size: 0.9375rem; /* Readable font size */
        min-height: 48px; /* Minimum touch target size */
        justify-content: center; /* Center button content */
        display: flex; /* Ensure flex display */
        align-items: center; /* Center vertically */
        gap: 0.5rem; /* Space between icon and text */
    }
    
    /* Ensure text doesn't overflow on mobile */
    .result-card * {
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%; /* Prevent overflow */
    }
    
    /* Status and distance badges */
    .result-card .flex.items-center.space-x-2 {
        flex-wrap: wrap; /* Allow badges to wrap */
        gap: 0.25rem; /* Small gap between badges */
    }
    
    .status-badge, .distance-badge {
        font-size: 0.75rem; /* Smaller font for badges */
        padding: 0.25rem 0.5rem; /* Adjust padding */
    }
}

/* Grid adjustments for mobile */
@media (max-width: 640px) {
    .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-3 {
        grid-template-columns: 1fr; /* Single column on mobile */
        gap: 0; /* Remove gap as cards have their own margins */
    }
}

/* No results message */
@media (max-width: 640px) {
    #no-results {
        padding: 2rem 1rem; /* Adjust padding */
    }
    
    #no-results .max-w-md {
        max-width: 100%; /* Full width on mobile */
        padding: 1.5rem; /* More padding inside */
    }
}

/* Status badges */
.status-badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.status-open {
    background-color: #dcfce7;
    color: #166534;
}

.status-closed {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-unknown {
    background-color: #f3f4f6;
    color: #4b5563;
}

/* Distance badge */
.distance-badge {
    background-color: #dbeafe;
    color: #1e40af;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

/* Action buttons */
.action-button {
    transition: all 0.2s ease;
    font-weight: 500;
    text-align: center;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.action-button:hover {
    transform: translateY(-1px);
}

.action-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loading states */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 0.25rem solid #e5e7eb;
    border-top: 0.25rem solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Map markers */
.user-location-marker {
    background-color: #3b82f6;
    border: 2px solid white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .result-card {
        margin-bottom: 0.75rem;
    }
    
    .action-button {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    #map {
        height: 300px;
    }
}

/* No results state */
.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.no-results i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Category selector */
#category-select {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#category-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Search button */
#search-btn {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

#search-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

#search-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Refresh button */
#refresh-btn {
    transition: all 0.2s ease;
}

#refresh-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Results header */
.results-header {
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 10;
    border-bottom: 1px solid #e5e7eb;
}

/* Limit message */
.limit-message {
    background-color: #dbeafe;
    border: 1px solid #93c5fd;
    color: #1e40af;
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* Popup content */
.leaflet-popup-content {
    font-family: system-ui, -apple-system, sans-serif;
}

.leaflet-popup-content h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.leaflet-popup-content p {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: #6b7280;
}

.leaflet-popup-content button {
    margin-right: 0.5rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Mobile-specific enhancements */
@media (max-width: 640px) {
    /* Improve scrolling behavior */
    body {
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        overscroll-behavior-y: contain; /* Prevent bounce scrolling */
    }
    
    /* Better touch feedback */
    .result-card,
    .action-button,
    #search-btn,
    #refresh-btn {
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1); /* Subtle tap highlight */
        touch-action: manipulation; /* Disable double-tap zoom */
    }
    
    /* Prevent horizontal scrolling */
    .container {
        overflow-x: hidden;
    }
    
    /* Improve map interaction on mobile */
    #map {
        touch-action: pan-y; /* Allow vertical panning but prevent horizontal */
    }
    
    /* Better loading states for mobile */
    #map-loading {
        background-color: rgba(255, 255, 255, 0.95); /* More opaque on mobile */
    }
    
    #results-loading {
        padding: 2rem 1rem; /* More padding for mobile */
    }
    
    /* Mobile-friendly popup content */
    .leaflet-popup-content {
        min-width: 250px; /* Minimum width for mobile */
        max-width: 280px; /* Maximum width for mobile */
        font-size: 0.875rem; /* Readable font size */
    }
    
    .leaflet-popup-content h3 {
        font-size: 1rem; /* Larger heading in popup */
        margin-bottom: 0.75rem;
    }
    
    .leaflet-popup-content p {
        font-size: 0.875rem;
        margin-bottom: 0.75rem;
        line-height: 1.4;
    }
    
    .leaflet-popup-content button {
        display: block; /* Stack buttons vertically */
        width: 100%;
        margin-bottom: 0.5rem;
        padding: 0.5rem;
        font-size: 0.875rem;
        text-align: center;
        border-radius: 0.375rem;
    }
    
    .leaflet-popup-content button:last-child {
        margin-bottom: 0;
    }
    
    /* Improve category selector on mobile */
    #category-select {
        appearance: none; /* Remove default appearance */
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
        background-position: right 0.5rem center;
        background-repeat: no-repeat;
        background-size: 1.5em 1.5em;
        padding-right: 2.5rem; /* Space for dropdown arrow */
    }
    
    /* Better focus states for mobile */
    #category-select:focus,
    #search-btn:focus,
    #refresh-btn:focus,
    .action-button:focus {
        outline: 2px solid #3b82f6;
        outline-offset: 2px;
    }
    
    /* Improve loading spinner visibility on mobile */
    .fa-spinner {
        font-size: 1.5rem; /* Larger spinner */
    }
    
    /* Better spacing for limit message */
    .limit-message {
        margin: 0 1rem 1rem 1rem; /* Add horizontal margins */
        padding: 1rem; /* More padding */
        font-size: 0.875rem;
        line-height: 1.4;
    }
}

/* Small mobile devices (max width: 480px) */
@media (max-width: 480px) {
    .hero-section {
        padding: 1.5rem 1rem;
    }
    
    .hero-section h1 {
        font-size: 1.5rem;
    }
    
    .hero-section p {
        font-size: 0.9375rem;
    }
    
    .search-section {
        padding: 1rem 0;
    }
    
    .search-container {
        padding: 0.5rem;
        margin: 0 0.5rem;
        border-radius: 0.5rem;
    }
    
    .result-card {
        margin: 0 0.5rem 0.75rem 0.5rem;
        padding: 0.75rem;
    }
    
    .result-card h3 {
        font-size: 1rem;
    }
    
    .result-card p {
        font-size: 0.875rem;
    }
    
    .action-button {
        font-size: 0.875rem;
        padding: 0.75rem;
    }
    
    #map {
        height: 200px !important;
    }
}

/* Landscape orientation improvements */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        padding: 1rem 1rem;
    }
    
    .search-section {
        padding: 1rem 0;
    }
    
    .map-section {
        padding: 0.5rem 0;
    }
    
    #map {
        height: 200px !important;
    }
    
    .results-section {
        padding: 0.5rem 0;
    }
    
    .result-card {
        margin-bottom: 0.5rem;
    }
}