/**
 * ALGORIZMS™ GLOBAL SEARCH COMMAND PALETTE (Cmd + K)
 * High-performance keyboard-driven search & navigation HUD
 * Fully responsive, bilingual (LTR/RTL), with Algorizms Dark Theme & Light Mode parity
 */

.command-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 2, 2, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 99999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
}

.command-palette-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.command-palette-modal {
  width: 100%;
  max-width: 640px;
  background: #0D0A08;
  border: 1px solid rgba(252, 211, 77, 0.22);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.85), 0 0 30px rgba(252, 211, 77, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(-16px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  z-index: 1;
}

.command-palette-backdrop.is-open .command-palette-modal {
  transform: translateY(0) scale(1);
}

/* Header & Input */
.command-palette-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 12px;
  position: relative;
}

.command-search-icon {
  width: 20px;
  height: 20px;
  color: #FCD34D;
  flex-shrink: 0;
}

.command-palette-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif);
  font-size: 1.02rem;
  color: #FAF8F4;
  line-height: 1.4;
}

.command-palette-input::placeholder {
  color: #78716C;
}

.command-esc-badge {
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
  color: #A8A29E;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  user-select: none;
}

/* Results Body */
.command-palette-results {
  max-height: 380px;
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: scroll !important;
  overflow-x: hidden;
  padding: 10px 8px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: rgba(252, 211, 77, 0.55) rgba(255, 255, 255, 0.05);
}

.command-palette-results::-webkit-scrollbar {
  width: 8px !important;
  display: block !important;
}

.command-palette-results::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.command-palette-results::-webkit-scrollbar-thumb {
  background: rgba(252, 211, 77, 0.5) !important;
  border-radius: 4px;
  border: 1px solid rgba(252, 211, 77, 0.25);
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.command-palette-results::-webkit-scrollbar-thumb:hover {
  background: #FCD34D !important;
  box-shadow: 0 0 10px rgba(252, 211, 77, 0.7);
}

/* Section Header */
.command-section-title {
  font-family: var(--font-mono, monospace);
  font-size: 0.68rem;
  font-weight: 700;
  color: #FCD34D;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 12px 4px;
}

/* Item */
.command-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  user-select: none;
  border: 1px solid transparent;
  gap: 12px;
}

.command-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.command-item-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.command-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.command-item-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #FAF8F4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-item-desc {
  font-size: 0.74rem;
  color: #A8A29E;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-item-badge {
  font-family: var(--font-mono, monospace);
  font-size: 0.68rem;
  color: #38BDF8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  padding: 2px 7px;
  border-radius: 5px;
  flex-shrink: 0;
}

/* Hover & Selected */
.command-item:hover,
.command-item.is-selected {
  background: rgba(252, 211, 77, 0.08);
  border-color: rgba(252, 211, 77, 0.28);
}

.command-item.is-selected .command-item-title {
  color: #FCD34D;
}

/* Empty State */
.command-empty-state {
  padding: 36px 20px;
  text-align: center;
  color: #A8A29E;
  font-size: 0.88rem;
}

/* Footer Instructions */
.command-palette-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.4);
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
  color: #78716C;
}

.command-footer-hints {
  display: flex;
  align-items: center;
  gap: 14px;
}

.command-footer-hint span {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
  margin-right: 4px;
  color: #D6D3D1;
}

/* Header Trigger Button */
.header-search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 6px 13px;
  color: #D6D3D1;
  font-family: var(--font-mono, monospace);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.header-search-trigger:hover {
  background: rgba(252, 211, 77, 0.1);
  border-color: rgba(252, 211, 77, 0.35);
  color: #FCD34D;
  box-shadow: 0 0 12px rgba(252, 211, 77, 0.2);
}

.header-search-trigger .search-kbd {
  font-size: 0.68rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Light Mode Overrides */
[data-theme="marble-bling"] .command-palette-backdrop,
[data-theme="light"] .command-palette-backdrop {
  background: rgba(244, 241, 234, 0.82);
}

[data-theme="marble-bling"] .command-palette-modal,
[data-theme="light"] .command-palette-modal {
  background: #FFFDF9;
  border-color: rgba(217, 119, 6, 0.35);
  box-shadow: 0 24px 70px rgba(180, 120, 20, 0.16);
}

[data-theme="marble-bling"] .command-palette-header,
[data-theme="light"] .command-palette-header {
  border-bottom-color: rgba(217, 119, 6, 0.18);
}

[data-theme="marble-bling"] .command-palette-input,
[data-theme="light"] .command-palette-input {
  color: #0A0B0E;
}

[data-theme="marble-bling"] .command-palette-input::placeholder,
[data-theme="light"] .command-palette-input::placeholder {
  color: #78716C;
}

[data-theme="marble-bling"] .command-section-title,
[data-theme="light"] .command-section-title {
  color: #B45309;
}

[data-theme="marble-bling"] .command-item-title,
[data-theme="light"] .command-item-title {
  color: #1C1917;
}

[data-theme="marble-bling"] .command-item-desc,
[data-theme="light"] .command-item-desc {
  color: #57534E;
}

[data-theme="marble-bling"] .command-item:hover,
[data-theme="marble-bling"] .command-item.is-selected,
[data-theme="light"] .command-item:hover,
[data-theme="light"] .command-item.is-selected {
  background: rgba(217, 119, 6, 0.08);
  border-color: rgba(217, 119, 6, 0.32);
}

[data-theme="marble-bling"] .command-palette-footer,
[data-theme="light"] .command-palette-footer {
  background: #F5EFE6;
  border-top-color: rgba(217, 119, 6, 0.18);
  color: #78716C;
}

[data-theme="marble-bling"] .header-search-trigger,
[data-theme="light"] .header-search-trigger {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(217, 119, 6, 0.28);
  color: #44403C;
}

[data-theme="marble-bling"] .command-palette-results,
[data-theme="light"] .command-palette-results {
  scrollbar-color: rgba(217, 119, 6, 0.5) rgba(0, 0, 0, 0.05);
}

[data-theme="marble-bling"] .command-palette-results::-webkit-scrollbar-track,
[data-theme="light"] .command-palette-results::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="marble-bling"] .command-palette-results::-webkit-scrollbar-thumb,
[data-theme="light"] .command-palette-results::-webkit-scrollbar-thumb {
  background: rgba(217, 119, 6, 0.45);
  border-color: rgba(217, 119, 6, 0.25);
}

[data-theme="marble-bling"] .command-palette-results::-webkit-scrollbar-thumb:hover,
[data-theme="light"] .command-palette-results::-webkit-scrollbar-thumb:hover {
  background: #D97706;
}

/* RTL Support */
[dir="rtl"] .command-item-left {
  text-align: right;
}

[dir="rtl"] .command-footer-hint span {
  margin-right: 0;
  margin-left: 4px;
}
