/* =========================================== */
/* SMART SEARCH - Global Search Bar */
/* Instant search across artworks, pages, series */
/* Created: 2025-11-06 */
/* =========================================== */

/* ===== SEARCH BUTTON IN NAVBAR ===== */
.navbar-search-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(99, 102, 241, 0.08);
  color: #6366f1;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin-left: 1rem;
}

.navbar-search-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: #6366f1;
  transform: scale(1.05);
}

.navbar-search-btn i {
  font-size: 1.1rem;
}

.navbar-search-kbd {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.375rem;
  background: rgba(99, 102, 241, 0.15);
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: monospace;
  font-weight: 700;
  margin-left: 0.25rem;
}

@media (max-width: 991px) {
  .navbar-search-kbd {
    display: none;
  }
}

/* ===== SEARCH OVERLAY ===== */
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 2rem 2rem;
}

.search-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ===== SEARCH CONTAINER ===== */
.search-container {
  width: 100%;
  max-width: 700px;
  transform: translateY(-50px) scale(0.95);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.search-overlay.active .search-container {
  transform: translateY(0) scale(1);
}

/* ===== SEARCH INPUT BOX ===== */
.search-input-wrapper {
  position: relative;
  background: white;
  border-radius: 20px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(99, 102, 241, 0.2);
  overflow: hidden;
}

[data-bs-theme="dark"] .search-input-wrapper {
  background: #1e293b;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(99, 102, 241, 0.3);
}

.search-input-icon {
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: #6366f1;
  font-size: 1.5rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 1.25rem 4rem 1.25rem 4rem;
  border: none;
  background: transparent;
  font-size: 1.125rem;
  color: #1e293b;
  outline: none;
}

[data-bs-theme="dark"] .search-input {
  color: #e2e8f0;
}

.search-input::placeholder {
  color: #94a3b8;
}

.search-close-btn {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.1);
  border: none;
  border-radius: 50%;
  color: #6366f1;
  cursor: pointer;
  transition: all 0.3s ease;
}

.search-close-btn:hover {
  background: #6366f1;
  color: white;
  transform: translateY(-50%) scale(1.1);
}

/* ===== SEARCH RESULTS ===== */
.search-results {
  margin-top: 1rem;
  max-height: 60vh;
  overflow-y: auto;
  background: white;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  padding: 1rem 0;
}

[data-bs-theme="dark"] .search-results {
  background: #1e293b;
}

.search-results::-webkit-scrollbar {
  width: 8px;
}

.search-results::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

.search-results::-webkit-scrollbar-thumb {
  background: #6366f1;
  border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
  background: #4f46e5;
}

/* ===== RESULT CATEGORIES ===== */
.search-category {
  padding: 0.75rem 1.5rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6366f1;
  background: rgba(99, 102, 241, 0.05);
}

/* ===== INDIVIDUAL RESULTS ===== */
.search-result-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.search-result-item:hover {
  background: rgba(99, 102, 241, 0.08);
  transform: translateX(4px);
}

.search-result-item.active {
  background: rgba(99, 102, 241, 0.12);
}

/* Result thumbnail */
.search-result-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Result icon (for pages without thumbnails) */
.search-result-icon {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border-radius: 12px;
  font-size: 1.75rem;
  flex-shrink: 0;
}

/* Result content */
.search-result-content {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

[data-bs-theme="dark"] .search-result-title {
  color: #e2e8f0;
}

.search-result-description {
  font-size: 0.813rem;
  color: #64748b;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.search-result-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* ===== EMPTY STATE ===== */
.search-empty {
  text-align: center;
  padding: 3rem 2rem;
  color: #64748b;
}

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

.search-empty-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.5rem;
}

[data-bs-theme="dark"] .search-empty-title {
  color: #e2e8f0;
}

.search-empty-text {
  font-size: 0.875rem;
  color: #64748b;
}

/* ===== LOADING STATE ===== */
.search-loading {
  text-align: center;
  padding: 2rem;
}

.search-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

/* ===== KEYBOARD HINT ===== */
.search-hints {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  padding: 1rem;
  background: rgba(99, 102, 241, 0.03);
  border-radius: 12px;
  margin-top: 1rem;
  font-size: 0.813rem;
  color: #64748b;
}

.search-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-hint-key {
  padding: 0.25rem 0.5rem;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-family: monospace;
  font-weight: 700;
  color: #1e293b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .search-hint-key {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  .search-overlay {
    padding: 5vh 1rem 1rem;
  }

  .search-input {
    font-size: 1rem;
    padding: 1rem 3.5rem 1rem 3.5rem;
  }

  .search-input-icon {
    left: 1rem;
    font-size: 1.25rem;
  }

  .search-results {
    max-height: 50vh;
  }

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

  .search-result-thumb,
  .search-result-icon {
    width: 50px;
    height: 50px;
  }

  .search-hints {
    flex-direction: column;
    gap: 0.75rem;
  }
}

/* ===== ANIMATIONS ===== */
@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-result-item {
  animation: slideInDown 0.3s ease;
}

.search-result-item:nth-child(1) { animation-delay: 0s; }
.search-result-item:nth-child(2) { animation-delay: 0.05s; }
.search-result-item:nth-child(3) { animation-delay: 0.1s; }
.search-result-item:nth-child(4) { animation-delay: 0.15s; }
.search-result-item:nth-child(5) { animation-delay: 0.2s; }

/* ===== HIGHLIGHT MATCHED TEXT ===== */
.search-highlight {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
  color: #6366f1;
  font-weight: 700;
  padding: 0 0.125rem;
  border-radius: 2px;
}

/* ===== ACCESSIBILITY ===== */
.search-input:focus {
  outline: none;
}

.search-input-wrapper:focus-within {
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 0 0 3px rgba(99, 102, 241, 0.4);
}

/* ===== PERFORMANCE ===== */
@media (prefers-reduced-motion: reduce) {
  .search-overlay,
  .search-container,
  .search-result-item {
    animation: none !important;
    transition: none !important;
  }
}

