/* Fix nav overflow to allow search results to extend beyond nav bar */
.nav {
  overflow: visible !important;
}

.nav-container {
  display: flex;
  align-items: center;
  overflow: visible !important;
}

.search-wrapper {
  position: relative;
  margin-left: auto;
  z-index: 1001;
}

.search-container {
  display: flex;
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  transition: all 0.3s ease;
  overflow: hidden;
}

.search-input {
  width: 0;
  padding: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  color: #333;
  outline: none;
  opacity: 0;
  transition: all 0.3s ease;
}

.search-input::placeholder {
  color: #999;
  font-size: 0.85rem;
}

.search-icon {
  padding: 0.5rem;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.search-icon:hover {
  color: #333;
}

/* Expanded state on hover or focus-within */
.search-wrapper:hover .search-container,
.search-container:focus-within {
  background: #fafafa;
  border-color: #e5e5e5;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.03);
}

.search-wrapper:hover .search-input,
.search-container:focus-within .search-input {
  width: 180px;
  padding: 0.4rem 0.6rem;
  opacity: 1;
}

/* Keep expanded when input has focus */
.search-input:focus {
  width: 180px;
  padding: 0.4rem 0.6rem;
  opacity: 1;
}

.search-input:focus + .search-icon,
.search-container:focus-within .search-icon {
  color: #333;
}

/* Results dropdown - positioned outside nav to avoid clipping */
.search-results {
  position: fixed;
  width: 400px;
  max-height: 400px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}

.search-results.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.search-results ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-result-item {
  border-bottom: 1px solid #f0f0f0;
}

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

.search-result-item a {
  display: block;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.1s ease;
}

.search-result-item a:hover,
.search-result-item.selected a {
  background: #f8f8f8;
}

.search-result-title {
  display: block;
  font-weight: 600;
  color: #222;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.search-result-date {
  display: inline-block;
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.3rem;
}

.search-result-summary {
  display: block;
  font-size: 0.85rem;
  color: #666;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-message {
  padding: 1rem;
  text-align: center;
  color: #888;
  font-size: 0.9rem;
}

/* Mobile */
@media (max-width: 600px) {
  .search-wrapper:hover .search-input,
  .search-container:focus-within .search-input,
  .search-input:focus {
    width: 140px;
  }

  .search-results {
    width: 280px;
    max-height: 60vh;
  }
}

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

.search-results::-webkit-scrollbar-track {
  background: transparent;
}

.search-results::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}
