/**
 * Petka Better Search
 *
 * Every colour and size is a --pbs-* custom property. The admin writes them into an inline
 * style block; the values below are only the fallbacks for when that block is missing.
 */

.pbs-dropdown,
.pbs-form {
    --pbs-text: #2b2b2b;
    --pbs-muted: #767676;
    --pbs-bg: #ffffff;
    --pbs-border: #e4e4e4;
    --pbs-hover: #f4f4f4;
    --pbs-highlight: #000000;
    --pbs-accent: #333333;
    --pbs-accent-hover: #1f1f1f;
    --pbs-accent-text: #ffffff;
    --pbs-price: #2b2b2b;
    --pbs-old-price: #9b9b9b;
    --pbs-in-stock: #4a7a57;
    --pbs-out-of-stock: #a64b4b;
    --pbs-input-bg: #ffffff;
    --pbs-input-text: #2b2b2b;
    --pbs-input-border: #cfcfcf;
    --pbs-input-focus: #333333;
    --pbs-image-size: 56px;
    --pbs-radius: 8px;
    --pbs-input-radius: 6px;
    --pbs-z-index: 1000;
}

/* ---------------------------------------------------------------- search field */

.pbs-form.pbs-styled .pbs-input {
    background-color: var(--pbs-input-bg);
    color: var(--pbs-input-text);
    border: 1px solid var(--pbs-input-border);
    border-radius: var(--pbs-input-radius);
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.pbs-form.pbs-styled .pbs-input::placeholder {
    color: var(--pbs-muted);
    opacity: 1;
}

.pbs-form.pbs-styled .pbs-input:focus {
    border-color: var(--pbs-input-focus);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .06);
    outline: none;
}

/* The stock dropdown container stays empty while Better Search runs. */
.pbs-form .search-autocomplete {
    display: none !important;
}

/* ---------------------------------------------------------------- dropdown shell */

.pbs-dropdown {
    position: fixed;
    z-index: var(--pbs-z-index);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    max-width: 100vw;
    overflow: hidden;
    background: var(--pbs-bg);
    color: var(--pbs-text);
    border: 1px solid var(--pbs-border);
    border-radius: var(--pbs-radius);
    box-shadow: 0 16px 40px rgba(0, 0, 0, .10), 0 2px 8px rgba(0, 0, 0, .05);
    font-family: var(--pbs-font-family, inherit);
    font-size: 14px;
    line-height: 1.4;
    text-align: left;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .14s ease, transform .14s ease;
}

.pbs-dropdown[hidden] {
    display: none;
}

.pbs-dropdown.is-open {
    opacity: 1;
    transform: none;
}

.pbs-dropdown.is-mobile {
    border-width: 1px 0;
    border-radius: 0;
}

.pbs-dropdown *,
.pbs-dropdown *::before,
.pbs-dropdown *::after {
    box-sizing: border-box;
}

.pbs-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 6px 0;
}

.pbs-dropdown ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.pbs-dropdown li {
    margin: 0;
}

/* Loading: a thin moving line along the top edge. */
.pbs-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    overflow: hidden;
    pointer-events: none;
}

.pbs-dropdown.is-loading .pbs-bar::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 35%;
    background: var(--pbs-accent);
    animation: pbs-bar 1s ease-in-out infinite;
}

@keyframes pbs-bar {
    from { left: -35%; }
    to { left: 100%; }
}

.pbs-heading {
    padding: 10px 16px 6px;
    color: var(--pbs-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.pbs-section + .pbs-section {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--pbs-border);
}

.pbs-option {
    cursor: pointer;
    transition: background-color .12s ease;
}

.pbs-option:hover,
.pbs-option.is-active {
    background: var(--pbs-hover);
}

.pbs-match {
    padding: 0;
    background: none;
    color: var(--pbs-highlight);
    font-weight: 600;
}

/* ---------------------------------------------------------------- suggestions */

.pbs-term {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 16px;
    color: var(--pbs-text);
}

.pbs-term::before {
    content: '';
    flex: none;
    width: 14px;
    height: 14px;
    background: var(--pbs-muted);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.pbs-term-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------------------------------------------------------------- products: list */

.pbs-product {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 16px;
    color: var(--pbs-text);
    text-decoration: none;
}

.pbs-product:hover,
.pbs-product:focus,
.pbs-product:visited {
    color: var(--pbs-text);
    text-decoration: none;
}

.pbs-media {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--pbs-image-size);
    height: var(--pbs-image-size);
    overflow: hidden;
    border-radius: calc(var(--pbs-radius) * .75);
    background: var(--pbs-bg);
}

.pbs-media img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.pbs-media.is-broken {
    background: var(--pbs-hover);
}

.pbs-media.is-broken img {
    visibility: hidden;
}

.pbs-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pbs-name {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-weight: 500;
}

.pbs-description {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    color: var(--pbs-muted);
    font-size: 12.5px;
}

.pbs-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    margin-top: 2px;
}

