/* =====================================================
   Command Palette & Keyboard Shortcuts
   ===================================================== */

/* ── Command Palette Overlay ────────────────────────── */

.command-palette-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.command-palette-overlay.active {
    display: flex;
}

/* ── Palette Container ──────────────────────────────── */

.command-palette {
    width: 100%;
    max-width: 560px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    animation: cp-enter 150ms ease-out;
}

@keyframes cp-enter {
    from {
        opacity: 0;
        transform: scale(0.98) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ── Header / Search Input ──────────────────────────── */

.command-palette-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.command-palette-icon {
    font-size: var(--font-size-lg);
    flex-shrink: 0;
    opacity: 0.5;
}

.command-palette-header input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: var(--font-size-base);
    color: var(--text-primary);
    font-family: inherit;
    padding: var(--space-1) 0;
}

.command-palette-header input::placeholder {
    color: var(--text-muted);
}

.command-palette-hint {
    font-size: 0.6875rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    font-family: inherit;
    flex-shrink: 0;
}

/* ── Results Container ──────────────────────────────── */

.command-palette-results {
    max-height: 400px;
    overflow-y: auto;
}

/* ── Category Headers ───────────────────────────────── */

.cp-category {
    padding: var(--space-2) var(--space-4);
    font-size: 0.6875rem;
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

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

/* ── Result Items ───────────────────────────────────── */

.cp-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.cp-item:hover,
.cp-item.selected {
    background: var(--bg-secondary);
}

.cp-item-icon {
    font-size: var(--font-size-lg);
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.cp-item-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.cp-item-label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cp-item-subtitle {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cp-empty {
    padding: var(--space-8) var(--space-4);
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* ── Shortcuts Help Overlay ─────────────────────────── */

.shortcuts-help-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}

.shortcuts-help-overlay.active {
    display: flex;
}

.shortcuts-help-panel {
    width: 100%;
    max-width: 480px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: cp-enter 150ms ease-out;
}

.shortcuts-help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
}

.shortcuts-help-header h3 {
    margin: 0;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.shortcuts-help-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
}

.shortcuts-help-close:hover {
    color: var(--text-primary);
}

.shortcuts-help-body {
    padding: var(--space-3) var(--space-5);
    max-height: 60vh;
    overflow-y: auto;
}

/* ── Shortcut Groups ────────────────────────────────── */

.shortcuts-group {
    padding: var(--space-3) 0;
}

.shortcuts-group + .shortcuts-group {
    border-top: 1px solid var(--border-color);
}

.shortcuts-group-title {
    font-size: 0.6875rem;
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-1) 0;
}

.shortcut-keys {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.shortcut-keys kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.6875rem;
    font-family: inherit;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    min-width: 20px;
    text-align: center;
    line-height: 1.4;
}

.kbd-plus,
.kbd-then {
    font-size: 0.625rem;
    color: var(--text-muted);
}

.shortcut-desc {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* ── Go-To Hint Toast ───────────────────────────────── */

.goto-hint {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    opacity: 0;
    transition: opacity 150ms ease, transform 150ms ease;
    z-index: 1100;
    pointer-events: none;
}

.goto-hint.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Section Hint Tooltips ──────────────────────────── */

.section-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    cursor: help;
    position: relative;
    flex-shrink: 0;
    line-height: 1;
    user-select: none;
    outline: none;
    vertical-align: middle;
}

.section-hint-tooltip {
    display: none;
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-3);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-normal);
    color: var(--text-secondary);
    text-transform: none;
    white-space: pre-line;
    max-width: min(280px, calc(100vw - 24px));
    min-width: min(200px, calc(100vw - 24px));
    width: max-content;
    z-index: 10001;
    line-height: 1.5;
    cursor: default;
    pointer-events: none;
}

/* ── Mobile Adjustments ─────────────────────────────── */

@media (max-width: 768px) {
    .command-palette-overlay {
        padding-top: var(--space-4);
        padding-left: 12px;
        padding-right: 12px;
    }

    .command-palette {
        max-width: 100%;
    }

    .shortcuts-help-overlay {
        padding-top: var(--space-4);
        padding-left: 12px;
        padding-right: 12px;
    }

    .shortcuts-help-panel {
        max-width: 100%;
    }
}
