/* ====================================
   Enhanced Location & Map Modal Styles
   ==================================== */

/* Location Button States */
.locate-me-btn {
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.locate-me-btn:hover {
    color: #667eea !important;
    transform: translateY(-2px);
}

.locate-me-btn.locating {
    pointer-events: none;
    opacity: 0.7;
}

.locate-me-btn.located {
    color: #28a745 !important;
}

.locate-me-btn.location-error {
    color: #dc3545 !important;
}

.locate-me-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Location Input Enhancement */
input[name="search"][data-location-set="true"] {
    border-color: #667eea;
    background: linear-gradient(to right, #f8f9ff, #ffffff);
}

/* Map Modal Enhancements */
#locationMapModal .modal-dialog {
    max-width: 900px;
}

#locationMapModal .modal-content {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Map Container */
#locationMap {
    position: relative;
    border-radius: 0;
}

.leaflet-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border-radius: 0;
}

/* Custom Marker Styles */
.custom-marker {
    background: transparent !important;
    border: none !important;
    animation: markerBounce 0.5s ease-out;
}

@keyframes markerBounce {
    0% {
        transform: translateY(-50px) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translateY(-10px) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Map Controls */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-control-zoom a {
    background: white !important;
    color: #667eea !important;
    border: none !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
    font-weight: bold !important;
    transition: all 0.2s ease !important;
}

.leaflet-control-zoom a:hover {
    background: #667eea !important;
    color: white !important;
}

/* Search Input in Modal */
#mapSearchInput {
    font-size: 15px;
    padding: 14px 16px 14px 45px;
    transition: all 0.3s ease;
}

#mapSearchInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    outline: none;
}

/* Selected Address Display */
#selectedAddress {
    transition: all 0.3s ease;
    min-height: 70px;
}

#selectedAddress:has(p.text-dark) {
    background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%) !important;
    border-color: #667eea !important;
}

/* Modal Buttons */
#useCurrentLocation {
    transition: all 0.3s ease;
    font-weight: 500;
    padding: 12px 24px;
}

#useCurrentLocation:hover {
    background: #f8f9fa;
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
}

#confirmLocation {
    transition: all 0.3s ease;
    padding: 12px 32px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#confirmLocation:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

#confirmLocation:active {
    transform: translateY(0);
}

/* Loading Spinner in Address */
#selectedAddress .spinner-border-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
    #locationMapModal .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    #locationMap {
        height: 350px !important;
    }

    .locate-me-btn span {
        display: none !important;
    }

    #useCurrentLocation span,
    #confirmLocation span {
        display: inline;
    }
}

@media (max-width: 576px) {
    #locationMap {
        height: 300px !important;
    }

    #mapSearchInput {
        font-size: 14px;
        padding: 12px 14px 12px 42px;
    }

    #useCurrentLocation,
    #confirmLocation {
        padding: 10px 16px;
        font-size: 14px;
    }

    .modal-header h5 {
        font-size: 16px;
    }
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
    padding: 16px;
    font-size: 14px;
}

.leaflet-popup-tip {
    display: none;
}

/* Map Attribution */
.leaflet-control-attribution {
    font-size: 10px;
    background: rgba(255, 255, 255, 0.8) !important;
    padding: 2px 5px !important;
}

/* Loading State for Map */
#locationMap .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
}

/* Smooth Transitions */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

/* Icon Animations */
.fa-location-dot,
.fa-location-crosshairs {
    transition: all 0.3s ease;
}

.locate-me-btn:hover .fa-location-crosshairs {
    transform: scale(1.1);
}

/* Distance Badge in Restaurant Cards */
.restaurant-card .distance-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Delivery Fee Display */
.delivery-fee-display {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
}

.delivery-fee-display.free-delivery {
    background: linear-gradient(135deg, #d4fc79 0%, #96e6a1 100%);
    border-color: #96e6a1;
}

.delivery-fee-display .fee-amount {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}

.delivery-fee-display.free-delivery .fee-amount {
    color: #2d7738;
}

/* Pulse Animation for Active Location */
@keyframes locationPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.location-active {
    animation: locationPulse 2s ease-in-out infinite;
}

/* Enhanced Search Bar */
.search-adjust1 {
    position: relative;
    transition: all 0.3s ease;
}

.search-adjust1:focus-within {
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.search-adjust1 .fa-location-dot {
    cursor: pointer;
    transition: all 0.2s ease;
    color: #667eea;
}

.search-adjust1 .fa-location-dot:hover {
    transform: scale(1.2);
    color: #764ba2;
}

/* Tooltip for Location Icon */
.search-adjust1 .fa-location-dot[data-bs-toggle="tooltip"] {
    cursor: help;
}

/* Modal Backdrop */
#locationMapModal.show ~ .modal-backdrop {
    background-color: rgba(0, 0, 0, 0.7);
}

/* Success/Error States */
.location-success {
    border-color: #28a745 !important;
    background: #d4edda !important;
}

.location-error {
    border-color: #dc3545 !important;
    background: #f8d7da !important;
}

/* Dragging Cursor */
.leaflet-grab {
    cursor: grab;
}

.leaflet-dragging .leaflet-grab {
    cursor: grabbing;
}

/* Smooth Loading */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Accessibility */
.locate-me-btn:focus,
#useCurrentLocation:focus,
#confirmLocation:focus,
#mapSearchInput:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Dark Mode Support (if applicable) */
@media (prefers-color-scheme: dark) {
    .leaflet-container {
        filter: invert(1) hue-rotate(180deg);
    }

    .leaflet-container img {
        filter: invert(1) hue-rotate(180deg);
    }
}