/**
 * Frontend CSS for WooCommerce Advanced Search by Soul Country.
 *
 * Live-search dropdown styles. The markup is generated by frontend.js
 * and looks like:
 *   .woo-search-sc-panel              (single, body-attached, fixed)
 *     > .woo-search-sc-list
 *       > li.woo-search-sc-item
 *         > a.woo-search-sc-suggestion           (links to product)
 *             > .woo-search-sc-thumb > img
 *             > .woo-search-sc-meta
 *                 > .woo-search-sc-title
 *                 > .woo-search-sc-excerpt
 *                 > .woo-search-sc-detail
 *                     > .woo-search-sc-price
 *                     > .woo-search-sc-badge--sale (optional)
 *         > .woo-search-sc-tag-row              (sibling, sits below)
 *             > a.woo-search-sc-tag             (links to product_tag)
 *                 > img.woo-search-sc-tag-img
 *                 > .woo-search-sc-tag-label
 *     > .woo-search-sc-view-all (always last)
 *
 * The panel is always attached to <body> and positioned via inline
 * `position: fixed; top/left/width` styles set by the JS, so it is not
 * affected by host-form layout, overflow, transforms or z-index.
 *
 * @package WooSearch_SC
 */

/* ----- Panel ------------------------------------------------------------ */

/*
 * The panel reads the host theme's CSS custom properties so it blends in
 * with the rest of the site. Each var() falls back to a sensible literal
 * so it still looks intentional on themes that don't expose those tokens.
 */
