/* Frontbox Search — quick search panel (DESIGN-SPEC C1–C9) and /search/ page (D).
   Site tokens: Bootstrap 5.2 theme of Plastic System; no own palette. */

.wgp-qs-root {
    --wgp-qs-text: #212529;
    --wgp-qs-muted: #6c757d;
    --wgp-qs-accent: #0d6efd;
    --wgp-qs-accent-hover: #0a58ca;
    --wgp-qs-icon: #2F80ED;
    --wgp-qs-soft: rgba(13, 110, 253, .08);
    --wgp-qs-border: #dee2e6;
    --wgp-qs-subtle: #f8f9fa;
    --wgp-qs-header-bottom: 103px;
    position: relative;
    min-width: 0;
    font-family: inherit;
}

/* While the panel is open the header must sit above toasts (1031); the mobile layer above the bottom menu (1030). */
html.wgp-qs-open .fixed-top { z-index: 1035; }
html.wgp-qs-mobile-open .fixed-top { z-index: 1060; }
html.wgp-qs-mobile-open, html.wgp-qs-mobile-open body { overflow: hidden; }
/* The Bitrix24 widget button (z 10150) would float over the full-screen layer. */
html.wgp-qs-mobile-open .b24-widget-button-wrapper { display: none !important; }

/* ── Field ───────────────────────────────────────────── */
.wgp-qs-bar { display: flex; align-items: center; min-width: 0; }
.wgp-qs-back, .wgp-qs-cancel { display: none; }
.wgp-qs-field { position: relative; flex: 1 1 auto; min-width: 0; margin: 0; }
.wgp-qs-icon {
    position: absolute; top: 50%; left: 10px; z-index: 2;
    width: 28px; height: 28px; color: var(--wgp-qs-icon);
    transform: translateY(-50%); pointer-events: none;
}
.wgp-qs-root .wgp-qs-input {
    height: 40px; padding: 0 40px 0 44px;
    border-radius: 6px; font-size: 16px; line-height: 1.5; color: var(--wgp-qs-text);
}
.wgp-qs-root .wgp-qs-input::placeholder { color: var(--wgp-qs-muted); opacity: 1; }
.wgp-qs-root .wgp-qs-input::-webkit-search-cancel-button,
.wgp-qs-root .wgp-qs-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.wgp-qs-clear {
    position: absolute; top: 50%; right: 4px; z-index: 2;
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px;
    background: transparent; color: var(--wgp-qs-muted); transform: translateY(-50%);
}
.wgp-qs-clear:hover { background: var(--wgp-qs-subtle); color: var(--wgp-qs-text); }
.wgp-qs-clear[hidden] { display: none; }

