/**
 * Command Palette System
 * 
 * Premium 2026 SaaS Navigation Pattern
 * Inspired by: Vercel, Linear, GitHub, Notion, Stripe
 * 
 * The Cmd+K command palette is THE power-user interface standard.
 * Creates instant navigation + search with keyboard-first UX.
 * Increases perceived sophistication and reduces friction.
 * 
 * Features:
 * - Cmd/Ctrl+K keyboard shortcut
 * - Fuzzy search filtering
 * - Keyboard navigation (arrows + enter)
 * - Quick actions (navigate, book, contact)
 * - Recent searches memory
 * - Mobile-optimized modal
 * - Glassmorphism backdrop
 * - Smooth micro-animations
 * - Focus trap accessibility
 */

/* ═══════════════════════════════════════════════════════════════════════════
   COMMAND PALETTE OVERLAY
   ════════════════════════════════════════════════════════════════════════ */

.command-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.command-palette-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMMAND PALETTE CONTAINER
   ════════════════════════════════════════════════════════════════════════ */

.command-palette {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: min(600px, calc(100vw - 32px));
  max-height: 70vh;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 
    0 24px 48px rgba(0, 0, 0, 0.15),
    0 8px 16px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  z-index: 10001;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.command-palette.active {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%) scale(1);
}

/* Dark gradient header */
.command-palette::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(
    135deg,
    rgba(139, 92, 246, 0.08) 0%,
    rgba(139, 92, 246, 0.08) 100%
  );
  pointer-events: none;
  z-index: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SEARCH INPUT
   ════════════════════════════════════════════════════════════════════════ */

.command-palette__search {
  position: relative;
  z-index: 1;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.command-palette__input {
  width: 100%;
  padding: 14px 20px 14px 48px;
  font-size: 16px;
  font-weight: 500;
  color: #1a1a1a;
  background: rgba(255, 255, 255, 0.6);
  border: 2px solid transparent;
  border-radius: 12px;
  outline: none;
  transition: all 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.command-palette__input::placeholder {
  color: rgba(0, 0, 0, 0.4);
}

.command-palette__input:focus {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

/* Search icon */
.command-palette__search-icon {
  position: absolute;
  left: 40px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  opacity: 0.4;
  pointer-events: none;
}

/* Keyboard hint */
.command-palette__hint {
  position: absolute;
  right: 40px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.4);
  font-weight: 500;
}

.command-palette__kbd {
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: 11px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.6);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESULTS LIST
   ════════════════════════════════════════════════════════════════════════ */

.command-palette__results {
  position: relative;
  z-index: 1;
  max-height: calc(70vh - 100px);
  overflow-y: auto;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.command-palette__results::-webkit-scrollbar {
  width: 8px;
}

.command-palette__results::-webkit-scrollbar-track {
  background: transparent;
}

.command-palette__results::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

/* Section headers */
.command-palette__section {
  margin-top: 16px;
  margin-bottom: 8px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(0, 0, 0, 0.4);
}

.command-palette__section:first-child {
  margin-top: 0;
}

/* Empty state */
.command-palette__empty {
  padding: 48px 24px;
  text-align: center;
  color: rgba(0, 0, 0, 0.4);
  font-size: 14px;
}

.command-palette__empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  opacity: 0.3;
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMMAND ITEMS
   ════════════════════════════════════════════════════════════════════════ */

.command-palette__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  margin-bottom: 4px;
}

.command-palette__item:hover {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.15);
}

.command-palette__item.active {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.3);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.command-palette__item[hidden] {
  display: none;
}

/* Item icon */
.command-palette__item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.6;
}

.command-palette__item.active .command-palette__item-icon {
  opacity: 1;
}

/* Item content */
.command-palette__item-content {
  flex: 1;
  min-width: 0;
}

.command-palette__item-title {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
  margin-bottom: 2px;
}

.command-palette__item-subtitle {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.5);
}

/* Item shortcut badge */
.command-palette__item-shortcut {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.command-palette__item-shortcut .command-palette__kbd {
  font-size: 10px;
  padding: 2px 6px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FOOTER HINTS
   ════════════════════════════════════════════════════════════════════════ */

.command-palette__footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.02);
}

.command-palette__footer-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: rgba(0, 0, 0, 0.5);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE OPTIMIZATION
   ════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .command-palette {
    top: auto;
    bottom: 0;
    transform: translate(-50%, 100%);
    border-radius: 24px 24px 0 0;
    max-height: 85vh;
  }

  .command-palette.active {
    transform: translate(-50%, 0);
  }

  .command-palette__hint {
    display: none;
  }

  .command-palette__footer-hint {
    font-size: 10px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   REDUCED MOTION
   ════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .command-palette-overlay,
  .command-palette,
  .command-palette__item {
    transition: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TRIGGER BUTTON (OPTIONAL)
   ════════════════════════════════════════════════════════════════════════ */

.command-palette-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: none; /* Hidden by default - use keyboard shortcut */
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 
    0 8px 16px rgba(139, 92, 246, 0.3),
    0 4px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  z-index: 999;
}

.command-palette-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 12px 24px rgba(139, 92, 246, 0.4),
    0 6px 12px rgba(0, 0, 0, 0.15);
}

.command-palette-trigger:active {
  transform: translateY(0);
}

@media (max-width: 768px) {
  .command-palette-trigger {
    display: flex; /* Show on mobile for discoverability */
  }
}
