/**
 * 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 {
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Header section */
.autocomplete-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid #f1f5f9;
  background: #fafafa;
}

.autocomplete-title {
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.autocomplete-subtitle {
  margin: 0;
  font-size: 12px;
  color: #64748b;
  font-weight: 400;
}

/* Suggestions container */
.autocomplete-suggestions {
  padding: 8px 0;
  max-height: 320px;
  overflow-y: auto;
}

/* Initially limit height to show only first few items */
.autocomplete-suggestions:not(.expanded) {
  max-height: 240px; /* Show approximately 4 items */
  overflow-y: hidden;
}

/* 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 {
  padding: 12px 16px;
  text-align: center;
  border-top: 1px solid #f1f5f9;
  background: #fafafa;
  cursor: pointer;
  transition: background-color 0.15s ease;
  font-size: 14px;
  font-weight: 500;
  color: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.autocomplete-show-more:hover {
  background: #f1f5f9;
}

.autocomplete-show-more:active {
  background: #e2e8f0;
}

.dark .autocomplete-show-more {
  background: #1e293b;
  border-top-color: #334155;
  color: #60a5fa;
}

.dark .autocomplete-show-more:hover {
  background: #334155;
}

.dark .autocomplete-show-more:active {
  background: #475569;
}

/* Individual suggestion items */
.autocomplete-item {
  padding: 10px 16px; /* Reduced padding for more compact feel */
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background-color 0.15s ease;
  border-bottom: 1px solid #f1f5f9; /* Cleaner border */
  /* CRITICAL: Ensure enough height for 2-line text */
  min-height: 48px !important; /* Slightly reduced for compactness */
  display: flex !important;
  align-items: flex-start !important;
}

.autocomplete-item:hover {
  background-color: #f8fafc; /* Clean hover state */
}

.autocomplete-item:active {
  background-color: #f1f5f9;
}

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

/* Current location item styling */
.current-location-item {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  margin: 0 8px 8px;
  border-radius: 8px;
  border-bottom: none !important;
}

.current-location-item:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  color: white;
}

.current-location-item .location-icon,
.current-location-item .location-name,
.current-location-item .location-description {
  color: white;
}

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

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

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

/* Icons */
.location-icon,
.type-icon {
  font-size: 16px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

/* Text styling */
.location-name,
.suggestion-name {
  font-size: 14px;
  font-weight: 500;
  color: #1e293b;
  line-height: 1.4;
  /* CRITICAL: Enable multi-line display for long location names */
  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; /* ~2 lines at 1.4 line-height */
}

.location-description,
.suggestion-secondary {
  font-size: 12px;
  color: #64748b;
  line-height: 1.3;
  /* CRITICAL: Enable multi-line display for secondary text */
  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; /* ~2 lines at 1.3 line-height */
}

/* Suggestion item specific styling */
.suggestion-item .suggestion-name {
  font-weight: 500;
}

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

/* Scrollbar styling */
.autocomplete-suggestions::-webkit-scrollbar {
  width: 6px;
}

.autocomplete-suggestions::-webkit-scrollbar-track {
  background: #f8fafc;
}

.autocomplete-suggestions::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.autocomplete-suggestions::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Dark mode support - Class-based (not system preference) */
html.dark .renter-autocomplete,
body.dark .renter-autocomplete,
.dark .renter-autocomplete {
  background: #1e293b !important;
  color: #f1f5f9 !important;
}

html.dark .autocomplete-header,
body.dark .autocomplete-header,
.dark .autocomplete-header {
  background: #1e293b !important; /* Cleaner dark background */
  border-bottom-color: #334155 !important; /* Sharper dark border */
}

html.dark .autocomplete-title,
body.dark .autocomplete-title,
.dark .autocomplete-title {
  color: #f1f5f9 !important;
}

html.dark .autocomplete-subtitle,
body.dark .autocomplete-subtitle,
.dark .autocomplete-subtitle {
  color: #94a3b8 !important;
}

html.dark .autocomplete-item,
body.dark .autocomplete-item,
.dark .autocomplete-item {
  border-bottom-color: #334155 !important;
}

html.dark .autocomplete-item:hover,
body.dark .autocomplete-item:hover,
.dark .autocomplete-item:hover {
  background-color: #334155 !important;
}

html.dark .autocomplete-item:active,
body.dark .autocomplete-item:active,
.dark .autocomplete-item:active {
  background-color: #475569 !important;
}

html.dark .location-name,
html.dark .suggestion-name,
body.dark .location-name,
body.dark .suggestion-name,
.dark .location-name,
.dark .suggestion-name {
  color: #f1f5f9 !important;
}

html.dark .location-description,
html.dark .suggestion-secondary,
body.dark .location-description,
body.dark .suggestion-secondary,
.dark .location-description,
.dark .suggestion-secondary {
  color: #94a3b8 !important;
}

html.dark .autocomplete-suggestions::-webkit-scrollbar-track,
body.dark .autocomplete-suggestions::-webkit-scrollbar-track,
.dark .autocomplete-suggestions::-webkit-scrollbar-track {
  background: #334155 !important;
}

html.dark .autocomplete-suggestions::-webkit-scrollbar-thumb,
body.dark .autocomplete-suggestions::-webkit-scrollbar-thumb,
.dark .autocomplete-suggestions::-webkit-scrollbar-thumb {
  background: #475569 !important;
}

html.dark .autocomplete-suggestions::-webkit-scrollbar-thumb:hover,
body.dark .autocomplete-suggestions::-webkit-scrollbar-thumb:hover,
.dark .autocomplete-suggestions::-webkit-scrollbar-thumb:hover {
  background: #64748b !important;
}

/* Mobile responsive adjustments - More compact for touch screens */
@media (max-width: 640px) {
  .autocomplete-header {
    padding: 10px 12px 6px; /* More compact header */
  }
  
  .autocomplete-item {
    padding: 8px 12px !important; /* More compact padding for touch */
    min-height: 44px !important; /* Reduced height for compactness */
  }
  
  .item-details {
    margin-left: 20px; /* Reduced margin */
  }
  
  .current-location-item {
    margin: 0 4px 6px;
  }
  
  /* More compact text on mobile */
  .location-name,
  .suggestion-name {
    font-size: 13px !important; /* Slightly smaller for mobile */
    line-height: 1.35 !important; /* Tighter line height */
  }
  
  .location-description,
  .suggestion-secondary {
    font-size: 11px !important; /* Smaller secondary text */
    line-height: 1.3 !important;
  }
}

/* Focus states for accessibility */
.autocomplete-item:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
  background-color: #f8fafc;
}

