/**
 * Global Search Component
 * Professional command palette style search (Cmd/Ctrl + K)
 */

/* Search Modal Backdrop */
.global-search-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 24, 21, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: none;
  animation: fadeIn 0.15s ease;
}

.global-search-backdrop.active {
  display: block;
}

/* Search Modal Container */
.global-search-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: none;
  padding: 80px 20px 20px;
  pointer-events: none;
}

.global-search-modal.active {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Search Container */
.global-search-container {
  width: 100%;
  max-width: 640px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 160px);
  pointer-events: auto;
  animation: slideDown 0.2s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
}

/* Search Input Section */
.global-search-input-wrapper {
  display: flex;
  align-items: center;
  padding: 20px 20px 16px;
  border-bottom: 1px solid #e8e4df;
  gap: 12px;
}

.global-search-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: #6e645a;
}

.global-search-input {
  flex: 1;
  font-size: 16px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #1a1815;
  border: none;
  outline: none;
  background: transparent;
  padding: 0;
}

.global-search-input::placeholder {
  color: #a39d94;
}

.global-search-shortcut {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: #6e645a;
  background: #f5f3f0;
  padding: 4px 6px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* Search Results Section */
.global-search-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 200px;
  max-height: 400px;
}

/* Scrollbar Styling */
.global-search-results::-webkit-scrollbar {
  width: 8px;
}

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

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

.global-search-results::-webkit-scrollbar-thumb:hover {
  background: #a39d94;
}

/* Result Groups */
.search-result-group {
  margin-bottom: 12px;
}

.search-result-group:last-child {
  margin-bottom: 0;
}

.search-result-group-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6e645a;
  padding: 8px 12px 4px;
}

/* Result Items */
.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s ease;
  text-decoration: none;
  color: inherit;
}

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

.search-result-item.selected {
  box-shadow: inset 0 0 0 1px #d9d4cf;
}

.search-result-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 14px;
}

.search-result-icon.playbook {
  background: #e8f5e9;
  color: #2e7d32;
}

.search-result-icon.template {
  background: #e3f2fd;
  color: #1976d2;
}

.search-result-icon.export {
  background: #fff3e0;
  color: #f57c00;
}

.search-result-icon.share {
  background: #fce4ec;
  color: #c2185b;
}

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

.search-result-title {
  font-size: 14px;
  font-weight: 500;
  color: #1a1815;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-subtitle {
  font-size: 12px;
  color: #6e645a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 12px;
  background: #f5f3f0;
  color: #6e645a;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Empty State */
.search-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: #6e645a;
}

.search-empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.search-empty-title {
  font-size: 14px;
  font-weight: 500;
  color: #1a1815;
  margin-bottom: 4px;
}

.search-empty-description {
  font-size: 13px;
  color: #6e645a;
}

/* Loading State */
.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: #6e645a;
}

.search-loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e8e4df;
  border-top-color: #1a1815;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Search Footer */
.global-search-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid #e8e4df;
  font-size: 11px;
  color: #6e645a;
}

.search-footer-shortcuts {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-footer-shortcut {
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-footer-key {
  display: inline-flex;
  align-items: center;
  padding: 2px 5px;
  background: #f5f3f0;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  min-width: 18px;
  justify-content: center;
}

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

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

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

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

  .global-search-container {
    max-height: calc(100vh - 80px);
  }

  .global-search-input-wrapper {
    padding: 16px;
  }

  .global-search-shortcut {
    display: none;
  }

  .search-result-item {
    padding: 12px;
  }

  .search-result-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .search-footer-shortcuts {
    display: none;
  }

  .global-search-footer {
    justify-content: center;
  }
}

/* Focus State (Accessibility) */
.search-result-item:focus {
  outline: none;
  background: #f5f3f0;
  box-shadow: inset 0 0 0 2px #1a1815;
}

/* Highlight Matching Text */
.search-highlight {
  background: #fff3cd;
  color: #856404;
  font-weight: 500;
  padding: 1px 2px;
  border-radius: 2px;
}
