/* Search Component Styles */

#map-search-input {
  padding-right: 2rem;
  background-color: rgb(var(--surface-rgb, 16, 23, 42), 0.9);
  border: 1px solid rgb(var(--border-rgb, 94, 108, 132), 0.45);
  color: var(--text-color, rgb(var(--text-rgb, 226, 232, 240), 1));
  transition: all 0.2s ease;
  position: relative;
  z-index: 1;
}

#map-search-input:focus {
  background-color: rgb(var(--surface-rgb, 16, 23, 42), 1);
  border-color: var(--primary-color, #6366f1);
  box-shadow: 0 0 0 0.2rem rgb(var(--primary-rgb, 99, 102, 241), 0.25);
  color: var(--text-color, rgb(var(--text-rgb, 226, 232, 240), 1));
}

#map-search-input::placeholder {
  color: rgb(var(--text-rgb, 226, 232, 240), 0.5);
}

#clear-search-btn {
  color: rgb(var(--text-rgb, 226, 232, 240), 0.6);
  text-decoration: none;
  background: transparent;
  border: none;
  z-index: 2;
}

#clear-search-btn:hover {
  color: var(--text-color, #f8f9fa);
  background: transparent;
}

/* Search results dropdown - positioned to avoid clipping */
.search-results-dropdown {
  position: fixed;
  max-height: min(400px, 50vh);
  overflow: hidden auto;
  background-color: rgb(var(--surface-rgb, 16, 23, 42), 0.96);
  border: 1px solid rgb(var(--border-rgb, 94, 108, 132), 0.7);
  border-radius: var(--radius-md, 0.5rem);
  box-shadow:
    0 8px 24px rgb(0 0 0 / 40%),
    0 4px 12px rgb(0 0 0 / 30%);
  z-index: 9999;
  backdrop-filter: blur(12px);
  animation: slideDown 0.2s ease-out;
  min-width: 280px;
  margin-top: 0.5rem;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  will-change: transform;
}

/* Note: @keyframes slideDown moved to animations.css */

/* When dropdown appears above the input */
.search-results-dropdown.above {
  animation: slideUp 0.2s ease-out;
}

/* Note: @keyframes slideUp moved to animations.css */

.search-result-item {
  padding: 0.875rem 1.125rem;
  cursor: pointer;
  border-bottom: 1px solid rgb(var(--border-rgb, 94, 108, 132), 0.24);
  transition: all 0.2s ease;
  color: var(--text-color, rgb(var(--text-rgb, 226, 232, 240), 1));
  position: relative;
}

.search-result-item:first-child {
  border-top-left-radius: var(--radius-md, 0.5rem);
  border-top-right-radius: var(--radius-md, 0.5rem);
}

.search-result-item:last-child {
  border-bottom: none;
  border-bottom-left-radius: var(--radius-md, 0.5rem);
  border-bottom-right-radius: var(--radius-md, 0.5rem);
}

.search-result-item:hover,
.search-result-item.active {
  background-color: rgb(var(--primary-rgb, 99, 102, 241), 0.18);
  transform: translateX(2px);
}