/* ── Panel ───────────────────────────────────────────── */
.wgp-qs-backdrop {
    position: fixed; top: var(--wgp-qs-header-bottom); right: 0; bottom: 0; left: 0;
    z-index: 1029; background: rgba(33, 37, 41, .24);
}
.wgp-qs-backdrop[hidden] { display: none; }
.wgp-qs {
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 1035;
    display: flex; flex-direction: column;
    width: clamp(640px, 100%, 880px);
    max-height: min(640px, calc(100dvh - var(--wgp-qs-header-bottom) - 24px));
    overflow: hidden;
    border: 1px solid var(--wgp-qs-border); border-radius: 8px;
    background: #fff; color: var(--wgp-qs-text);
    box-shadow: 0 12px 32px rgba(33, 37, 41, .16), 0 2px 6px rgba(33, 37, 41, .08);
    font-size: 14px; line-height: 20px; text-align: left;
    animation: wgp-qs-in 120ms ease-out;
}
.wgp-qs[hidden] { display: none; }
.wgp-qs.is-closing { animation: wgp-qs-out 80ms ease-in forwards; }
@keyframes wgp-qs-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes wgp-qs-out { from { opacity: 1; } to { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) {
    .wgp-qs, .wgp-qs.is-closing { animation: none; }
    .wgp-qs-skeleton { animation: none !important; }
}

.wgp-qs-list { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.wgp-qs-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 8px; }
.wgp-qs-progress {
    position: absolute; top: 0; left: 0; z-index: 3; width: 100%; height: 2px; overflow: hidden;
    background: rgba(13, 110, 253, .15);
}
.wgp-qs-progress::after {
    content: ""; position: absolute; top: 0; left: -40%; width: 40%; height: 100%;
    background: var(--wgp-qs-accent); animation: wgp-qs-progress 900ms ease-in-out infinite;
}
.wgp-qs-progress[hidden] { display: none; }
@keyframes wgp-qs-progress { to { left: 100%; } }

.wgp-qs-label {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin: 0; padding: 12px 16px 8px;
    font-size: 13px; line-height: 18px; font-weight: 600; color: var(--wgp-qs-muted);
}
.wgp-qs-label button {
    padding: 0; border: 0; background: none; font: inherit; font-weight: 400; color: var(--wgp-qs-accent);
}
.wgp-qs-label button:hover { color: var(--wgp-qs-accent-hover); text-decoration: underline; }

/* Chips: max 2 rows on desktop. */
.wgp-qs-chips {
    display: flex; flex-wrap: wrap; gap: 8px;
    max-height: 72px; overflow: hidden; padding: 0 16px 8px;
}
.wgp-qs-chip {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
    height: 32px; padding: 0 12px;
    border: 1px solid var(--wgp-qs-border); border-radius: 16px; background: #fff;
    font-size: 14px; line-height: 20px; color: var(--wgp-qs-text); text-decoration: none; white-space: nowrap;
}
.wgp-qs-chip > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.wgp-qs-chip-count { font-size: 13px; color: var(--wgp-qs-muted); }
.wgp-qs-chip:hover, .wgp-qs-chip.is-active {
    border-color: var(--wgp-qs-accent); background: var(--wgp-qs-soft); color: var(--wgp-qs-text);
}

/* Recent queries */
.wgp-qs-recent {
    display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 8px 8px 16px;
    color: var(--wgp-qs-text); text-decoration: none; font-size: 15px; line-height: 20px;
}
.wgp-qs-recent:hover, .wgp-qs-recent.is-active { background: var(--wgp-qs-soft); color: var(--wgp-qs-text); }
.wgp-qs-recent-icon { flex: 0 0 auto; width: 16px; height: 16px; color: var(--wgp-qs-muted); }
.wgp-qs-recent-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wgp-qs-recent-remove {
    flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--wgp-qs-muted);
}
.wgp-qs-recent-remove:hover { background: #e9ecef; color: var(--wgp-qs-text); }

/* Product rows */
.wgp-qs-row {
    display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 12px 16px;
    color: var(--wgp-qs-text); text-decoration: none;
}
.wgp-qs-row:hover, .wgp-qs-row.is-active { background: var(--wgp-qs-soft); color: var(--wgp-qs-text); }
.wgp-qs-thumb {
    flex: 0 0 48px; width: 48px; height: 48px; border-radius: 6px;
    background: var(--wgp-qs-subtle); object-fit: contain;
}
.wgp-qs-main { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.wgp-qs-name {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
    font-size: 15px; line-height: 20px; font-weight: 400; overflow-wrap: anywhere;
}
.wgp-qs-hl { font-weight: 600; }
.wgp-qs-meta { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; line-height: 18px; color: var(--wgp-qs-muted); }
.wgp-qs-art { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wgp-qs-swatches { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.wgp-qs-swatch { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 1px #ced4da; }
.wgp-qs-swatch.is-transparent { background: repeating-linear-gradient(45deg, #fff 0 2px, #dee2e6 2px 4px); }
.wgp-qs-swatch-more { font-size: 12px; color: var(--wgp-qs-muted); }
.wgp-qs-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; white-space: nowrap; text-align: right; }
.wgp-qs-price { font-size: 15px; line-height: 20px; font-weight: 600; color: var(--wgp-qs-text); }
.wgp-qs-price small { font-size: 13px; font-weight: 400; color: var(--wgp-qs-muted); }
.wgp-qs-root .wgp-qs-status {
    display: inline-flex; align-items: center; height: 20px; padding: 2px 6px;
    border-radius: 4px; font-size: 11px; line-height: 14px; font-weight: 500; white-space: nowrap;
}

/* Footer */
.wgp-qs-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex: 0 0 48px; height: 48px; padding: 0 16px;
    border-top: 1px solid var(--wgp-qs-border); background: var(--wgp-qs-subtle);
    font-size: 15px; line-height: 20px; font-weight: 600; color: var(--wgp-qs-accent); text-decoration: none;
}
.wgp-qs-footer[hidden] { display: none; }
.wgp-qs-footer:hover, .wgp-qs-footer.is-active { color: var(--wgp-qs-accent-hover); background: #eef4ff; }
.wgp-qs-kbd {
    padding: 1px 6px; border: 1px solid var(--wgp-qs-border); border-radius: 4px;
    background: #fff; color: var(--wgp-qs-muted); font: 400 12px/16px inherit; box-shadow: none;
}

/* Service states */
.wgp-qs-note { margin: 0; padding: 16px; font-size: 14px; line-height: 20px; color: var(--wgp-qs-muted); }
.wgp-qs-empty-title { margin: 0; padding: 16px 16px 4px; font-size: 15px; line-height: 20px; font-weight: 600; color: var(--wgp-qs-text); }
.wgp-qs-empty-hint { margin: 0; padding: 0 16px 4px; font-size: 14px; line-height: 20px; color: var(--wgp-qs-muted); }
.wgp-qs-empty-hint a { color: var(--wgp-qs-accent); }
.wgp-qs-catalog-link { display: inline-block; margin: 4px 16px 8px; font-size: 14px; color: var(--wgp-qs-accent); }
.wgp-qs-error { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
.wgp-qs-error p { margin: 0; font-size: 14px; line-height: 20px; color: var(--wgp-qs-muted); }

/* Skeleton */
.wgp-qs-skeleton { background: #e9ecef; border-radius: 6px; animation: wgp-qs-shimmer 1.2s ease-in-out infinite; }
@keyframes wgp-qs-shimmer { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.wgp-qs-sk-chips { display: flex; gap: 8px; padding: 12px 16px 8px; }
.wgp-qs-sk-chip { width: 120px; height: 32px; border-radius: 16px; }
.wgp-qs-sk-row { display: flex; align-items: center; gap: 12px; height: 72px; padding: 12px 16px; }
.wgp-qs-sk-thumb { flex: 0 0 48px; height: 48px; }
.wgp-qs-sk-lines { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; }
.wgp-qs-sk-line { height: 12px; }

/* Tablet: the panel takes the header row (set by JS through --wgp-qs-left / --wgp-qs-width). */
@media (min-width: 768px) {
    .wgp-qs.is-positioned { left: var(--wgp-qs-left, 0); width: var(--wgp-qs-width, auto); }
}

/* ── Phone: full-screen layer (C7) ───────────────────────────────────────────── */
@media (max-width: 767.98px) {
    .wgp-qs-root.is-fullscreen {
        position: fixed; inset: 0; z-index: 1060;
        display: flex; flex-direction: column;
        height: 100dvh; background: #fff;
    }
    .wgp-qs-root.is-fullscreen .wgp-qs-bar {
        flex: 0 0 56px; gap: 4px; padding: 8px 12px 8px 4px; border-bottom: 1px solid var(--wgp-qs-border);
    }
    .wgp-qs-root.is-fullscreen .wgp-qs-back {
        display: inline-flex; align-items: center; justify-content: center; flex: 0 0 44px;
        width: 44px; height: 44px; padding: 0; border: 0; background: none; color: var(--wgp-qs-text);
    }
    .wgp-qs-root.is-fullscreen .wgp-qs-cancel {
        display: inline-block; flex: 0 0 auto; padding: 0 0 0 8px; border: 0; background: none;
        font-size: 15px; line-height: 44px; color: var(--wgp-qs-accent);
    }
    .wgp-qs-root.is-fullscreen .wgp-qs-backdrop { display: none; }
    .wgp-qs-root.is-fullscreen .wgp-qs {
        position: static; flex: 1 1 auto; width: auto; max-height: none;
        border: 0; border-radius: 0; box-shadow: none; animation: none;
    }
    .wgp-qs-root.is-fullscreen .wgp-qs-chips {
        flex-wrap: nowrap; max-height: none; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    }
    .wgp-qs-root.is-fullscreen .wgp-qs-chips::-webkit-scrollbar { display: none; }
    .wgp-qs-root.is-fullscreen .wgp-qs-row { align-items: flex-start; }
    .wgp-qs-root.is-fullscreen .wgp-qs-side { gap: 6px; }
    .wgp-qs-root.is-fullscreen .wgp-qs-footer {
        position: sticky; bottom: var(--wgp-qs-keyboard, 0px);
        flex: 0 0 auto; height: auto; padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--wgp-qs-border); background: #fff;
    }
    .wgp-qs-root.is-fullscreen .wgp-qs-footer-text {
        display: flex; align-items: center; justify-content: center; width: 100%; height: 44px;
        border-radius: 6px; background: var(--wgp-qs-accent); color: #fff;
    }
    .wgp-qs-root.is-fullscreen .wgp-qs-footer.is-active .wgp-qs-footer-text { background: var(--wgp-qs-accent-hover); }
    .wgp-qs-root.is-fullscreen .wgp-qs-kbd { display: none; }
    .wgp-qs-root.is-fullscreen .wgp-qs-scroll { padding-bottom: 16px; }
}

/* ── /search/ page (D) ───────────────────────────────────────────── */
.wgp-sr-summary { margin: -8px 0 16px; font-size: 14px; line-height: 20px; color: #6c757d; }
.wgp-sr-chips {
    display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; padding: 0; list-style: none;
}
.wgp-sr-chips .wgp-qs-chip { height: 32px; }
.wgp-sr-chips .wgp-qs-chip.is-current { border-color: #0d6efd; background: #0d6efd; color: #fff; }
.wgp-sr-chips .wgp-qs-chip.is-current .wgp-qs-chip-count { color: rgba(255, 255, 255, .8); }
.wgp-sr-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin: 0 0 16px; }
.wgp-sr-toolbar label { margin: 0; font-size: 14px; color: #6c757d; white-space: nowrap; }
.wgp-sr-toolbar .form-select { width: auto; min-width: 200px; }
.wgp-sr-empty { max-width: 720px; padding: 8px 0 32px; }
.wgp-sr-empty h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }
.wgp-sr-empty p { margin: 0 0 12px; color: #6c757d; }
.wgp-sr-empty .wgp-qs-chips { max-height: none; padding: 0; margin: 0 0 16px; }
.wgp-sr-notice { margin: 0 0 16px; padding: 12px 16px; border-radius: 6px; background: #f8f9fa; color: #6c757d; font-size: 14px; }
@media (max-width: 767.98px) {
    .wgp-sr-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -12px; padding-right: 12px; }
    .wgp-sr-chips::-webkit-scrollbar { display: none; }
    .wgp-sr-toolbar { justify-content: space-between; }
    .wgp-sr-toolbar label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .wgp-sr-toolbar .form-select { min-width: 0; flex: 1 1 auto; }
}
