/* ==========================================================================
   Command Palette (Cmd+K / Ctrl+K)
   Quick-access search and command bar overlay
   ========================================================================== */

/* Backdrop overlay */
.command-palette-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-command-palette);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

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

/* Modal container */
.command-palette {
    width: 100%;
    max-width: 560px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    transform: scale(0.95) translateY(-10px);
    transition: transform 0.15s ease;
}

.command-palette-overlay.active .command-palette {
    transform: scale(1) translateY(0);
}

/* Search input area */
.command-palette-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
    gap: 10px;
}

.command-palette-header .search-icon {
    color: #9ca3af;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.command-palette-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: #111827;
    background: transparent;
    padding: 0;
    line-height: 1.5;
}

.command-palette-input::placeholder {
    color: #9ca3af;
}

.command-palette-input:focus {
    outline: none;
}

.command-palette-shortcut-hint {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px 7px;
    border-radius: 6px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    line-height: 1;
    user-select: none;
}

/* Results area */
.command-palette-body {
    max-height: 360px;
    overflow-y: auto;
    padding: 8px 0;
    overscroll-behavior: contain;
}

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

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

.command-palette-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.command-palette-body::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Category headers */
.command-palette-category {
    padding: 8px 16px 4px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    user-select: none;
}

/* Command items */
.command-palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background-color 0.1s ease, border-color 0.1s ease;
}

.command-palette-item:hover {
    background-color: #faf5ff;
}

.command-palette-item.selected {
    background-color: #faf5ff;
    border-left-color: #9333ea;
}

.command-palette-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #f3f4f6;
    color: #6b7280;
    flex-shrink: 0;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.command-palette-item.selected .command-palette-item-icon,
.command-palette-item:hover .command-palette-item-icon {
    background: #ede9fe;
    color: #9333ea;
}

.command-palette-item-icon svg {
    width: 16px;
    height: 16px;
}

.command-palette-item-label {
    flex: 1;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    line-height: 1.4;
}

.command-palette-item-label mark {
    background: #fde68a;
    color: #111827;
    border-radius: 2px;
    padding: 0 1px;
}

.command-palette-item-category-badge {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    flex-shrink: 0;
}

/* Recently used indicator */
.command-palette-item-recent {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 11px;
    color: #9ca3af;
    flex-shrink: 0;
}

.command-palette-item-recent svg {
    width: 12px;
    height: 12px;
}

/* Empty state */
.command-palette-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
}

.command-palette-empty-icon {
    color: #d1d5db;
    margin-bottom: 12px;
}

.command-palette-empty-icon svg {
    width: 40px;
    height: 40px;
}

.command-palette-empty-text {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 4px;
}

.command-palette-empty-hint {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 13px;
    color: #9ca3af;
}

/* Footer / keyboard hints */
.command-palette-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 12px 12px;
}

.command-palette-footer-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 12px;
    color: #9ca3af;
}

.command-palette-footer-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    padding: 2px 5px;
    border-radius: 4px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    line-height: 1;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

.command-palette-footer-hint svg {
    width: 14px;
    height: 14px;
}

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

@keyframes commandPaletteSlideIn {
    from {
        transform: scale(0.95) translateY(-10px);
    }
    to {
        transform: scale(1) translateY(0);
    }
}

/* Responsive - full width on mobile */
@media (max-width: 640px) {
    .command-palette-overlay {
        padding-top: 0;
        align-items: flex-start;
    }

    .command-palette {
        max-width: 100%;
        border-radius: 0 0 12px 12px;
        max-height: 100vh;
    }

    .command-palette-body {
        max-height: calc(100vh - 140px);
    }

    .command-palette-header {
        padding: 16px;
    }

    .command-palette-input {
        font-size: 16px; /* Prevents iOS zoom on input focus */
    }

    .command-palette-shortcut-hint {
        display: none;
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .command-palette-overlay,
    .command-palette,
    .command-palette-item {
        transition: none;
    }
}

/* Dark mode: CRM is light-only. Dark mode is Hangout PWA only.
   Do NOT add @media (prefers-color-scheme: dark) rules here — they fire
   based on the OS setting even when color-scheme: only light is declared. */
