/* Woo Product Search & Filter */
.wapsf-product-filters {
    margin: 1.5em 0;
    padding: 1.25em 1.5em;
    background: #f7f7f9;
    border-radius: 10px;
    border: 1px solid #e0e0e5;
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    align-items: flex-end;
    font-size: 14px;
}

.wapsf-product-filters .wapsf-field {
    display: flex;
    flex-direction: column;
    min-width: 160px;
}

.wapsf-product-filters .wapsf-field label {
    font-weight: 600;
    margin-bottom: 0.25em;
    color: #333;
}

.wapsf-product-filters input[type="text"],
.wapsf-product-filters input[type="number"],
.wapsf-product-filters select {
    padding: 0.45em 0.55em;
    border-radius: 4px;
    border: 1px solid #ccc;
    min-height: 36px;
    background: #fff;
}

.wapsf-price-row {
    display: flex;
    gap: 0.4em;
}

.wapsf-product-filters .wapsf-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin-left: auto;
}

.wapsf-product-filters .button-primary,
.wapsf-product-filters .button-secondary {
    border-radius: 4px;
    padding: 0.55em 0.95em;
    cursor: pointer;
    font-weight: 600;
    border: none;
    line-height: 1.4;
}

.wapsf-product-filters .button-primary {
    background: #2271b1;
    color: #fff;
}

.wapsf-product-filters .button-primary:hover {
    background: #1b5a8c;
}

.wapsf-product-filters .button-secondary {
    background: #e4e4e7;
    color: #333;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wapsf-product-filters .wapsf-checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.4em;
    margin-top: 0.3em;
}

.wapsf-product-filters .wapsf-checkbox-row label {
    font-weight: 400;
    margin-bottom: 0;
}

.wapsf-category-tree {
    min-width: 240px;
    flex: 1 1 300px;
}

.wapsf-category-levels {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6em;
    align-items: flex-end;
}

.wapsf-category-level {
    display: flex;
    flex-direction: column;
    min-width: 190px;
    flex: 1 1 190px;
}

.wapsf-category-level select {
    width: 100%;
}

@media (max-width: 768px) {
    .wapsf-product-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .wapsf-price-row,
    .wapsf-category-levels {
        flex-direction: column;
        align-items: stretch;
    }

    .wapsf-product-filters .wapsf-actions {
        margin-left: 0;
    }

    .wapsf-category-level {
        width: 100%;
    }
}

/* Header-only search shortcode and AJAX suggestions */
.wapsf-header-search-wrap {
    --wapsf-search-accent: #2271b1;
    --wapsf-search-accent-hover: #185a91;
    --wapsf-search-border: #d7dce3;
    --wapsf-search-text: #172033;
    --wapsf-search-muted: #687386;
    position: relative;
    width: 100%;
    max-width: 520px;
    z-index: 99999;
    font-size: 14px;
}

.wapsf-header-search {
    width: 100%;
    margin: 0;
}

.wapsf-header-search-field {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
    min-height: 46px;
    overflow: hidden;
    border: 1px solid var(--wapsf-search-border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 3px 14px rgba(23, 32, 51, 0.08);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.wapsf-header-search-field:focus-within {
    border-color: var(--wapsf-search-accent);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.14), 0 6px 22px rgba(23, 32, 51, 0.12);
}

.wapsf-header-search-leading-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    width: 19px;
    height: 19px;
    transform: translateY(-50%);
    color: #7c8798;
    pointer-events: none;
    z-index: 2;
}

.wapsf-header-search-leading-icon svg,
.wapsf-header-search-submit svg,
.wapsf-search-clear svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.wapsf-header-search input[type="search"] {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 44px;
    margin: 0;
    padding: 10px 48px 10px 44px;
    border: 0 !important;
    border-radius: 0;
    outline: 0;
    background: transparent;
    color: var(--wapsf-search-text);
    box-shadow: none !important;
    font: inherit;
    font-size: 15px;
    line-height: 1.4;
    appearance: none;
    -webkit-appearance: none;
}

.wapsf-header-search input[type="search"]::-webkit-search-cancel-button {
    display: none;
}

.wapsf-header-search input[type="search"]::placeholder {
    color: #8993a2;
    opacity: 1;
}

.wapsf-search-clear {
    position: absolute;
    right: 116px;
    top: 50%;
    width: 30px;
    height: 30px;
    padding: 7px;
    transform: translateY(-50%);
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #7b8594;
    cursor: pointer;
    z-index: 3;
}

.wapsf-header-search-no-button .wapsf-search-clear {
    right: 8px;
}

.wapsf-search-clear:hover,
.wapsf-search-clear:focus-visible {
    background: #eef1f5;
    color: var(--wapsf-search-text);
    outline: 0;
}

.wapsf-header-search-submit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 106px;
    margin: 4px;
    padding: 8px 16px;
    border: 0;
    border-radius: 9px;
    background: var(--wapsf-search-accent);
    color: #fff;
    font: inherit;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.18s ease, transform 0.18s ease;
}

