/* MwCommandPalette — global Cmd+K page jumper.
   Prefix: mw-cp-*
   Loaded via App.razor with Assets["mw-command-palette.css"].

   This file restyles the MudDialog shell from the inside out: we use
   NoHeader + Class="mw-cp-shell mw-dialog-frameless" so MudBlazor renders
   no header chrome and applies no padding to the content area, then we
   draw the entire palette ourselves. */

/* ============================================================
   THEME TOKENS — scoped to the palette so they cannot leak.
   ============================================================ */
.mw-cp-shell {
    --mw-cp-surface:           hsl(240 12% 9%);
    --mw-cp-surface-elev:      hsl(240 11% 11%);
    --mw-cp-row-hover:         hsla(0 0% 100% / 0.025);
    --mw-cp-row-selected:      hsla(263 90% 65% / 0.09);

    --mw-cp-border:            hsla(0 0% 100% / 0.06);
    --mw-cp-border-strong:     hsla(0 0% 100% / 0.10);
    --mw-cp-border-accent:     hsla(263 90% 65% / 0.32);

    --mw-cp-text:              hsl(0 0% 96%);
    --mw-cp-text-dim:          hsl(240 5% 60%);
    --mw-cp-text-faint:        hsl(240 5% 38%);

    --mw-cp-accent:            hsl(263 90% 67%);
    --mw-cp-accent-soft:       hsl(263 70% 78%);
    --mw-cp-accent-glow:       hsla(263 90% 67% / 0.18);

    --mw-cp-ring:
        0 0 0 1px var(--mw-cp-border-strong),
        0 22px 60px -16px hsla(0 0% 0% / 0.7),
        0 8px 24px -8px hsla(0 0% 0% / 0.5),
        0 0 80px -20px var(--mw-cp-accent-glow);
}

/* ============================================================
   DIALOG SHELL — overrides MudDialog box.
   The MudDialogProvider renders our component inside .mud-dialog;
   we tag that node with .mw-cp-shell via the Class parameter.
   ============================================================ */
.mud-dialog.mw-cp-shell {
    width: min(640px, calc(100vw - 32px));
    max-width: min(640px, calc(100vw - 32px));
    max-height: 80vh;
    background: var(--mw-cp-surface) !important;
    border-radius: 14px !important;
    box-shadow: var(--mw-cp-ring) !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    position: relative;
    animation: mw-cp-dialog-in 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Hairline accent line at the top of the dialog */
.mud-dialog.mw-cp-shell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 16px;
    right: 16px;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        var(--mw-cp-accent) 30%,
        var(--mw-cp-accent-soft) 50%,
        var(--mw-cp-accent) 70%,
        transparent);
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}

/* Force the inner DialogContent area to fill and not add its own padding */
.mud-dialog.mw-cp-shell .mud-dialog-content {
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    overflow: visible !important;
}

@keyframes mw-cp-dialog-in {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================================
   BACKDROP — applied via DialogOptions.BackgroundClass
   ============================================================ */
.mw-cp-backdrop {
    background: hsla(240 15% 4% / 0.55) !important;
    backdrop-filter: blur(14px) saturate(140%) !important;
    -webkit-backdrop-filter: blur(14px) saturate(140%) !important;
    animation: mw-cp-backdrop-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mw-cp-backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================
   ROOT — the wrapper inside DialogContent we render ourselves
   ============================================================ */
.mw-cp-root {
    display: flex;
    flex-direction: column;
    color: var(--mw-cp-text);
    font-family: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    /* match the dialog's max height so the inner result list scrolls
       instead of pushing the footer out */
    max-height: 80vh;
}

/* ============================================================
   HEADER — search input + esc pill
   ============================================================ */
.mw-cp-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 18px 18px 22px;
    border-bottom: 1px solid var(--mw-cp-border);
    flex-shrink: 0;
}

.mw-cp-header .mw-cp-search-icon {
    color: var(--mw-cp-text-dim);
    font-size: 20px !important;
    flex-shrink: 0;
    transition: color 150ms ease;
}

.mw-cp-header:focus-within .mw-cp-search-icon {
    color: var(--mw-cp-accent-soft);
}

.mw-cp-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--mw-cp-text);
    font-family: inherit;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: -0.005em;
    caret-color: var(--mw-cp-accent);
    padding: 0;
}