.woo-search-sc-panel {
    /* position / top / left / width / z-index are set inline by JS. */
    box-sizing: border-box;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--color-background, #f5f4eb);
    color: var(--color-text, #1f1f1f);
    border: 1px solid var(--color-border, #e6e6e6);
    border-radius: 4px;
    box-shadow:
        0 18px 40px rgba(15, 15, 15, 0.10),
        0 2px 6px  rgba(15, 15, 15, 0.05);
    padding: 14px;
    -webkit-overflow-scrolling: touch;
    animation: wooSearchSCFade 120ms ease-out;
    font-family: inherit;
}

@keyframes wooSearchSCFade {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ----- Result list ------------------------------------------------------- */

.woo-search-sc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.woo-search-sc-list li,
.woo-search-sc-item {
    margin: 0;
    padding: 0;
    border: 0;
}

.woo-search-sc-item {
    transition: background-color 120ms ease;
    padding: 12px 12px;
    border-radius: 4px;
}

/* Highlight whole row when the user hovers it, focuses any link inside, or
   keyboard-navigates to the suggestion. The tint is a low-opacity wash of
   the theme's primary accent so it always reads as "selected". */
.woo-search-sc-item:hover,
.woo-search-sc-item:focus-within {
    background-color: rgba(153, 195, 185, 0.18);
}
.woo-search-sc-item:has(.woo-search-sc-suggestion.is-active) {
    background-color: rgba(153, 195, 185, 0.22);
}
/* Fallback for browsers without :has(): the inner suggestion still gets
   tinted on keyboard activation. */
.woo-search-sc-suggestion.is-active {
    background-color: rgba(153, 195, 185, 0.22);
    border-radius: 4px;
}

.woo-search-sc-suggestion {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    color: inherit;
    text-decoration: none;
}

.woo-search-sc-suggestion:hover,
.woo-search-sc-suggestion:focus {
    color: inherit;
    text-decoration: none;
    outline: none;
}

.woo-search-sc-thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: 2px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.woo-search-sc-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0;
}

.woo-search-sc-thumb--empty {
    background:
        linear-gradient(135deg, rgba(0,0,0,0.04) 0%, rgba(0,0,0,0.08) 100%);
}

.woo-search-sc-meta {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.woo-search-sc-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-title, #1f1f1f);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.woo-search-sc-title mark,
.woo-search-sc-excerpt mark {
    background: rgba(255, 220, 100, 0.55);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

/* Two-line clamped short description. */
.woo-search-sc-excerpt {
    font-size: 13px;
    line-height: 1.45;
    color: var(--color-text-muted, #555);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Bottom detail row inside the suggestion link: price + sale badge. */
.woo-search-sc-detail {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.woo-search-sc-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text, #1f1f1f);
    line-height: 1.2;
}

.woo-search-sc-price .amount { color: inherit; }
.woo-search-sc-price del { color: var(--color-text-muted, #999); font-weight: 400; margin-right: 4px; }
.woo-search-sc-price ins { text-decoration: none; color: inherit; }

.woo-search-sc-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.woo-search-sc-badge--sale {
    background: var(--color-accent-tertiary, #c0392b);
    color: #fff;
}

/* ----- Tag row (linked product_tag icons) ------------------------------- */

/*
 * The tag row sits underneath the suggestion link. We indent it to align
 * with the title column (thumb width 64 + suggestion gap 14 = 78px) and
 * render each tag as a bare image — no pill, no visible label. The tag
 * name is still announced via the image's alt and the link's aria-label
 * / title, so screen readers and hover tooltips keep working.
 */
.woo-search-sc-tag-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding-left: 78px;
}

.woo-search-sc-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    text-decoration: none;
    border: 0;
    background: transparent;
    padding: 0;
    transition: transform 120ms ease, opacity 120ms ease;
}

.woo-search-sc-tag:hover,
.woo-search-sc-tag:focus {
    text-decoration: none;
    outline: none;
    transform: scale(1.08);
}

.woo-search-sc-tag:focus-visible {
    outline: 2px solid var(--color-accent-primary, #99c3b9);
    outline-offset: 3px;
    border-radius: 999px;
}

.woo-search-sc-tag--static {
    cursor: default;
}

.woo-search-sc-tag-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    display: block;
    flex: 0 0 auto;
}

/* ----- View all / loading / empty states -------------------------------- */

/*
 * The view-all link is separated from the result list by a thin rule so it
 * reads as a footer action, then styled like a quiet text-button that uses
 * the theme's hover accent on interaction.
 */
.woo-search-sc-view-all {
    display: block;
    margin: 12px -2px 0 -2px;
    padding: 12px 14px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    border-top: 1px solid var(--color-border, #e6e3d2);
    color: var(--color-text, #1f1f1f);
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    transition: background-color 120ms ease, color 120ms ease;
}

.woo-search-sc-view-all:hover,
.woo-search-sc-view-all:focus {
    background-color: rgba(153, 195, 185, 0.18);
    color: var(--color-text, #1f1f1f);
    text-decoration: none;
}

.woo-search-sc-loading,
.woo-search-sc-empty {
    padding: 18px 20px;
    text-align: center;
    color: var(--color-text-muted, #777);
    font-size: 13px;
}

.woo-search-sc-loading::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 8px;
    border: 2px solid #ccc;
    border-top-color: #555;
    border-radius: 50%;
    vertical-align: -2px;
    animation: wooSearchSCSpin 700ms linear infinite;
}

@keyframes wooSearchSCSpin {
    to { transform: rotate(360deg); }
}

/* ----- "Did you mean?" list (rendered by PHP on no-results pages) ------- */

.woocommerce-no-products-found .woo-search-sc-suggestions,
body .woocommerce .woo-search-sc-suggestions {
    margin: 20px 0;
    padding: 18px 20px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #0073aa;
}

.woocommerce-no-products-found .woo-search-sc-suggestions h3 {
    margin: 0 0 12px 0;
    font-size: 1.05em;
}

.woocommerce-no-products-found .woo-search-sc-suggestions ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.woocommerce-no-products-found .woo-search-sc-suggestions li {
    margin: 0 0 6px 0;
}

.woocommerce-no-products-found .woo-search-sc-suggestions a {
    color: #0073aa;
    text-decoration: none;
}

.woocommerce-no-products-found .woo-search-sc-suggestions a:hover {
    text-decoration: underline;
}

/* ----- Mobile ----------------------------------------------------------- */

@media (max-width: 600px) {
    .woo-search-sc-panel {
        max-height: 65vh;
        padding: 10px;
        border-radius: 4px;
    }

    .woo-search-sc-item {
        padding: 10px 10px;
    }

    .woo-search-sc-suggestion {
        gap: 10px;
    }

    .woo-search-sc-thumb {
        width: 56px;
        height: 56px;
    }

    .woo-search-sc-title { font-size: 14px; }
    .woo-search-sc-excerpt {
        font-size: 12px;
        -webkit-line-clamp: 2;
    }
    .woo-search-sc-price { font-size: 12px; }

    /* Align tag row with the (smaller) title column on mobile. */
    .woo-search-sc-tag-row {
        padding-left: 66px; /* 56px thumb + 10px gap */
        margin-top: 8px;
        gap: 8px;
    }

    .woo-search-sc-tag-img {
        width: 24px;
        height: 24px;
    }

    .woo-search-sc-view-all {
        margin: 10px -2px 0 -2px;
        padding: 11px 12px;
    }
}

/* ----- Dark mode -------------------------------------------------------- */

/*
 * Dark mode is gated to themes that DO NOT expose --color-background, so
 * we don't accidentally invert the palette of a light theme like Cake
 * Club's that already supplies its own tokens.
 */
@media (prefers-color-scheme: dark) {
    .woo-search-sc-panel {
        background: var(--color-background, #20232a);
        color: var(--color-text, #f0f0f1);
        border-color: var(--color-border, #3a3f48);
        box-shadow:
            0 18px 40px rgba(0, 0, 0, 0.45),
            0 2px 6px  rgba(0, 0, 0, 0.30);
    }

    .woo-search-sc-item:hover,
    .woo-search-sc-item:focus-within,
    .woo-search-sc-suggestion.is-active {
        background-color: rgba(255, 255, 255, 0.06);
    }
    .woo-search-sc-item:has(.woo-search-sc-suggestion.is-active) {
        background-color: rgba(255, 255, 255, 0.08);
    }

    .woo-search-sc-thumb { background: rgba(255, 255, 255, 0.06); }
    .woo-search-sc-thumb--empty {
        background:
            linear-gradient(135deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.10) 100%);
    }

    .woo-search-sc-title { color: var(--color-title, #fff); }
    .woo-search-sc-excerpt { color: var(--color-text-muted, #b6b9be); }
    .woo-search-sc-price { color: var(--color-text, #f0f0f1); }
    .woo-search-sc-price del { color: var(--color-text-muted, #888); }

    .woo-search-sc-view-all {
        color: var(--color-text, #f0f0f1);
        border-top-color: var(--color-border, #3a3f48);
    }

    .woo-search-sc-view-all:hover,
    .woo-search-sc-view-all:focus {
        background-color: rgba(255, 255, 255, 0.06);
        color: var(--color-text, #fff);
    }

    .woo-search-sc-loading,
    .woo-search-sc-empty { color: var(--color-text-muted, #a7aaad); }

    .woo-search-sc-title mark,
    .woo-search-sc-excerpt mark {
        background: rgba(255, 220, 100, 0.25);
        color: inherit;
    }
}
