/**
 * Command Palette Styles
 * Spotlight-style interface for quick navigation and actions
 */

/* Modal container */
.cmd-palette-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: min(20vh, 150px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.cmd-palette-modal.cmd-palette-visible {
  opacity: 1;
  visibility: visible;
}

/* Backdrop with blur */
.cmd-palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

[data-theme="dark"] .cmd-palette-backdrop {
  background: rgba(0, 0, 0, 0.6);
}

/* Main container */
.cmd-palette-container {
  position: relative;
  width: 100%;
  max-width: 580px;
  margin: 0 1rem;
  background: var(--content-bg);
  border-radius: 12px;
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 0 0 1px var(--border-color);
  overflow: hidden;
  transform: scale(0.96) translateY(-10px);
  transition: transform 0.15s ease;
}

.cmd-palette-visible .cmd-palette-container {
  transform: scale(1) translateY(0);
}

/* Search input area */
.cmd-palette-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.cmd-palette-icon {
  font-size: 1.25rem;
  opacity: 0.5;
  flex-shrink: 0;
}

.cmd-palette-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1.125rem;
  color: var(--content-text);
  outline: none;
}

.cmd-palette-input::placeholder {
  color: var(--content-text);
  opacity: 0.4;
}

.cmd-palette-kbd-hint {
  display: flex;
  gap: 0.25rem;
  opacity: 0.4;
  flex-shrink: 0;
}

.cmd-palette-kbd-hint kbd {
  padding: 0.15rem 0.4rem;
  font-size: 0.7rem;
  font-family: inherit;
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

/* Results area */
.cmd-palette-results {
  max-height: 400px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.cmd-palette-results::-webkit-scrollbar {
  width: 6px;
}

.cmd-palette-results::-webkit-scrollbar-track {
  background: transparent;
}

.cmd-palette-results::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.cmd-palette-results::-webkit-scrollbar-thumb:hover {
  background: var(--content-text);
  opacity: 0.3;
}

/* Empty state */
.cmd-palette-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--content-text);
  opacity: 0.5;
}

.cmd-palette-empty-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

/* Category headers */
.cmd-palette-category {
  padding: 0.5rem 1.25rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--content-text);
  opacity: 0.4;
  background: var(--hover-bg);
  border-top: 1px solid var(--border-color);
}

.cmd-palette-category:first-child {
  border-top: none;
}

/* Result items */
.cmd-palette-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  cursor: pointer;
  transition: background 0.1s ease, transform 0.1s ease;
  border-left: 3px solid transparent;
}

.cmd-palette-item:hover {
  background: var(--hover-bg);
}

.cmd-palette-item.cmd-palette-selected {
  background: var(--primary-color);
  color: white;
  border-left-color: white;
}

.cmd-palette-item.cmd-palette-selected .cmd-palette-item-hint {
  opacity: 0.8;
  color: white;
}

/* When hovering a non-selected item while there's a selection */
.cmd-palette-item:hover:not(.cmd-palette-selected) {
  background: var(--hover-bg);
}

.cmd-palette-item-icon {
  font-size: 1.125rem;
  flex-shrink: 0;
  width: 1.5rem;
  text-align: center;
}

.cmd-palette-item-content {
  flex: 1;
  min-width: 0;
}

.cmd-palette-item-label {
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-palette-item-sublabel {
  font-size: 0.75rem;
  opacity: 0.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-palette-item-hint {
  font-size: 0.75rem;
  opacity: 0.4;
  flex-shrink: 0;
}

.cmd-palette-item-hint kbd {
  padding: 0.15rem 0.35rem;
  font-size: 0.65rem;
  font-family: inherit;
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  border-radius: 3px;
}

.cmd-palette-item:hover .cmd-palette-item-hint kbd,
.cmd-palette-item.cmd-palette-selected .cmd-palette-item-hint kbd {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Footer */
.cmd-palette-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  font-size: 0.7rem;
  color: var(--content-text);
  opacity: 0.5;
  background: var(--hover-bg);
  border-top: 1px solid var(--border-color);
}

.cmd-palette-footer-keys {
  display: flex;
  gap: 0.75rem;
}

.cmd-palette-footer-key {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.cmd-palette-footer-key kbd {
  padding: 0.1rem 0.3rem;
  font-size: 0.65rem;
  font-family: inherit;
  background: var(--content-bg);
  border: 1px solid var(--border-color);
  border-radius: 3px;
}

/* Highlight matched text */
.cmd-palette-match {
  background: rgba(102, 126, 234, 0.25);
  border-radius: 2px;
}

.cmd-palette-item:hover .cmd-palette-match,
.cmd-palette-item.cmd-palette-selected .cmd-palette-match {
  background: rgba(255, 255, 255, 0.3);
}

/* Loading state */
.cmd-palette-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  color: var(--content-text);
  opacity: 0.5;
}

.cmd-palette-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: cmd-palette-spin 0.6s linear infinite;
}

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

/* Recent indicator */
.cmd-palette-recent-badge {
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  background: var(--primary-color);
  color: white;
  border-radius: 3px;
  margin-left: 0.5rem;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .cmd-palette-modal {
    padding-top: 0;
    align-items: flex-start;
  }
  
  .cmd-palette-container {
    max-width: none;
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
    max-height: 100vh;
  }
  
  .cmd-palette-results {
    max-height: calc(100vh - 140px);
  }
  
  .cmd-palette-kbd-hint {
    display: none;
  }
  
  .cmd-palette-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
  }
}
