/* ============================================================================
   Floating Search Modal - Beautiful Overlay Search Interface
   ============================================================================ */

/* Search Trigger Button in Header */
.search-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--color-text-primary, #333);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-trigger:hover {
  background: rgba(139, 69, 19, 0.08);
  transform: translateY(-1px);
}

.search-trigger i {
  font-size: 20px;
  color: var(--color-accent, #cd853f);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-trigger:hover i {
  color: var(--color-primary, #8b4513);
  transform: scale(1.08);
}

/* Legacy SVG support */
.search-trigger svg {
  width: 22px;
  height: 22px;
  color: var(--color-accent, #cd853f);
  transition: color 0.2s ease;
}

.search-trigger:hover svg {
  color: var(--color-primary, #8b4513);
}

/* Modal Overlay */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 16px;
  overflow-y: auto;
  overflow-x: hidden;
}

.search-modal[aria-hidden="false"] {
  display: flex;
}

/* Backdrop with blur effect */
.search-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Modal Container */
.search-modal-container {
  position: relative;
  width: 100%;
  max-width: 640px;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Modal Content */
.search-modal-content {
  background: white;
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.05),
    0 10px 40px rgba(0, 0, 0, 0.15),
    0 20px 60px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
}

/* Header with Close Button */
.search-modal-header {
  display: flex;
  justify-content: flex-end;
  padding: 12px 12px 0;
}

.search-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--color-text-secondary, #666);
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text-primary, #333);
}

.search-modal-close i {
  font-size: 18px;
}

/* Legacy SVG support */
.search-modal-close svg {
  width: 18px;
  height: 18px;
}

/* Search Input Area */
.search-modal-search {
  padding: 0 24px 20px;
}

.search-modal-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-modal-icon {
  position: absolute;
  left: 18px;
  font-size: 20px;
  color: var(--color-text-secondary, #666);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Legacy SVG support */
.search-modal-icon svg {
  width: 24px;
  height: 24px;
}

.search-modal-input {
  width: 100%;
  padding: 16px 48px 16px 52px;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-text-primary, #333);
  background: rgba(0, 0, 0, 0.02);
  border: 2px solid transparent;
  border-radius: 12px;
  outline: none;
  transition: all 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.search-modal-input:focus {
  background: white;
  border-color: var(--color-accent, #cd853f);
  box-shadow: 0 0 0 3px rgba(205, 133, 63, 0.1);
}

.search-modal-input:focus + .search-modal-clear {
  opacity: 1;
}

.search-modal-input-wrapper:focus-within .search-modal-icon {
  color: var(--color-accent, #cd853f);
}

.search-modal-clear {
  position: absolute;
  right: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--color-text-secondary, #666);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
}

.search-modal-clear:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text-primary, #333);
  opacity: 1;
}

.search-modal-clear i {
  font-size: 18px;
}

/* Legacy SVG support */
.search-modal-clear svg {
  width: 18px;
  height: 18px;
}

/* Results Container */
.search-modal-results-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 300px;
  max-height: 500px;
  padding: 0 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

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

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

.search-modal-results-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.search-modal-results-container::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Empty State */
.search-modal-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.search-modal-empty-icon {
  margin-bottom: 20px;
  color: var(--color-text-tertiary, #999);
  opacity: 0.35;
}

.search-modal-empty-icon i {
  font-size: 56px;
}

/* Legacy SVG support */
.search-modal-empty-icon svg {
  width: 56px;
  height: 56px;
}

.search-modal-empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary, #333);
  margin: 0 0 8px;
}

.search-modal-empty-state p {
  font-size: 14px;
  color: var(--color-text-secondary, #666);
  margin: 0 0 24px;
}

/* Popular Searches */
.search-modal-popular {
  margin-top: 32px;
}

.search-modal-popular-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary, #666);
  margin: 0 0 12px;
}

.search-modal-popular-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.search-tag {
  padding: 6px 12px;
  background: rgba(205, 133, 63, 0.1);
  border: 1px solid rgba(205, 133, 63, 0.2);
  border-radius: 16px;
  color: var(--color-accent, #cd853f);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-tag:hover {
  background: var(--color-accent, #cd853f);
  color: white;
  border-color: var(--color-accent, #cd853f);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(205, 133, 63, 0.3);
}

/* Results */
.search-modal-results-header {
  padding: 0 16px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.search-modal-results-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary, #666);
}

.search-modal-results-list {
  padding: 8px;
}

.search-result-item {
  display: block;
  padding: 12px 16px;
  margin-bottom: 4px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
  cursor: pointer;
}

.search-result-item:hover,
.search-result-item.selected {
  background: rgba(205, 133, 63, 0.08);
}

.search-result-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary, #333);
  margin: 0 0 4px;
  line-height: 1.4;
}

.search-result-item:hover .search-result-title {
  color: var(--color-accent, #cd853f);
}

.search-result-excerpt {
  font-size: 13px;
  color: var(--color-text-secondary, #666);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-excerpt mark {
  background: rgba(255, 235, 59, 0.4);
  color: inherit;
  font-weight: 600;
  padding: 1px 3px;
  border-radius: 2px;
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-text-tertiary, #999);
}

.search-result-type {
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  font-weight: 500;
  font-size: 11px;
  text-transform: capitalize;
}

/* Load More Button */
.search-modal-load-more {
  padding: 16px;
  text-align: center;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.search-load-more-btn {
  padding: 10px 24px;
  background: var(--color-accent, #cd853f);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-load-more-btn:hover {
  background: var(--color-accent-dark, #b8733d);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(205, 133, 63, 0.3);
}

/* No Results */
.search-modal-no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.search-modal-no-results h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary, #333);
  margin: 0 0 8px;
}

.search-modal-no-results p {
  font-size: 14px;
  color: var(--color-text-secondary, #666);
  margin: 0;
}

/* Footer with Keyboard Shortcuts */
.search-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.02);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 12px;
}

.search-modal-shortcuts {
  display: flex;
  gap: 16px;
}

.search-shortcut {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-secondary, #666);
}

.search-shortcut kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 2px 6px;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.search-shortcut span {
  font-size: 12px;
}

.search-modal-attribution {
  color: var(--color-text-tertiary, #999);
  font-size: 12px;
}

.search-modal-attribution strong {
  color: var(--color-text-secondary, #666);
  font-weight: 600;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .search-modal {
    padding: 20px 12px 12px;
  }

  .search-modal-content {
    border-radius: 12px;
    max-height: calc(100vh - 40px);
  }

  .search-modal-input {
    font-size: 16px;
    padding: 14px 40px 14px 48px;
  }

  /* Fix clear button positioning on mobile */
  .search-modal-clear {
    right: 4px;
    width: 36px;
    height: 36px;
  }

  .search-modal-clear i {
    font-size: 16px;
  }

  .search-modal-results-container {
    max-height: calc(100vh - 280px);
  }

  /* Fix load more button on mobile */
  .search-modal-load-more {
    padding: 16px 12px;
  }

  .search-load-more-btn {
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    display: block;
  }

  .search-modal-shortcuts {
    gap: 12px;
  }

  .search-shortcut span {
    display: none;
  }

  .search-modal-footer {
    padding: 12px 16px;
  }
}

/* Animation for result items */
.search-result-item {
  animation: slideInResult 0.2s ease-out backwards;
}

.search-result-item:nth-child(1) { animation-delay: 0.02s; }
.search-result-item:nth-child(2) { animation-delay: 0.04s; }
.search-result-item:nth-child(3) { animation-delay: 0.06s; }
.search-result-item:nth-child(4) { animation-delay: 0.08s; }
.search-result-item:nth-child(5) { animation-delay: 0.10s; }

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

/* Prevent body scroll when modal is open */
body.search-modal-open {
  overflow: hidden;
}
