/**
 * Modern Location Selector Modal - 2025 Design
 * Inspired by UberEats, DoorDash, Instacart
 * Features: Glassmorphism, smooth animations, autocomplete
 */

/* Modal Overlay */
.location-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 9998;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.location-modal-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  animation: fadeIn 0.3s ease;
}

/* Modal Container - Glassmorphism */
.location-modal {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.location-modal-overlay.active .location-modal {
  transform: scale(1) translateY(0);
}

/* Modal Header */
.location-modal-header {
  padding: 24px 28px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(249, 250, 251, 0.5) 100%);
}

.location-modal-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
}

.location-modal-title i {
  font-size: 24px;
  color: var(--primary);
}

.location-modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 20px;
}

.location-modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: rotate(90deg);
}

/* Modal Body */
.location-modal-body {
  padding: 28px;
  max-height: calc(85vh - 140px);
  overflow-y: auto;
}

/* Search Input with Icon */
.location-search-wrapper {
  position: relative;
  margin-bottom: 24px;
}

.location-search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 20px;
  pointer-events: none;
}

.location-search-input {
  width: 100%;
  padding: 16px 18px 16px 52px;
  border: 2px solid #e5e7eb;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 500;
  color: #1a1a1a;
  background: #fff;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.location-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow:
    0 2px 8px rgba(0, 178, 7, 0.15),
    0 0 0 4px rgba(0, 178, 7, 0.08);
}

.location-search-input::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

/* Autocomplete Suggestions */
.location-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 16px;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  max-height: 300px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}

.location-suggestions.active {
  display: block;
  animation: slideDown 0.2s ease;
}

.location-suggestion-item {
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.location-suggestion-item:hover {
  background: rgba(0, 178, 7, 0.04);
}

.location-suggestion-item i {
  color: var(--primary);
  font-size: 18px;
}

.location-suggestion-content {
  flex: 1;
}

.location-suggestion-main {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 2px;
}

.location-suggestion-sub {
  font-size: 13px;
  color: #6b7280;
}

/* Use Current Location Button */
.use-location-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 178, 7, 0.25);
  margin-bottom: 24px;
}

.use-location-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 178, 7, 0.35);
}

.use-location-btn:active {
  transform: translateY(0);
}

.use-location-btn i {
  font-size: 20px;
}

/* Divider */
.location-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 28px 0;
  color: #9ca3af;
  font-size: 14px;
  font-weight: 500;
}

.location-divider::before,
.location-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
}

/* Recent Locations */
.recent-locations-section {
  margin-bottom: 20px;
}

.recent-locations-title {
  font-size: 14px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.recent-location-item {
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.02);
  border: 2px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.recent-location-item:hover {
  background: rgba(0, 178, 7, 0.04);
  border-color: var(--primary);
  transform: translateX(4px);
}

.recent-location-item i {
  color: var(--primary);
  font-size: 18px;
}

.recent-location-content {
  flex: 1;
}

.recent-location-name {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 2px;
}

.recent-location-address {
  font-size: 13px;
  color: #6b7280;
}

/* Loading State */
.location-loading {
  text-align: center;
  padding: 40px 20px;
}

.location-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(0, 178, 7, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

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

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .location-modal {
    width: 95%;
    max-height: 90vh;
    border-radius: 20px;
  }

  .location-modal-header {
    padding: 20px 20px 16px;
  }

  .location-modal-title {
    font-size: 20px;
  }

  .location-modal-body {
    padding: 20px;
  }

  .location-search-input {
    padding: 14px 16px 14px 48px;
    font-size: 15px;
  }

  .use-location-btn {
    padding: 14px;
    font-size: 15px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
