/**
 * Location Lookup Styles
 * Styles for the address lookup functionality with bubble UI
 */

/* Main wrapper */
.location-lookup-wrapper {
  position: relative;
  width: 100%;
  margin-top: 4px;
}

/* Search input styling */
.location-search-input {
  margin-top: 0;
}

div[data-name="user_location_lookup"] .acf-input-wrap {
  overflow: initial;
}

/* Location bubble styling */
.location-bubble {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  color: white;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.4;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.location-bubble .location-text {
  margin-right: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #134c8b;
  border-radius: 20px;
  padding: 4px 36px 4px 18px;
  position: relative;
}

.location-bubble .location-remove {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
  position: absolute;
  right: 8px;
  top: 5px;
}

.location-bubble .location-remove:hover {
  background: rgba(255, 255, 255, 0.3);
}

.location-bubble .location-remove:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 1px;
}

/* Dropdown styling */
.location-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
}

.location-item {
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
}

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

.location-item:hover,
.location-item.active {
  background-color: #f8f9fa;
}

.location-item .location-main {
  font-weight: 500;
  color: #333;
  margin-bottom: 2px;
}

.location-item .location-details {
  font-size: 12px;
  color: #666;
  line-height: 1.3;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .location-bubble {
    padding: 6px 10px;
    font-size: 13px;
  }

  .location-bubble .location-remove {
    width: 18px;
    height: 18px;
    font-size: 14px;
  }

  .location-item {
    padding: 10px;
  }

  .location-item .location-main {
    font-size: 13px;
  }

  .location-item .location-details {
    font-size: 11px;
  }
}

/* Integration with MemberPress styles */

.mp-form-row .location-bubble {
  min-height: 46px;
  border-radius: 2px;
}

/* Integration with ACF admin styles */
.acf-input .location-lookup-wrapper {
  margin: 0;
}

.acf-input .location-dropdown {
  border-radius: 0 0 3px 3px;
}

/* Hide original field when wrapper is active */
.location-lookup-wrapper input[data-location-lookup-initialized] {
  display: none !important;
}

/* Accessibility improvements */
.location-bubble:focus-within {
  outline: 2px solid #007cba;
  outline-offset: 2px;
}

.location-item:focus {
  outline: 2px solid #007cba;
  outline-offset: -2px;
  background-color: #f8f9fa;
}

/* Loading state */
.location-dropdown.loading::before {
  content: "Searching...";
  display: block;
  padding: 12px;
  text-align: center;
  color: #666;
  font-style: italic;
}

/* Error state */
.location-dropdown.error::before {
  content: "Search failed. Please try again.";
  display: block;
  padding: 12px;
  text-align: center;
  color: #d63384;
}

/* No results state */
.location-dropdown.no-results::before {
  content: "No locations found. Try a different search term.";
  display: block;
  padding: 12px;
  text-align: center;
  color: #666;
  font-style: italic;
}

/* Animation for smooth transitions */
.location-bubble,
.location-search-input,
.location-dropdown {
  transition: all 0.2s ease;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .location-bubble {
    background: #000;
    border: 2px solid #fff;
  }

  .location-dropdown {
    border: 2px solid #000;
  }

  .location-item:hover,
  .location-item.active {
    background-color: #000;
    color: #fff;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .location-bubble,
  .location-search-input,
  .location-dropdown,
  .location-item,
  .location-remove {
    transition: none;
  }
}
