/**
 * Search Engine Styles for Youth Devotionals
 * Mobile-first responsive design
 */

/* Search Container */
.devotionals-search-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

/* Search Input */
.search-input-wrapper {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-input {
  width: 100%;
  padding: 0.875rem 3rem 0.875rem 1rem;
  font-size: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 24px;
  background-color: #fff;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.search-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.search-input::placeholder {
  color: #9ca3af;
}

.search-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

.search-clear-btn {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  padding: 0.25rem;
  display: none;
  font-size: 1.25rem;
  line-height: 1;
}

.search-input:not(:placeholder-shown) ~ .search-clear-btn {
  display: block;
}

.search-clear-btn:hover {
  color: #374151;
}

/* Search Results */
.search-results {
  margin-top: 1.5rem;
}

.search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e5e7eb;
}

.search-results-count {
  font-size: 0.875rem;
  color: #6b7280;
}

.search-results-time {
  font-size: 0.75rem;
  color: #9ca3af;
}

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

/* Search Result Item */
.search-result-item {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.search-result-item:hover {
  border-color: #6366f1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
  transform: translateY(-2px);
}

.search-result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.search-result-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #111827;
  margin: 0 0 0.25rem 0;
  line-height: 1.4;
}

.search-result-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.875rem;
  color: #6b7280;
}

.search-result-topic {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  background-color: #f3f4f6;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #4b5563;
}

.search-result-read-time {
  font-size: 0.75rem;
  color: #9ca3af;
}

.search-result-relevance {
  font-size: 0.75rem;
  color: #10b981;
  font-weight: 500;
}

/* Search Matches */
.search-result-matches {
  margin-top: 0.75rem;
}

.search-match-section {
  margin-bottom: 0.5rem;
}

.search-match-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6366f1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.search-match-text {
  font-size: 0.875rem;
  color: #4b5563;
  line-height: 1.6;
}

/* Highlight */
.search-highlight {
  background-color: #fef3c7;
  color: #92400e;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  font-weight: 500;
}

/* Empty State */
.search-empty-state {
  text-align: center;
  padding: 3rem 1rem;
}

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

.search-empty-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0.5rem;
}

.search-empty-message {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 2rem;
}

/* Suggestions */
.search-suggestions {
  margin-top: 2rem;
}

.search-suggestions-title {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 1rem;
}

.search-suggestions-topics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.search-suggestion-topic {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-suggestion-topic:hover {
  border-color: #6366f1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
  transform: translateY(-2px);
}

.search-suggestion-topic-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.search-suggestion-topic-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0.25rem;
}

.search-suggestion-topic-description {
  font-size: 0.75rem;
  color: #6b7280;
  line-height: 1.4;
}

.search-suggestions-devotionals {
  list-style: none;
  padding: 0;
  margin: 0;
}

.search-suggestion-devotional {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-suggestion-devotional:hover {
  border-color: #6366f1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.search-suggestion-devotional-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0.25rem;
}

.search-suggestion-devotional-topic {
  font-size: 0.75rem;
  color: #6b7280;
}

/* Loading State */
.search-loading {
  text-align: center;
  padding: 2rem;
}

.search-loading-spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 3px solid #e5e7eb;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: search-spin 0.8s linear infinite;
}

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

.search-loading-text {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: #6b7280;
}

/* Error State */
.search-error {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.search-error-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #991b1b;
  margin-bottom: 0.25rem;
}

.search-error-message {
  font-size: 0.875rem;
  color: #dc2626;
}

/* Responsive Design */
@media (max-width: 640px) {
  .devotionals-search-container {
    padding: 0.75rem;
  }

  .search-input {
    font-size: 0.875rem;
    padding: 0.75rem 2.5rem 0.75rem 0.875rem;
  }

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

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

  .search-result-meta {
    font-size: 0.75rem;
  }

  .search-suggestions-topics {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }

  .search-suggestion-topic {
    padding: 0.75rem;
  }

  .search-suggestion-topic-icon {
    font-size: 1.5rem;
  }
}

/* Accessibility */
.search-result-item:focus,
.search-suggestion-topic:focus,
.search-suggestion-devotional:focus {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* Dark Mode Support (optional) */
@media (prefers-color-scheme: dark) {
  .search-input {
    background-color: #1f2937;
    border-color: #374151;
    color: #f9fafb;
  }

  .search-input::placeholder {
    color: #6b7280;
  }

  .search-result-item,
  .search-suggestion-topic,
  .search-suggestion-devotional {
    background-color: #1f2937;
    border-color: #374151;
  }

  .search-result-title,
  .search-empty-title,
  .search-suggestions-title,
  .search-suggestion-topic-name,
  .search-suggestion-devotional-title {
    color: #f9fafb;
  }

  .search-result-meta,
  .search-match-text,
  .search-empty-message,
  .search-suggestion-topic-description,
  .search-suggestion-devotional-topic {
    color: #9ca3af;
  }

  .search-highlight {
    background-color: #78350f;
    color: #fef3c7;
  }
}
