/* ============================================================
   BSD-SearchSidebar.css  |  Slide-in search panel for the
   BlueSky Dashboard Design System
   Custom prefix: bsd-
   DEPENDENCY: load BSD-Stylesheet.css BEFORE this file — every
   rule below reads BSD's --bsd-* custom properties.

   Markup shape:
     <button class="bsd-search-trigger">...</button>

     <div class="bsd-search-backdrop"></div>
     <aside class="bsd-search-sidebar">
       <div class="bsd-search-sidebar__header">
         <div class="bsd-input-wrap bsd-search-sidebar__input-wrap">
           <svg class="bsd-input-icon">...</svg>
           <input class="bsd-input bsd-search-sidebar__input" type="text">
         </div>
         <button class="bsd-search-sidebar__close">...</button>
       </div>
       <div class="bsd-search-sidebar__body">
         <p class="bsd-search-sidebar__section-label">Recent</p>
         <a class="bsd-search-result">...</a>
         ...
         <div class="bsd-search-sidebar__empty">...</div>
       </div>
     </aside>

   Toggle by adding/removing "open" on both
   .bsd-search-backdrop and .bsd-search-sidebar (see the JS
   snippet at the bottom of this comment block for the minimal
   wiring):

     trigger.addEventListener('click', () => {
       sidebar.classList.add('open');
       backdrop.classList.add('open');
       input.focus();
     });
   ============================================================ */

/* ── Trigger button ───────────────────────────────────────── */
.bsd-search-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--bsd-r-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--bsd-text-muted);
    cursor: pointer;
    transition: var(--bsd-t-fast);
}

.bsd-search-trigger svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.bsd-search-trigger:hover {
    background: var(--bsd-surface-3);
    color: var(--bsd-text);
}

.bsd-search-trigger:focus-visible {
    outline: none;
    box-shadow: var(--bsd-shadow-focus);
}

/* Optional: show a "/" or "⌘K" hint next to the icon */
.bsd-search-trigger__hint {
    margin-left: 8px;
    font-family: var(--bsd-font-mono);
    font-size: var(--bsd-text-2xs);
    color: var(--bsd-text-faint);
    border: 1px solid var(--bsd-border-2);
    border-radius: var(--bsd-r-xs);
    padding: 1px 5px;
}


/* ── Backdrop ─────────────────────────────────────────────── */
.bsd-search-backdrop {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.45);
    backdrop-filter: blur(3px);
    z-index: var(--bsd-z-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--bsd-dur) var(--bsd-ease),
                visibility 0s linear var(--bsd-dur);
}

.bsd-search-backdrop.open {
    opacity: 1;
    visibility: visible;
    transition: opacity var(--bsd-dur) var(--bsd-ease);
}


/* ── Sliding panel ────────────────────────────────────────── */
.bsd-search-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 380px;
    max-width: 88vw;
    background: var(--bsd-surface);
    border-right: 1px solid var(--bsd-border);
    box-shadow: var(--bsd-shadow-xl);
    z-index: var(--bsd-z-modal);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--bsd-dur) var(--bsd-ease-out);
}

.bsd-search-sidebar.open {
    transform: translateX(0);
}

/* Right-docked variant, for layouts where search opens from the right */
.bsd-search-sidebar--right {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--bsd-border);
    transform: translateX(100%);
}

.bsd-search-sidebar--right.open {
    transform: translateX(0);
}


/* ── Header: search field + close ────────────────────────── */
.bsd-search-sidebar__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border-bottom: 1px solid var(--bsd-border);
    flex-shrink: 0;
}

.bsd-search-sidebar__input-wrap {
    flex: 1;
    min-width: 0;
}

.bsd-search-sidebar__input-wrap .bsd-input-icon {
    color: var(--bsd-text-faint);
}

.bsd-search-sidebar__input-wrap .bsd-input-icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: block;
}

.bsd-search-sidebar__input {
    background: var(--bsd-surface-2);
    border-color: transparent;
}

.bsd-search-sidebar__input:focus {
    background: var(--bsd-surface);
    border-color: var(--bsd-primary);
}

.bsd-search-sidebar__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: var(--bsd-r-sm);
    border: none;
    background: transparent;
    color: var(--bsd-text-muted);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: var(--bsd-t-fast);
}

.bsd-search-sidebar__close:hover {
    background: var(--bsd-surface-3);
    color: var(--bsd-text);
}


/* ── Body: results ────────────────────────────────────────── */
.bsd-search-sidebar__body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px 24px;
}

