/**
 * Renter-Focused Autocomplete Styles
 *
 * Clean, simple styling for the renter-focused autocomplete dropdown
 * that prioritizes usability and clarity over complex marketplace features.
 */

/* Main autocomplete container */
.renter-autocomplete {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  padding: 0;
  font-family: var(--font-family-sans);
  border-radius: 16px;
  overflow: hidden;
}

/* Header section - unified background */
.autocomplete-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--discover-popover-border, rgba(214, 211, 208, 0.68));
  background: transparent;
}

.autocomplete-title {
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--discover-popover-text, #292524);
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-icon {
  font-size: 16px;
}

.autocomplete-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--discover-popover-text-muted, #57534e);
  font-weight: 400;
}

/* Suggestions container */
.autocomplete-suggestions {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.5rem;
  max-height: none;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 113, 108, 0.45) rgba(0, 0, 0, 0.04);
}

/* Initially limit visible rows when collapsed */
.autocomplete-suggestions:not(.expanded),
.autocomplete-suggestions[data-expanded="false"] {
  overflow-y: auto !important;
}

/* Hide items with hidden class when collapsed */
.autocomplete-suggestions:not(.expanded) .autocomplete-item-hidden,
.autocomplete-suggestions[data-expanded="false"] .autocomplete-item-hidden {
  display: none !important;
}

/* Ensure items are visible when expanded */
.autocomplete-suggestions.expanded .autocomplete-item,
.autocomplete-suggestions[data-expanded="true"] .autocomplete-item {
  display: flex !important;
}

