/* @file: src/assets/css/components/search.css */

/* Search Component Styles */
search-box,
.search-box {
  position: relative;
  width: 300px;
  margin-right: 1rem;
  display: block;
}

.search-container {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  padding: 0.5rem 2.5rem 0.5rem 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.search-input:focus {
  outline: none;
  border-color: #0056b3;
  box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.1);
}

.search-button {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  padding: 0.25rem;
  transition: color 0.3s;
}

.search-button:hover {
  color: #0056b3;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.5rem;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
}

.search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
  background-color: #f8f9fa;
}

.results-count {
  font-weight: 600;
  color: #666;
  font-size: 0.875rem;
}

.close-search {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  line-height: 1;
  transition: color 0.3s;
}

.close-search:hover {
  color: #000;
}

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

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

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

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

.result-item a:hover {
  background-color: #f8f9fa;
}

.result-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #0056b3;
  font-size: 1rem;
  line-height: 1.3;
}

.result-snippet {
  font-size: 0.875rem;
  color: #666;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.result-item mark {
  background-color: #ffeb3b;
  font-weight: 600;
  padding: 0 2px;
}

/* Loading state */
.search-loading {
  text-align: center;
  padding: 1rem;
  color: #666;
}

.search-loading::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 0.5rem;
  border: 2px solid #ddd;
  border-top-color: #0056b3;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Empty state */
.search-empty {
  text-align: center;
  padding: 2rem;
  color: #666;
}

.search-empty-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  opacity: 0.3;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .search-box {
    width: 250px;
  }
}

@media (max-width: 768px) {
  .search-box {
    width: 100%;
    margin-right: 0;
    margin-bottom: 1rem;
  }

  .header-component__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .search-results {
    position: fixed;
    top: 4rem;
    left: 1rem;
    right: 1rem;
    max-height: calc(100vh - 5rem);
  }

  .search-results::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: -1;
  }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
  .search-input {
    background-color: #2d3748;
    border-color: #4a5568;
    color: #fff;
  }

  .search-results {
    background-color: #2d3748;
    border-color: #4a5568;
  }

  .search-results-header {
    background-color: #1a202c;
    border-color: #4a5568;
  }

  .result-item {
    border-color: #4a5568;
  }

  .result-item a:hover {
    background-color: #1a202c;
  }

  .result-title {
    color: #63b3ed;
  }

  .result-snippet {
    color: #a0aec0;
  }

  .result-item mark {
    background-color: #d69e2e;
    color: #000;
  }
}

/* Search page specific styles */
.search-page .search-container-large {
  max-width: 600px;
  margin: 3rem auto;
}

.search-page .search-box {
  width: 100%;
  margin-bottom: 2rem;
}

.search-page .search-input {
  font-size: 1.2rem;
  padding: 0.75rem 3rem 0.75rem 1.25rem;
}

.search-page .search-button {
  right: 0.75rem;
}

.search-page .search-button svg {
  width: 24px;
  height: 24px;
}

/* Mobile search container */
.mobile-search-container {
  display: none;
  padding: 1rem 2rem;
  border-bottom: 1px solid #eee;
}

@media (max-width: 1023px) {
  .header-component__actions .search-box {
    display: none !important;
  }

  .header-component__nav.active .mobile-search-container {
    display: block;
  }

  .mobile-search-container .search-box {
    width: 100%;
    margin: 0;
  }
}

/* Search icon for mobile */
.search-icon-mobile {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: #666;
}

@media (max-width: 768px) {
  .search-icon-mobile {
    display: block;
  }
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* Focus trap for accessibility */
.search-results:focus-within {
  outline: 2px solid #0056b3;
  outline-offset: 2px;
}

/* Keyboard navigation highlight */
.result-item.keyboard-focus {
  background-color: #e8f0fe;
}

.result-item.keyboard-focus a {
  outline: 2px solid #0056b3;
  outline-offset: -2px;
}