.mw-cp-input::placeholder {
    color: var(--mw-cp-text-faint);
    font-weight: 300;
}

/* ============================================================
   KEYBOARD PILL — used in header and footer
   ============================================================ */
.mw-cp-kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 5px;
    font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--mw-cp-text-dim);
    background: hsla(0 0% 100% / 0.04);
    border: 1px solid hsla(0 0% 100% / 0.07);
    border-bottom-color: hsla(0 0% 100% / 0.12);
    box-shadow: 0 1px 0 hsla(0 0% 0% / 0.2);
    text-transform: uppercase;
    flex-shrink: 0;
}

/* ============================================================
   RESULT LIST
   ============================================================ */
.mw-cp-results {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
    scrollbar-width: thin;
    scrollbar-color: hsla(0 0% 100% / 0.12) transparent;
}
.mw-cp-results::-webkit-scrollbar { width: 8px; }
.mw-cp-results::-webkit-scrollbar-track { background: transparent; }
.mw-cp-results::-webkit-scrollbar-thumb {
    background: hsla(0 0% 100% / 0.08);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.mw-cp-section-label {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 9.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--mw-cp-text-faint);
    padding: 12px 14px 6px 14px;
    font-weight: 500;
}

.mw-cp-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: background 100ms ease;
    user-select: none;
}

.mw-cp-row:hover {
    background: var(--mw-cp-row-hover);
}

.mw-cp-row.is-selected {
    background: var(--mw-cp-row-selected);
}

/* Vertical accent bar on the selected row */
.mw-cp-row.is-selected::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 18px;
    border-radius: 2px;
    background: var(--mw-cp-accent);
    box-shadow: 0 0 12px var(--mw-cp-accent-glow);
}

.mw-cp-row .mw-cp-row-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: hsla(0 0% 100% / 0.035);
    border: 1px solid hsla(0 0% 100% / 0.05);
    color: var(--mw-cp-text-dim);
    flex-shrink: 0;
    transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.mw-cp-row .mw-cp-row-icon .mud-icon-root {
    font-size: 17px !important;
}

.mw-cp-row.is-selected .mw-cp-row-icon {
    color: var(--mw-cp-accent-soft);
    border-color: var(--mw-cp-border-accent);
    background: hsla(263 90% 65% / 0.06);
}

.mw-cp-row .mw-cp-row-name {
    flex: 1;
    font-size: 14px;
    font-weight: 450;
    letter-spacing: -0.005em;
    color: var(--mw-cp-text);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mw-cp-row .mw-cp-row-route {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    color: var(--mw-cp-text-faint);
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
}

.mw-cp-row.is-selected .mw-cp-row-route {
    color: var(--mw-cp-text-dim);
}

/* Empty state */
.mw-cp-empty {
    padding: 56px 24px;
    text-align: center;
    color: var(--mw-cp-text-faint);
    font-size: 13px;
    line-height: 1.6;
}

.mw-cp-empty .mw-cp-empty-icon {
    font-size: 32px !important;
    color: var(--mw-cp-text-faint);
    margin-bottom: 8px;
    opacity: 0.6;
}

/* ============================================================
   FOOTER
   ============================================================ */
.mw-cp-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--mw-cp-border);
    background: hsla(0 0% 0% / 0.18);
    flex-shrink: 0;
}

.mw-cp-footer-hints {
    display: flex;
    align-items: center;
    gap: 18px;
}

.mw-cp-footer-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--mw-cp-text-faint);
    letter-spacing: 0.01em;
}

.mw-cp-brand {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--mw-cp-text-faint);
    text-transform: uppercase;
}

.mw-cp-brand-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--mw-cp-accent);
    margin-right: 6px;
    box-shadow: 0 0 8px var(--mw-cp-accent-glow);
    transform: translateY(-1px);
}