/* Show more button */
.autocomplete-show-more {
  margin: 0.25rem 0.5rem 0.35rem;
  padding: 0.65rem 0.75rem;
  text-align: center;
  border: 1px solid var(--discover-popover-border, rgba(214, 211, 208, 0.68));
  border-radius: 0.75rem;
  background: var(--discover-popover-bg-elevated, #ffffff);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  font-size: 13px;
  font-weight: 600;
  color: var(--discover-popover-text, #292524);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.autocomplete-show-more > span {
  padding: 2px 4px;
}

.autocomplete-show-more span,
.autocomplete-item span,
.autocomplete-header span,
.autocomplete-title span {
  border-radius: 4px;
  display: inline-block;
}

.autocomplete-show-more:hover {
  background: var(--discover-popover-hover, rgba(245, 245, 244, 0.92));
  border-color: rgba(120, 113, 108, 0.28);
}

.autocomplete-show-more:active {
  background: var(--discover-popover-active, rgba(231, 229, 228, 0.9));
}

.dark .autocomplete-show-more {
  background: var(--discover-popover-bg-dark-elevated, #2f2f2f);
  border-color: var(--discover-popover-border-dark, rgba(82, 82, 82, 0.72));
  color: var(--discover-popover-text-dark, #f5f5f4);
}

.dark .autocomplete-show-more:hover {
  background: var(--discover-popover-hover-dark, rgba(64, 64, 64, 0.78));
}

.dark .autocomplete-show-more:active {
  background: var(--discover-popover-active-dark, rgba(82, 82, 82, 0.72));
}

/* Individual suggestion items */
.autocomplete-item {
  padding: 0.75rem 0.85rem;
  margin: 0 0 0.35rem;
  cursor: pointer;
  border: none;
  background: transparent;
  width: calc(100% - 0.25rem);
  text-align: left;
  transition: background-color 0.15s ease;
  border-radius: 0.75rem;
  min-height: 48px !important;
  display: flex !important;
  align-items: flex-start !important;
}

.autocomplete-item:last-child {
  margin-bottom: 0;
}

.autocomplete-loading-item {
  pointer-events: none;
  opacity: 0.72;
}

.autocomplete-loading-item .suggestion-name {
  font-weight: 500 !important;
  color: var(--discover-popover-text-muted, #57534e) !important;
}

.autocomplete-item:hover,
.autocomplete-item:focus-visible {
  background-color: var(--discover-popover-hover, rgba(245, 245, 244, 0.92));
  outline: none;
}

.autocomplete-item:active {
  background-color: var(--discover-popover-active, rgba(231, 229, 228, 0.9));
}

.dark .autocomplete-item:hover,
.dark .autocomplete-item:focus-visible {
  background-color: var(--discover-popover-hover-dark, rgba(64, 64, 64, 0.78));
}

.dark .autocomplete-item:active {
  background-color: var(--discover-popover-active-dark, rgba(82, 82, 82, 0.72));
}

/* Current location — compact action button on one line */
.current-location-item {
  align-items: center !important;
  justify-content: center !important;
  flex-wrap: nowrap !important;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem !important;
  margin: 0 0 0.5rem;
  width: 100%;
  min-height: 2.5rem !important;
  overflow: hidden;
  border-radius: 0.75rem;
  border: 1px solid var(--discover-popover-border, rgba(214, 211, 208, 0.68));
  background: var(--discover-popover-bg-elevated, #ffffff);
  color: var(--discover-popover-text, #292524);
  text-align: center;
  font-weight: 600;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.dark .current-location-item {
  background: var(--discover-popover-bg-dark-elevated, #2f2f2f);
  border-color: var(--discover-popover-border-dark, rgba(82, 82, 82, 0.72));
  color: var(--discover-popover-text-dark, #f5f5f4);
}

.current-location-item:hover,
.current-location-item:focus-visible {
  background: var(--discover-popover-hover, rgba(245, 245, 244, 0.92));
  border-color: rgba(120, 113, 108, 0.32);
}

.dark .current-location-item:hover,
.dark .current-location-item:focus-visible {
  background: var(--discover-popover-hover-dark, rgba(64, 64, 64, 0.78));
  border-color: rgba(115, 115, 115, 0.36);
}

.current-location-item:active {
  background: var(--discover-popover-active, rgba(231, 229, 228, 0.9));
}

.dark .current-location-item:active {
  background: var(--discover-popover-active-dark, rgba(82, 82, 82, 0.72));
}

/* GPS already active — status row, not a first-time prompt */
.current-location-item--active {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.06);
}

.dark .current-location-item--active {
  border-color: rgba(96, 165, 250, 0.4);
  background: rgba(37, 99, 235, 0.12);
}

.current-location-item--active .location-description {
  font-weight: 500;
  color: var(--discover-brand-accent-fg, var(--color-brand-accent-fg, #0f5a56));
}

.dark .current-location-item--active .location-description {
  color: var(--discover-brand-accent-fg, var(--color-brand-accent-fg, #5eead4));
}

.current-location-item .location-icon {
  color: var(--discover-brand-accent-fg, var(--color-brand-accent-fg, #0f5a56));
  flex-shrink: 0;
}

.dark .current-location-item .location-icon {
  color: var(--discover-brand-accent-fg, var(--color-brand-accent-fg, #5eead4));
}

.current-location-item .location-icon,
.current-location-item .location-name,
.current-location-item .current-location-separator {
  flex: 0 0 auto !important;
}

.current-location-item .location-name {
  flex-shrink: 0;
  white-space: nowrap !important;
  display: inline !important;
  overflow: visible !important;
  -webkit-line-clamp: unset !important;
  line-clamp: unset !important;
  -webkit-box-orient: unset !important;
  max-height: none !important;
  font-weight: 600;
  color: inherit;
}

.current-location-item .location-description {
  flex: 1 1 auto !important;
  min-width: 0;
  white-space: nowrap !important;
  display: inline !important;
  overflow: hidden !important;
  text-overflow: ellipsis;
  -webkit-line-clamp: unset !important;
  line-clamp: unset !important;
  -webkit-box-orient: unset !important;
  max-height: none !important;
  font-weight: 400;
  color: var(--discover-popover-text-muted, #57534e);
}

.dark .current-location-item .location-description {
  color: var(--discover-popover-text-muted-dark, #a8a29e);
}

.current-location-separator {
  flex-shrink: 0;
  color: var(--discover-popover-text-muted, #57534e);
  font-weight: 400;
  user-select: none;
}

.dark .current-location-separator {
  color: var(--discover-popover-text-muted-dark, #a8a29e);
}

#unified-autocomplete .current-location-item .location-name,
#unified-autocomplete .current-location-item .location-description {
  display: inline !important;
  -webkit-box-orient: unset !important;
  word-break: normal !important;
}

/* Item layout */
.item-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.item-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-details {
  margin-left: 28px;
}

/* Icons */
.location-icon,
.type-icon,
.title-icon {
  font-size: 16px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--discover-popover-text-muted, #57534e);
}

.dark .location-icon,
.dark .type-icon,
.dark .title-icon {
  color: var(--discover-popover-text-muted-dark, #a8a29e);
}

/* Text styling */
.location-name,
.suggestion-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--discover-popover-text, #292524);
  line-height: 1.4;
  border-radius: 4px;
  white-space: normal !important;
  overflow: hidden !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  word-break: break-word !important;
  max-height: 2.8em !important;
}

.dark .location-name,
.dark .suggestion-name {
  color: var(--discover-popover-text-dark, #f5f5f4);
}

.location-description,
.suggestion-secondary {
  font-size: 12px;
  color: var(--discover-popover-text-muted, #57534e);
  line-height: 1.3;
  border-radius: 4px;
  white-space: normal !important;
  overflow: hidden !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  word-break: break-word !important;
  max-height: 2.6em !important;
}

.dark .location-description,
.dark .suggestion-secondary {
  color: var(--discover-popover-text-muted-dark, #a8a29e);
}

.suggestion-item .suggestion-name {
  font-weight: 600;
}

.suggestion-item .suggestion-secondary {
  margin-top: 2px;
}

/* Shared discover panel scroll styling */
.discover-panel-scroll {
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 113, 108, 0.45) rgba(0, 0, 0, 0.04);
}

.discover-panel-scroll::-webkit-scrollbar,
.autocomplete-suggestions::-webkit-scrollbar {
  width: 8px;
}

.discover-panel-scroll::-webkit-scrollbar-track,
.autocomplete-suggestions::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 4px;
}

.discover-panel-scroll::-webkit-scrollbar-thumb,
.autocomplete-suggestions::-webkit-scrollbar-thumb {
  background: rgba(120, 113, 108, 0.35);
  border-radius: 4px;
}

.discover-panel-scroll::-webkit-scrollbar-thumb:hover,
.autocomplete-suggestions::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 113, 108, 0.5);
}

.dark .discover-panel-scroll,
.dark .autocomplete-suggestions {
  scrollbar-color: rgba(163, 163, 163, 0.45) rgba(0, 0, 0, 0.15);
}

.dark .discover-panel-scroll::-webkit-scrollbar-thumb,
.dark .autocomplete-suggestions::-webkit-scrollbar-thumb {
  background: rgba(163, 163, 163, 0.35);
}

.dark .discover-panel-scroll::-webkit-scrollbar-thumb:hover,
.dark .autocomplete-suggestions::-webkit-scrollbar-thumb:hover {
  background: rgba(163, 163, 163, 0.5);
}

/* Mobile adjustments */
@media (max-width: 567px) {
  .renter-autocomplete {
    border-radius: var(--discover-mobile-panel-radius, 0.875rem);
  }

  .autocomplete-suggestions {
    padding: 0.35rem;
  }

  .autocomplete-item {
    padding: 0.45rem 0.55rem;
    margin: 0 0 0.2rem;
    min-height: 2.125rem !important;
    border-radius: 0.625rem;
  }

  .current-location-item {
    margin: 0 0 0.3rem;
    padding: 0.5rem 0.625rem !important;
    gap: 0.375rem;
    min-height: 2.25rem !important;
    flex-wrap: nowrap !important;
  }

  .current-location-item .location-name,
  .current-location-item .location-description {
    font-size: 0.8125rem;
  }

  .item-header {
    gap: 0.5rem;
  }

  .item-details {
    margin-left: 1.375rem;
  }

  .location-name,
  .suggestion-name {
    font-size: 0.8125rem;
    max-height: 1.35em !important;
    -webkit-line-clamp: 1 !important;
    line-clamp: 1 !important;
  }

  .location-description,
  .suggestion-secondary {
    font-size: 0.6875rem;
    max-height: 1.3em !important;
    -webkit-line-clamp: 1 !important;
    line-clamp: 1 !important;
  }

  .current-location-item .location-name,
  .current-location-item .location-description {
    max-height: none !important;
    -webkit-line-clamp: unset !important;
    line-clamp: unset !important;
  }

  .autocomplete-show-more {
    margin: 0.15rem 0.35rem 0.2rem;
    padding: 0.45rem 0.625rem;
    font-size: 0.75rem;
    gap: 0.375rem;
  }
}

@media (max-width: 360px) {
  .autocomplete-item {
    min-height: 2rem !important;
  }
}