.search-result-item:focus {
  outline: 2px solid var(--primary-color, #6366f1);
  outline-offset: -2px;
  z-index: 1;
}

.search-result-title {
  font-weight: 600;
  font-size: 0.925rem;
  margin-bottom: 0.35rem;
  color: var(--text-color, rgb(var(--text-rgb, 226, 232, 240), 1));
  line-height: 1.4;
}

.search-result-subtitle {
  font-size: 0.8rem;
  color: rgb(var(--text-rgb, 226, 232, 240), 0.65);
  line-height: 1.4;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-type {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.65rem;
  border-radius: var(--radius-sm, 0.25rem);
  margin-right: 0.5rem;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.search-result-type.place {
  background-color: rgb(var(--success-rgb, 5, 150, 105), 0.22);
  color: var(--success, #059669);
}

.search-result-type.street {
  background-color: rgb(var(--info-rgb, 63, 140, 255), 0.22);
  color: var(--info, #3f8cff);
}

.search-result-type.address {
  background-color: rgb(var(--warning-rgb, 250, 174, 43), 0.22);
  color: var(--warning, #faae2b);
}

.search-loading {
  padding: 1.5rem;
  text-align: center;
  color: rgb(var(--text-rgb, 226, 232, 240), 0.7);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.search-no-results {
  padding: 1.5rem;
  text-align: center;
  color: rgb(var(--text-rgb, 226, 232, 240), 0.65);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.search-no-results::before {
  content: "🔍";
  font-size: 2rem;
  opacity: 0.5;
}

.search-error {
  padding: 1.5rem;
  text-align: center;
  color: var(--danger, #ff5470);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.search-error::before {
  content: "⚠️";
  font-size: 1.5rem;
}

/* Street highlight layer styles */
.street-highlight-layer {
  pointer-events: none;
}

/* Keyboard navigation highlight */
.search-result-item[aria-selected="true"] {
  background-color: rgb(var(--primary-rgb, 99, 102, 241), 0.32);
  outline: 2px solid var(--primary-color, #6366f1);
  outline-offset: -2px;
  z-index: 1;
}

/* Loading spinner for search */
.search-loading::before {
  content: "";
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgb(var(--text-rgb, 226, 232, 240), 0.28);
  border-top-color: var(--primary-color, #6366f1);
  border-radius: 50%;
  animation: search-spin 0.6s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* Note: @keyframes search-spin moved to animations.css */

/* Scrollbar styling for dropdown */
.search-results-dropdown::-webkit-scrollbar {
  width: 6px;
}

.search-results-dropdown::-webkit-scrollbar-track {
  background: rgb(0 0 0 / 20%);
  border-radius: 3px;
}

.search-results-dropdown::-webkit-scrollbar-thumb {
  background: rgb(255 255 255 / 30%);
  border-radius: 3px;
}

.search-results-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgb(255 255 255 / 50%);
}

/* Responsive adjustments */
@media (width <= 768px) {
  .search-results-dropdown {
    max-height: min(350px, 40vh);
    min-width: 250px;
  }

  .search-result-item {
    padding: 0.75rem 0.875rem;
  }

  .search-result-title {
    font-size: 0.875rem;
  }

  .search-result-subtitle {
    font-size: 0.775rem;
  }
}

@media (width <= 480px) {
  .search-results-dropdown {
    max-height: min(300px, 35vh);
    left: 0.5rem !important;
    right: 0.5rem !important;
    width: calc(100vw - 1rem) !important;
    min-width: unset;
  }

  .search-result-item {
    padding: 0.625rem 0.75rem;
  }
}

/* Dark/Light theme support */
body.light-mode #map-search-input,
[data-bs-theme="light"] #map-search-input {
  background-color: rgb(255 255 255 / 95%);
  border-color: rgb(206 212 218 / 60%);
  color: #212529;
}

body.light-mode #map-search-input:focus,
[data-bs-theme="light"] #map-search-input:focus {
  background-color: rgb(255 255 255);
  border-color: var(--primary, #6366f1);
  color: #212529;
  box-shadow: 0 0 0 0.2rem rgb(var(--primary-rgb, 99, 102, 241), 0.15);
}

body.light-mode #map-search-input::placeholder,
[data-bs-theme="light"] #map-search-input::placeholder {
  color: rgb(33 37 41 / 50%);
}

body.light-mode .search-results-dropdown,
[data-bs-theme="light"] .search-results-dropdown {
  background-color: rgb(255 255 255 / 98%);
  border-color: rgb(206 212 218 / 80%);
  box-shadow:
    0 8px 24px rgb(0 0 0 / 12%),
    0 4px 12px rgb(0 0 0 / 8%);
}

body.light-mode .search-result-item,
[data-bs-theme="light"] .search-result-item {
  color: #212529;
  border-bottom-color: rgb(206 212 218 / 35%);
}

body.light-mode .search-result-item:hover,
body.light-mode .search-result-item.active,
[data-bs-theme="light"] .search-result-item:hover,
[data-bs-theme="light"] .search-result-item.active {
  background-color: rgb(var(--primary-rgb, 99, 102, 241), 0.1);
}

body.light-mode .search-result-title,
[data-bs-theme="light"] .search-result-title {
  color: #212529;
}

body.light-mode .search-result-subtitle,
[data-bs-theme="light"] .search-result-subtitle {
  color: rgb(33 37 41 / 65%);
}

body.light-mode #clear-search-btn,
[data-bs-theme="light"] #clear-search-btn {
  color: rgb(33 37 41 / 60%);
}

body.light-mode #clear-search-btn:hover,
[data-bs-theme="light"] #clear-search-btn:hover {
  color: #212529;
}

body.light-mode .search-loading,
body.light-mode .search-no-results,
[data-bs-theme="light"] .search-loading,
[data-bs-theme="light"] .search-no-results {
  color: rgb(33 37 41 / 60%);
}

body.light-mode .search-error,
[data-bs-theme="light"] .search-error {
  color: var(--danger, #ff5470);
}

body.light-mode .search-results-dropdown::-webkit-scrollbar-track,
[data-bs-theme="light"] .search-results-dropdown::-webkit-scrollbar-track {
  background: rgb(0 0 0 / 5%);
}

body.light-mode .search-results-dropdown::-webkit-scrollbar-thumb,
[data-bs-theme="light"] .search-results-dropdown::-webkit-scrollbar-thumb {
  background: rgb(0 0 0 / 20%);
}

body.light-mode .search-results-dropdown::-webkit-scrollbar-thumb:hover,
[data-bs-theme="light"]
  .search-results-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgb(0 0 0 / 35%);
}