.pbs-price-prefix {
    color: var(--pbs-muted);
    font-size: 12px;
}

.pbs-price {
    color: var(--pbs-price);
    font-weight: 600;
    white-space: nowrap;
}

.pbs-old-price {
    color: var(--pbs-old-price);
    font-size: 12.5px;
    white-space: nowrap;
}

.pbs-stock {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
}

.pbs-stock::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.pbs-stock.is-in {
    color: var(--pbs-in-stock);
}

.pbs-stock.is-out {
    color: var(--pbs-out-of-stock);
}

/* ---------------------------------------------------------------- products: grid */

.pbs--grid .pbs-section--products .pbs-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 4px;
    padding: 0 8px 4px;
}

.pbs--grid .pbs-product {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    height: 100%;
    padding: 10px;
    border-radius: calc(var(--pbs-radius) * .75);
}

.pbs--grid .pbs-media {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
}

.pbs--grid .pbs-description {
    display: none;
}

.pbs-dropdown.is-mobile.pbs--grid .pbs-section--products .pbs-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ---------------------------------------------------------------- empty & loading */

.pbs-empty {
    padding: 22px 16px;
    color: var(--pbs-muted);
    text-align: center;
}

.pbs-skeleton-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 16px;
}

.pbs-skeleton-row::before,
.pbs-skeleton-row::after {
    content: '';
    border-radius: 4px;
    background: linear-gradient(90deg, var(--pbs-hover) 0%, var(--pbs-border) 50%, var(--pbs-hover) 100%);
    background-size: 200% 100%;
    animation: pbs-shimmer 1.2s linear infinite;
}

.pbs-skeleton-row::before {
    flex: none;
    width: var(--pbs-image-size);
    height: var(--pbs-image-size);
    border-radius: calc(var(--pbs-radius) * .75);
}

.pbs-skeleton-row::after {
    flex: 1 1 auto;
    max-width: 60%;
    height: 12px;
}

@keyframes pbs-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* ---------------------------------------------------------------- show all */

.pbs-footer {
    flex: none;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--pbs-border);
    background: var(--pbs-bg);
}

.pbs-footer[hidden] {
    display: none;
}

.pbs-dropdown .pbs-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin: 0;
    padding: 11px 16px;
    border: 0;
    border-radius: calc(var(--pbs-radius) * .75);
    background: var(--pbs-accent);
    box-shadow: none;
    color: var(--pbs-accent-text);
    font: inherit;
    font-weight: 500;
    line-height: 1.3;
    text-shadow: none;
}

.pbs-dropdown .pbs-all:hover,
.pbs-dropdown .pbs-all.is-active {
    background: var(--pbs-accent-hover);
    color: var(--pbs-accent-text);
}

.pbs-dropdown .pbs-all:focus-visible {
    outline: 2px solid var(--pbs-accent);
    outline-offset: 2px;
}

.pbs-all-count {
    opacity: .7;
    font-weight: 400;
}

.pbs-all-count::before {
    content: '(';
}

.pbs-all-count::after {
    content: ')';
}

.pbs-all-label::after {
    content: ' \2192';
}

@media (prefers-reduced-motion: reduce) {
    .pbs-dropdown,
    .pbs-option,
    .pbs-form.pbs-styled .pbs-input {
        transition: none;
    }

    .pbs-dropdown.is-loading .pbs-bar::before,
    .pbs-skeleton-row::before,
    .pbs-skeleton-row::after {
        animation: none;
    }
}
