/* ============================================
   COMMAND PALETTE (⌘K)
   VS Code/Notion-inspired quick actions panel
   Gen Z Optimized: Keyboard-first, instant search
   ============================================ */

/* ===========================================
   OVERLAY
   =========================================== */

.command-palette-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition:
        opacity var(--ds-duration-fast, 150ms) var(--ds-ease-out, cubic-bezier(0, 0, 0.2, 1)),
        visibility var(--ds-duration-fast, 150ms);
}

.command-palette-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* ===========================================
   CONTAINER
   =========================================== */

.command-palette {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%) scale(0.96) translateY(-10px);
    z-index: 10000;
    width: 90%;
    max-width: 560px;
    max-height: 70vh;
    background: var(--ds-glass-2, rgba(30, 41, 59, 0.85));
    backdrop-filter: blur(var(--ds-blur-xl, 40px)) var(--ds-saturation, saturate(180%));
    -webkit-backdrop-filter: blur(var(--ds-blur-xl, 40px)) var(--ds-saturation, saturate(180%));
    border: 1px solid var(--ds-glass-border-emphasis, rgba(148, 163, 184, 0.2));
    border-radius: var(--ds-radius-2xl, 24px);
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 var(--ds-glass-shine-default, rgba(255, 255, 255, 0.05));
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity var(--ds-duration-fast, 150ms) var(--ds-ease-out),
        visibility var(--ds-duration-fast, 150ms),
        transform var(--ds-duration-normal, 250ms) var(--ds-ease-spring, cubic-bezier(0.175, 0.885, 0.32, 1.275));
}

.command-palette.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1) translateY(0);
}

/* Mobile adjustments */
@media (max-width: 640px) {
    .command-palette {
        top: 10%;
        width: 94%;
        max-height: 80vh;
        border-radius: var(--ds-radius-xl, 20px);
    }
}

/* ===========================================
   SEARCH HEADER
   =========================================== */

.command-search-header {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3, 0.75rem);
    padding: var(--ds-space-4, 1rem) var(--ds-space-5, 1.25rem);
    border-bottom: 1px solid var(--ds-glass-border-subtle, rgba(148, 163, 184, 0.08));
}