.wapsf-header-search-submit svg {
    width: 17px;
    height: 17px;
}

.wapsf-header-search-submit:hover,
.wapsf-header-search-submit:focus-visible {
    background: var(--wapsf-search-accent-hover);
    color: #fff;
    outline: 0;
}

.wapsf-header-search-submit:active {
    transform: scale(0.98);
}

.wapsf-live-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: min(520px, 70vh);
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid #e2e6ec;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 18px 46px rgba(18, 28, 45, 0.20);
    z-index: 1000000;
    overscroll-behavior: contain;
}

.wapsf-live-results[hidden] {
    display: none !important;
}

.wapsf-live-result-item {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-height: 78px;
    padding: 10px 13px;
    border-bottom: 1px solid #edf0f4;
    color: var(--wapsf-search-text);
    text-decoration: none !important;
    transition: background 0.15s ease;
}

.wapsf-live-result-item.wapsf-live-result-no-image {
    grid-template-columns: minmax(0, 1fr) auto;
}

.wapsf-live-result-item.wapsf-live-result-no-image.wapsf-live-result-no-price {
    grid-template-columns: minmax(0, 1fr);
}

.wapsf-live-result-item:hover,
.wapsf-live-result-item:focus,
.wapsf-live-result-item.is-active {
    background: #f5f8fc;
    color: var(--wapsf-search-text);
    outline: 0;
}

.wapsf-live-result-image {
    width: 58px;
    height: 58px;
    overflow: hidden;
    border: 1px solid #edf0f4;
    border-radius: 9px;
    background: #f7f8fa;
}

.wapsf-live-result-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.wapsf-live-result-content {
    min-width: 0;
}

.wapsf-live-result-title-row {
    display: flex;
    align-items: flex-start;
    gap: 7px;
}

.wapsf-live-result-title {
    overflow: hidden;
    color: var(--wapsf-search-text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wapsf-live-sale-badge {
    flex: 0 0 auto;
    padding: 2px 6px;
    border-radius: 999px;
    background: #fff0e8;
    color: #b94408;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.wapsf-live-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 9px;
    margin-top: 5px;
    color: var(--wapsf-search-muted);
    font-size: 12px;
    line-height: 1.35;
}

.wapsf-live-result-meta span + span::before {
    content: "•";
    margin-right: 9px;
    color: #bac1cb;
}

.wapsf-live-result-price {
    padding-left: 8px;
    color: var(--wapsf-search-text);
    font-size: 14px;
    font-weight: 800;
    text-align: right;
    white-space: nowrap;
}

.wapsf-live-result-price del {
    display: block;
    color: #9aa3af;
    font-size: 11px;
    font-weight: 500;
}

.wapsf-live-result-price ins {
    color: #c13a10;
    text-decoration: none;
}

.wapsf-live-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 82px;
    padding: 18px;
    color: var(--wapsf-search-muted);
    text-align: center;
}

.wapsf-live-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #dce2e9;
    border-top-color: var(--wapsf-search-accent);
    border-radius: 50%;
    animation: wapsf-spin 0.75s linear infinite;
}

@keyframes wapsf-spin {
    to { transform: rotate(360deg); }
}

.wapsf-live-view-all {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 15px;
    background: #f8fafc;
    color: var(--wapsf-search-accent);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none !important;
}

.wapsf-live-view-all:hover,
.wapsf-live-view-all:focus-visible {
    background: #eef4fa;
    color: var(--wapsf-search-accent-hover);
    outline: 0;
}

.wapsf-live-view-all::after {
    content: "→";
    font-size: 18px;
    line-height: 1;
}

@media (max-width: 767px) {
    .wapsf-header-search-wrap {
        max-width: 100%;
    }

    .wapsf-header-search-field {
        min-height: 44px;
        border-radius: 10px;
    }

    .wapsf-header-search-submit {
        min-width: 44px;
        width: 44px;
        padding: 8px;
    }

    .wapsf-header-search-submit span {
        display: none;
    }

    .wapsf-search-clear {
        right: 53px;
    }

    .wapsf-live-results {
        max-height: min(460px, 68vh);
        border-radius: 12px;
    }

    .wapsf-live-result-item {
        grid-template-columns: 50px minmax(0, 1fr);
        min-height: 70px;
        padding: 9px 11px;
    }

    .wapsf-live-result-item.wapsf-live-result-no-image {
        grid-template-columns: minmax(0, 1fr);
    }

    .wapsf-live-result-item.wapsf-live-result-no-image .wapsf-live-result-price {
        grid-column: 1;
    }

    .wapsf-live-result-image {
        width: 50px;
        height: 50px;
    }

    .wapsf-live-result-price {
        grid-column: 2;
        padding-left: 0;
        text-align: left;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wapsf-header-search-field,
    .wapsf-header-search-submit,
    .wapsf-live-result-item {
        transition: none;
    }
}