.current-location-item:focus {
  outline: 2px solid #ffffff;
  outline-offset: -2px;
}

/* Loading state (if needed) */
.autocomplete-loading {
  padding: 20px;
  text-align: center;
  color: #64748b;
  font-size: 14px;
}

.autocomplete-loading::before {
  content: "⏳";
  margin-right: 8px;
}

/* Empty state */
.autocomplete-empty {
  padding: 20px;
  text-align: center;
  color: #64748b;
  font-size: 14px;
}

.autocomplete-empty::before {
  content: "🔍";
  margin-right: 8px;
}

/* CRITICAL: Ensure proper contrast on dark overlays and backgrounds */
.dark *[style*="background: rgba(0"],
.dark *[style*="background-color: rgba(0"],
html.dark *[style*="background: rgba(0"],
html.dark *[style*="background-color: rgba(0"],
body.dark *[style*="background: rgba(0"],
body.dark *[style*="background-color: rgba(0"] {
  color: #f9fafb !important; /* Light text on dark backgrounds */
}

/* Ensure text is light on any very dark background */
*[style*="background: #0"],
*[style*="background-color: #0"],
*[style*="background: rgba(0, 0, 0"],
*[style*="background-color: rgba(0, 0, 0"] {
  color: #f9fafb !important; /* Light text on very dark backgrounds */
}

/* Override any gray-800 text that might appear on dark backgrounds in dark mode */
.dark .text-gray-800,
html.dark .text-gray-800,
body.dark .text-gray-800,
.dark [style*="color: #ffffff"],
html.dark [style*="color: #ffffff"],
body.dark [style*="color: #ffffff"] {
  color: #f9fafb !important; /* Light text in dark mode */
}

/* ULTRA-AGGRESSIVE CONTRAST FIX - Override any remaining gray-800 text in dark mode */

/* NUCLEAR OPTION: Force white text on any element with gray-800 color in dark contexts */
html.dark *[style*="color: rgb(31, 41, 55)"],
body.dark *[style*="color: rgb(31, 41, 55)"],
.dark *[style*="color: rgb(31, 41, 55)"],
html.dark *[style*="color:rgb(31, 41, 55)"],
body.dark *[style*="color:rgb(31, 41, 55)"],
.dark *[style*="color:rgb(31, 41, 55)"],
html.dark *[style*="color: rgb(31,41,55)"],
body.dark *[style*="color: rgb(31,41,55)"],
.dark *[style*="color: rgb(31,41,55)"],
html.dark *[style*="color:rgb(31,41,55)"],
body.dark *[style*="color:rgb(31,41,55)"],
.dark *[style*="color:rgb(31,41,55)"] {
  color: #ffffff !important;
}

/* Cover computed styles that might result in gray-800 */