.command-search-icon {
    flex-shrink: 0;
    font-size: 1rem;
    color: var(--ds-text-muted, #94a3b8);
}

.command-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: var(--ds-text-base, 1rem);
    font-weight: var(--ds-font-medium, 500);
    font-family: var(--ds-font-sans);
    color: var(--ds-text-primary, #f8fafc);
    caret-color: var(--ds-accent-primary, #8b5cf6);
}

.command-search-input::placeholder {
    color: var(--ds-text-muted, #94a3b8);
}

.command-shortcut-hint {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
}

.command-shortcut-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: var(--ds-glass-1, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--ds-glass-border-subtle, rgba(148, 163, 184, 0.08));
    border-radius: var(--ds-radius-sm, 6px);
    font-size: var(--ds-text-xs, 0.75rem);
    font-family: var(--ds-font-mono, monospace);
    color: var(--ds-text-muted, #94a3b8);
}

/* Hide shortcut hints on mobile */
@media (max-width: 480px) {
    .command-shortcut-hint {
        display: none;
    }
}

/* ===========================================
   RESULTS AREA
   =========================================== */

.command-results {
    flex: 1;
    overflow-y: auto;
    padding: var(--ds-space-2, 0.5rem);
    scrollbar-width: thin;
    scrollbar-color: var(--ds-glass-border-emphasis) transparent;
}

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

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

.command-results::-webkit-scrollbar-thumb {
    background: var(--ds-glass-border-emphasis, rgba(148, 163, 184, 0.2));
    border-radius: 3px;
}

/* ===========================================
   SECTION GROUPS
   =========================================== */

.command-section {
    padding: var(--ds-space-2, 0.5rem) 0;
}

.command-section:first-child {
    padding-top: 0;
}

.command-section-title {
    padding: var(--ds-space-2, 0.5rem) var(--ds-space-3, 0.75rem);
    font-size: var(--ds-text-xs, 0.75rem);
    font-weight: var(--ds-font-semibold, 600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ds-text-muted, #94a3b8);
}

/* ===========================================
   COMMAND ITEMS
   =========================================== */

.command-item {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3, 0.75rem);
    padding: var(--ds-space-3, 0.75rem) var(--ds-space-4, 1rem);
    border-radius: var(--ds-radius-lg, 16px);
    cursor: pointer;
    transition: all var(--ds-transition-fast, 150ms cubic-bezier(0.25, 0.1, 0.25, 1));
    color: var(--ds-text-secondary, #e2e8f0);
    text-decoration: none;
}

.command-item:hover,
.command-item.highlighted {
    background: var(--ds-accent-subtle, rgba(139, 92, 246, 0.1));
    color: var(--ds-text-primary, #f8fafc);
}

.command-item.highlighted {
    box-shadow: inset 0 0 0 1px var(--ds-accent-subtle, rgba(139, 92, 246, 0.2));
}

.command-item:active {
    transform: scale(0.99);
}

/* Item icon */
.command-item-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--ds-glass-1, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--ds-glass-border-subtle, rgba(148, 163, 184, 0.08));
    border-radius: var(--ds-radius-md, 12px);
    font-size: 0.9rem;
    color: var(--ds-text-muted, #94a3b8);
    transition: all var(--ds-transition-fast);
}

.command-item:hover .command-item-icon,
.command-item.highlighted .command-item-icon {
    background: var(--ds-accent-subtle, rgba(139, 92, 246, 0.15));
    border-color: var(--ds-accent-subtle, rgba(139, 92, 246, 0.2));
    color: var(--ds-accent-primary, #8b5cf6);
}

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

.command-item-title {
    font-size: var(--ds-text-sm, 0.8125rem);
    font-weight: var(--ds-font-medium, 500);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.command-item-description {
    font-size: var(--ds-text-xs, 0.75rem);
    color: var(--ds-text-muted, #94a3b8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 1px;
}

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

.command-item-shortcut kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: var(--ds-glass-1, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--ds-glass-border-subtle, rgba(148, 163, 184, 0.08));
    border-radius: var(--ds-radius-xs, 4px);
    font-size: 10px;
    font-family: var(--ds-font-mono, monospace);
    color: var(--ds-text-muted, #94a3b8);
}

/* Hide item shortcuts on mobile */
@media (max-width: 640px) {
    .command-item-shortcut {
        display: none;
    }
}

/* ===========================================
   ITEM TYPE VARIANTS
   =========================================== */

/* Navigation items */
.command-item[data-type="navigation"] .command-item-icon {
    color: var(--ds-accent-info, #3b82f6);
}

/* Action items */
.command-item[data-type="action"] .command-item-icon {
    color: var(--ds-accent-success, #10b981);
}

/* Recent items */
.command-item[data-type="recent"] .command-item-icon {
    color: var(--ds-text-muted, #94a3b8);
}

/* ===========================================
   EMPTY STATE
   =========================================== */

.command-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--ds-space-8, 2rem);
    text-align: center;
    color: var(--ds-text-muted, #94a3b8);
}

.command-empty-icon {
    font-size: 2rem;
    margin-bottom: var(--ds-space-3, 0.75rem);
    opacity: 0.5;
}

.command-empty-text {
    font-size: var(--ds-text-sm, 0.8125rem);
}

/* ===========================================
   FOOTER
   =========================================== */

.command-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--ds-space-3, 0.75rem) var(--ds-space-4, 1rem);
    border-top: 1px solid var(--ds-glass-border-subtle, rgba(148, 163, 184, 0.08));
    background: var(--ds-glass-1, rgba(15, 23, 42, 0.4));
}

.command-footer-hints {
    display: flex;
    gap: var(--ds-space-4, 1rem);
}

.command-footer-hint {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2, 0.5rem);
    font-size: var(--ds-text-xs, 0.75rem);
    color: var(--ds-text-muted, #94a3b8);
}

.command-footer-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--ds-glass-1, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--ds-glass-border-subtle, rgba(148, 163, 184, 0.08));
    border-radius: 4px;
    font-size: 10px;
    font-family: var(--ds-font-mono, monospace);
}

/* Mobile: Simplify footer */
@media (max-width: 640px) {
    .command-footer-hints {
        display: none;
    }
}

/* ===========================================
   ANIMATIONS
   =========================================== */

@keyframes command-slide-in {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.96) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scale(1) translateY(0);
    }
}

@keyframes command-highlight-pulse {
    0%, 100% {
        box-shadow: inset 0 0 0 1px var(--ds-accent-subtle, rgba(139, 92, 246, 0.2));
    }
    50% {
        box-shadow: inset 0 0 0 2px var(--ds-accent-subtle, rgba(139, 92, 246, 0.3));
    }
}

/* ===========================================
   REDUCED MOTION
   =========================================== */

@media (prefers-reduced-motion: reduce) {
    .command-palette-overlay,
    .command-palette,
    .command-item {
        transition: opacity 0.1s ease;
    }

    .command-palette.visible {
        transform: translateX(-50%) scale(1) translateY(0);
    }
}

/* ===========================================
   PRINT - Hide on print
   =========================================== */

@media print {
    .command-palette-overlay,
    .command-palette {
        display: none !important;
    }
}
