/* ═══════════════════════════════════════════════════
   Ajax Live Search — als-style.css
   ═══════════════════════════════════════════════════ */

:root {
    --als-accent: #2563eb;
    --als-accent-light: #dbeafe;
    --als-bg: #ffffff;
    --als-surface: #f8fafc;
    --als-border: #e2e8f0;
    --als-text: #0f172a;
    --als-muted: #64748b;
    --als-highlight-bg: #fef9c3;
    --als-highlight-fg: #713f12;
    --als-overlay-bg: rgba(15, 23, 42, 0.55);
    --als-radius: 14px;
    --als-shadow: 0 25px 60px rgba(0, 0, 0, .18), 0 8px 24px rgba(0, 0, 0, .10);
    --als-font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --als-transition: .18s cubic-bezier(.4, 0, .2, 1);
}

/* ── Overlay ───────────────────────────────────────── */
.als-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999999;
    background: var(--als-overlay-bg);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(16px, 5vw, 80px) 16px;
    opacity: 0;
    visibility: hidden;
    backdrop-filter: blur(4px);
    transition: opacity var(--als-transition), visibility var(--als-transition);
}

.als-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* ── Modal box ─────────────────────────────────────── */
.als-modal {
    background: var(--als-bg);
    border-radius: var(--als-radius);
    box-shadow: var(--als-shadow);
    width: 100%;
    max-width: 660px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(-16px) scale(.98);
    transition: transform var(--als-transition);
    max-height: calc(100vh - clamp(32px, 10vw, 160px));
}

.als-overlay.is-open .als-modal {
    transform: translateY(0) scale(1);
}

/* ── Header ────────────────────────────────────────── */
.als-modal__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--als-border);
    flex-shrink: 0;
}

.als-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--als-surface);
    border: 1.5px solid var(--als-border);
    border-radius: 9px;
    padding: 0 12px;
    transition: border-color var(--als-transition), box-shadow var(--als-transition);
}

.als-input-wrap:focus-within {
    border-color: var(--als-accent);
    box-shadow: 0 0 0 3px var(--als-accent-light);
}

.als-input-icon {
    width: 18px;
    height: 18px;
    color: var(--als-muted);
    flex-shrink: 0;
}

input.als-input {
    flex: 1;
    border: none;
    background: transparent;
    font: 500 16px/1 var(--als-font);
    color: var(--als-text);
    padding: 12px 0;
    outline: none !important;
}

input.als-input::placeholder {
    color: var(--als-muted);
    font-weight: 400;
}

.als-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--als-muted);
    font-size: 14px;
    padding: 4px;
    border-radius: 50%;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--als-transition), background var(--als-transition);
}

.als-clear.visible {
    opacity: 1;
    pointer-events: auto;
}

.als-clear:hover {
    background: var(--als-border);
    color: var(--als-text);
}

.als-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--als-muted);
    font-size: 18px;
    padding: 6px 8px;
    border-radius: 8px;
    line-height: 1;
    flex-shrink: 0;
    transition: background var(--als-transition), color var(--als-transition);
}

.als-close:hover {
    background: var(--als-surface);
    color: var(--als-text);
}

/* ── Body ──────────────────────────────────────────── */
.als-modal__body {
    overflow-y: auto;
    flex: 1;
    min-height: 80px;
    padding: 8px 0;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: var(--als-border) transparent;
}

/* ── Hint / empty state ────────────────────────────── */
.als-hint,
.als-no-results {
    padding: 32px 20px;
    text-align: center;
    color: var(--als-muted);
    font: 14px/1.6 var(--als-font);
    display: none;
}

.als-hint.visible,
.als-no-results.visible {
    display: block;
}

/* ── Spinner ───────────────────────────────────────── */
.als-spinner {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 28px;
}

.als-spinner.visible {
    display: flex;
}

.als-spinner span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--als-accent);
    animation: als-bounce 1.1s ease-in-out infinite;
}

.als-spinner span:nth-child(2) {
    animation-delay: .15s;
}

.als-spinner span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes als-bounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: .4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ── Section label ─────────────────────────────────── */
.als-section-label {
    font: 600 10px/1 var(--als-font);
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--als-muted);
    padding: 10px 20px 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.als-section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--als-border);
}

/* ── Result item ───────────────────────────────────── */
.als-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 20px;
    text-decoration: none;
    color: var(--als-text);
    cursor: pointer;
    transition: background var(--als-transition);
    border-radius: 0;
    outline: none;
    position: relative;
}

.als-item:hover,
.als-item.is-active {
    background: var(--als-surface);
}

.als-item.is-active::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--als-accent);
    border-radius: 2px;
}

/* Thumbnail */
.als-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--als-surface);
    border: 1px solid var(--als-border);
}

.als-thumb-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--als-surface);
    border: 1px solid var(--als-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--als-muted);
    font-size: 18px;
}

/* Text */
.als-item-text {
    flex: 1;
    min-width: 0;
}

.als-item-title {
    font: 500 14px/1.3 var(--als-font);
    color: var(--als-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.als-item-meta {
    font: 400 12px/1.3 var(--als-font);
    color: var(--als-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Price badge */
.als-item-price {
    font: 600 13px/1 var(--als-font);
    color: var(--als-accent);
    flex-shrink: 0;
}

/* ── Highlight ─────────────────────────────────────── */
.als-hl {
    background: var(--als-highlight-bg);
    color: var(--als-highlight-fg);
    border-radius: 3px;
    padding: 0 2px;
    font-weight: 600;
}

/* ── Footer ────────────────────────────────────────── */
.als-modal__footer {
    padding: 10px 20px;
    border-top: 1px solid var(--als-border);
    font: 400 11px/1 var(--als-font);
    color: var(--als-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.als-kbd {
    background: var(--als-surface);
    border: 1px solid var(--als-border);
    border-radius: 4px;
    padding: 2px 5px;
    font: 600 10px/1.4 var(--als-font);
    color: var(--als-text);
}

/* ── Inline trigger (shortcode) ────────────────────── */
.als-inline-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--als-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font: 500 15px var(--als-font);
    cursor: pointer;
    transition: opacity var(--als-transition);
}

.als-inline-trigger:hover {
    opacity: .88;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 480px) {
    .als-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .als-modal {
        border-radius: var(--als-radius) var(--als-radius) 0 0;
        max-height: 90vh;
    }

    .als-modal__footer {
        display: none;
    }
}