.bsd-search-sidebar__section-label {
    font-family: var(--bsd-font-display);
    font-size: var(--bsd-text-2xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--bsd-text-faint);
    margin: 14px 8px 6px;
}

.bsd-search-sidebar__section-label:first-child {
    margin-top: 8px;
}

/* Individual result row */
.bsd-search-result {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px;
    border-radius: var(--bsd-r-sm);
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: var(--bsd-t-fast);
}

.bsd-search-result:hover,
.bsd-search-result--active {
    background: var(--bsd-surface-2);
}

.bsd-search-result__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: var(--bsd-r-sm);
    background: var(--bsd-primary-bg);
    color: var(--bsd-primary);
}

.bsd-search-result__icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.bsd-search-result__icon--success { background: var(--bsd-success-bg); color: var(--bsd-success); }
.bsd-search-result__icon--warning { background: var(--bsd-warning-bg); color: var(--bsd-warning); }
.bsd-search-result__icon--danger  { background: var(--bsd-danger-bg);  color: var(--bsd-danger); }
.bsd-search-result__icon--violet  { background: var(--bsd-violet-100); color: var(--bsd-violet-600); }
.bsd-search-result__icon--neutral { background: var(--bsd-surface-3); color: var(--bsd-text-muted); }

.bsd-search-result__body {
    min-width: 0;
    flex: 1;
}

.bsd-search-result__title {
    font-size: var(--bsd-text-sm);
    font-weight: 600;
    color: var(--bsd-text);
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bsd-search-result__title mark {
    background: var(--bsd-amber-100);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

.bsd-search-result__meta {
    font-size: var(--bsd-text-xs);
    color: var(--bsd-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.bsd-search-result__badge {
    flex-shrink: 0;
    align-self: center;
}

.bsd-search-result__kbd {
    flex-shrink: 0;
    align-self: center;
    font-family: var(--bsd-font-mono);
    font-size: var(--bsd-text-2xs);
    color: var(--bsd-text-faint);
    border: 1px solid var(--bsd-border-2);
    border-radius: var(--bsd-r-xs);
    padding: 1px 5px;
}


/* ── Empty / loading / no-results states ─────────────────── */
.bsd-search-sidebar__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 56px 20px;
    color: var(--bsd-text-muted);
}

.bsd-search-sidebar__empty svg {
    width: 30px;
    height: 30px;
    stroke: var(--bsd-text-faint);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    margin-bottom: 12px;
}

.bsd-search-sidebar__empty p {
    margin: 0;
    font-size: var(--bsd-text-sm);
}

.bsd-search-sidebar__empty p.bsd-search-sidebar__empty-sub {
    font-size: var(--bsd-text-xs);
    color: var(--bsd-text-faint);
    margin-top: 4px;
}

/* Skeleton rows shown while a query is in flight */
.bsd-search-result--loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
}

.bsd-search-result--loading .bsd-search-result__icon {
    background: var(--bsd-surface-3);
}


/* ── Footer (optional: shortcut legend) ───────────────────── */
.bsd-search-sidebar__footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    border-top: 1px solid var(--bsd-border);
    background: var(--bsd-surface-2);
}

.bsd-search-sidebar__footer-hint {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: var(--bsd-text-2xs);
    color: var(--bsd-text-faint);
}

.bsd-search-sidebar__footer-hint kbd {
    font-family: var(--bsd-font-mono);
    font-size: var(--bsd-text-2xs);
    background: var(--bsd-surface);
    border: 1px solid var(--bsd-border-2);
    border-radius: var(--bsd-r-xs);
    padding: 1px 5px;
}


/* ── Scrollbar ────────────────────────────────────────────── */
.bsd-search-sidebar__body {
    scrollbar-width: thin;
    scrollbar-color: var(--bsd-border-2) transparent;
}

.bsd-search-sidebar__body::-webkit-scrollbar {
    width: 8px;
}

.bsd-search-sidebar__body::-webkit-scrollbar-thumb {
    background: var(--bsd-border-2);
    border-radius: var(--bsd-r-full);
}


/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 560px) {
    .bsd-search-sidebar {
        width: 100%;
        max-width: 100%;
        border-right: none;
    }
}


/* ── Dark theme ───────────────────────────────────────────── */
[data-bsd-theme="dark"] .bsd-search-sidebar__input {
    background: var(--bsd-surface-3);
}

[data-bsd-theme="dark"] .bsd-search-result__title mark {
    background: rgb(251 191 36 / 0.25);
}
