/* Search Component Styles */

#map-search-input {
  padding-right: 2rem;
  background-color: rgb(var(--surface-rgb, 33, 37, 41), 0.9);
  border: 1px solid rgb(var(--border-rgb, 73, 80, 87), 0.5);
  color: var(--text-color, #f8f9fa);
  transition: all 0.2s ease;
  position: relative;
  z-index: 1;
}

#map-search-input:focus {
  background-color: rgb(var(--surface-rgb, 33, 37, 41), 1);
  border-color: var(--primary-color, #0dcaf0);
  box-shadow: 0 0 0 0.2rem rgb(13 202 240 / 25%);
  color: var(--text-color, #f8f9fa);
}

#map-search-input::placeholder {
  color: rgb(var(--text-rgb, 248, 249, 250), 0.5);
}

#clear-search-btn {
  color: rgb(var(--text-rgb, 248, 249, 250), 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, 33, 37, 41), 0.98);
  border: 1px solid rgb(var(--border-rgb, 73, 80, 87), 0.8);
  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;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-result-item {
  padding: 0.875rem 1.125rem;
  cursor: pointer;
  border-bottom: 1px solid rgb(var(--border-rgb, 73, 80, 87), 0.2);
  transition: all 0.2s ease;
  color: var(--text-color, #f8f9fa);
  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, 13, 202, 240), 0.15);
  transform: translateX(2px);
}

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

.search-result-title {
  font-weight: 600;
  font-size: 0.925rem;
  margin-bottom: 0.35rem;
  color: var(--text-color, #f8f9fa);
  line-height: 1.4;
}

.search-result-subtitle {
  font-size: 0.8rem;
  color: rgb(var(--text-rgb, 248, 249, 250), 0.65);
  line-height: 1.4;
  display: -webkit-box;
  -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(25 135 84 / 30%);
  color: #4caf50;
}

.search-result-type.street {
  background-color: rgb(13 202 240 / 30%);
  color: #0dcaf0;
}

.search-result-type.address {
  background-color: rgb(255 193 7 / 30%);
  color: #ffc107;
}

.search-loading {
  padding: 1.5rem;
  text-align: center;
  color: rgb(var(--text-rgb, 248, 249, 250), 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, 248, 249, 250), 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: #ff6b6b;
  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, 13, 202, 240), 0.3);
  outline: 2px solid var(--primary-color, #0dcaf0);
  outline-offset: -2px;
}

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

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

/* 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: #0dcaf0;
  color: #212529;
  box-shadow: 0 0 0 0.2rem rgb(13 202 240 / 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(13 202 240 / 8%);
}

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: #dc3545;
}

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%);
}
