/*
 * 12taste Vertex AI Search Widget
 * Styled to match FiboSearch (dgwt-wcas) exactly.
 * Brand color: #e6007e
 *
 * v1.19.6: Mobile font-size fix, product card typography improvements
 *   - Mobile: font-size >= 16px on inputs to prevent iOS auto-zoom
 *   - Product cards: line-height 110% → 140% for readability
 *   - Brand text: darkened (#888 → #666), bumped to 12px, font-weight 500
 *   - Description text: darkened (#777 → #555), bumped to 12px
 *
 * v1.19.30: Apr-20 UAT re-test fixes
 *   - Input font-size: base rule now 16px (eliminates iOS auto-zoom without
 *     relying on media query; the mobile override kept as defence-in-depth).
 *   - .vtx-result-item line-height changed from 140% (unit) to 1.4 (unitless).
 *     The % unit froze computed line-height at 16.8px on the parent and
 *     inherited as a fixed value, so .vtx-result-title (13px) rendered at
 *     ratio 1.29 instead of 1.4. Unitless re-calculates per element.
 *   - Added explicit line-height: 1.4 on .vtx-result-title as a guard rail.
 */

/* ─── Wrapper ──────────────────────────────────────────────────────────── */
.vtx-search-wrapper {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    color: #444;
    box-sizing: border-box;
    font-family: inherit;
    z-index: 99999; /* stay above overlay */
}

/* ─── Input row ────────────────────────────────────────────────────────── */
.vtx-input-row {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

/* Text input – matches dgwt-wcas-search-input */
/* v1.19.30: font-size raised to 16px at base to prevent iOS Safari
   auto-zoom on focus (iOS auto-zooms any input < 16px). The mobile
   @media override further below is retained as defence-in-depth but
   is now redundant in normal conditions. */
.vtx-search-input {
    width: 100%;
    height: 40px;
    font-size: 16px;
    line-height: 100%;
    padding: 10px 55px 10px 15px; /* right padding leaves room for button */
    margin: 0;
    background: #fff;
    border: 1px solid #e6007e;
    border-radius: 3px;
    -webkit-border-radius: 3px;
    -webkit-appearance: none;
    box-sizing: border-box;
    outline: none;
    color: #333;
    box-shadow: none;
    -webkit-transition: 150ms ease-in;
    transition: 150ms ease-in;
}

.vtx-search-input:focus {
    outline: 0;
    background: #fff;
    box-shadow: 0 0 9px 1px rgba(0, 0, 0, 0.06);
    border-color: #e6007e;
}

/* Hide Chrome's native × clear button on type="search" (avoids double cross) */
.vtx-search-input::-webkit-search-decoration,
.vtx-search-input::-webkit-search-cancel-button,
.vtx-search-input::-webkit-search-results-button,
.vtx-search-input::-webkit-search-results-decoration {
    -webkit-appearance: none;
    display: none;
}

/* Italic placeholder – matches FiboSearch exactly */
.vtx-search-input::placeholder {
    color: #999;
    font-weight: 400;
    font-style: italic;
    line-height: normal;
}

.vtx-search-input::-webkit-input-placeholder {
    color: #999;
    font-weight: 400;
    font-style: italic;
}

.vtx-search-input:-moz-placeholder {
    color: #999;
    font-weight: 400;
    font-style: italic;
}

/* × Clear button – sits inside input on the right, left of search button */
.vtx-clear-btn {
    display: none; /* shown via JS when input has text */
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 50px;
    top: 0;
    height: 40px;
    width: 22px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #bbb;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    z-index: 2;
    transition: color 0.15s;
}

.vtx-clear-btn:hover {
    color: #666;
}

/* Search (submit) button – matches dgwt-wcas-search-submit */
.vtx-search-btn {
    position: absolute;
    right: 0;
    top: 0;
    height: 40px;
    min-width: 50px;
    width: auto;
    padding: 0 15px;
    margin: 0;
    background-color: #e6007e;
    color: #fff;
    border: 0;
    border-radius: 0 2px 2px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-transition: 250ms ease-in-out;
    transition: 250ms ease-in-out;
    box-sizing: border-box;
}

.vtx-search-btn:hover {
    background-color: #c8006e;
}

.vtx-search-btn svg {
    width: auto;
    height: 65%;
    fill: #fff;
    display: block;
}

/* ─── Dropdown ─────────────────────────────────────────────────────────── */
.vtx-dropdown {
    display: none; /* shown via JS */
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    overflow-y: auto;
    max-height: 520px;
    z-index: 99999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ─── Result items – matches dgwt-wcas-suggestion ──────────────────────── */
/* v1.19.30: line-height changed from 140% (absolute, freezes at
   12px × 1.4 = 16.8px) to 1.4 (unitless, inherits as a multiplier).
   This lets .vtx-result-title at 13px compute 13 × 1.4 = 18.2px
   instead of a stuck 16.8px (ratio was 1.29 — readability regression
   flagged in Apr-20 UAT). */
.vtx-result-item {
    cursor: pointer;
    font-size: 12px;
    line-height: 1.4;
    text-align: left;
    padding: 10px 12px;
    position: relative;
    border-bottom: 1px solid #dfdfdf;
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    text-decoration: none;
    color: #333;
    transition: background 0.1s;
    gap: 10px;
}

.vtx-result-item:last-child {
    border-bottom: none;
}

.vtx-result-item:hover,
.vtx-result-item.vtx-active {
    background: #f9f9f9;
}

/* Thumbnail */
.vtx-result-img {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
}

.vtx-result-thumb {
    display: block;
    width: 50px;
    height: 50px;
    object-fit: cover;
    border: 1px solid #eee;
    border-radius: 2px;
}

.vtx-no-image {
    background: #f5f5f5;
    border: 1px solid #eee;
    border-radius: 2px;
    display: block;
    width: 50px;
    height: 50px;
}

/* Text body */
.vtx-result-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vtx-result-title {
    font-size: 13px;
    font-weight: 600;
    color: #222;
    /* v1.19.30: explicit unitless line-height as guard rail so a future
       edit on .vtx-result-item (e.g. re-introducing a % unit) cannot
       quietly reintroduce the Apr-20 regression. */
    line-height: 1.4;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Highlighted match – brand pink */
mark.vtx-hl {
    background: transparent;
    color: #e6007e;
    font-weight: 700;
    padding: 0;
}

.vtx-result-brand {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vtx-result-desc {
    font-size: 12px;
    color: #555;
    display: block;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ─── States ───────────────────────────────────────────────────────────── */
.vtx-no-results,
.vtx-error {
    font-size: 15px;
    line-height: 157%;
    padding: 15px;
    width: 100%;
    color: #666;
    box-sizing: border-box;
}

.vtx-no-results a {
    color: #e6007e;
    text-decoration: underline;
}

.vtx-no-results a:hover {
    color: #c8006e;
}

.vtx-correction-banner {
    font-size: 13px;
    padding: 8px 15px;
    color: #555;
    background: #fef9e7;
    border-bottom: 1px solid #f0e4b8;
}

.vtx-correction-banner strong {
    color: #333;
    font-style: italic;
}

/* v1.19.31: "Did you mean X?" rescue link, shown above "No products found"
   when autocomplete has suggestions but product search returned nothing
   (typically queries below Retail's spell-correction threshold). */
.vtx-did-you-mean {
    font-size: 14px;
    line-height: 1.4;
    padding: 10px 15px 6px;
    color: #555;
    background: #f9f9f9;
    border-bottom: 1px solid #eee;
}

.vtx-did-you-mean a.vtx-dym-link {
    color: #e6007e;
    text-decoration: none;
}

.vtx-did-you-mean a.vtx-dym-link:hover,
.vtx-did-you-mean a.vtx-dym-link:focus {
    text-decoration: underline;
}

.vtx-error {
    color: #c0392b;
}

/* Loading dots */
.vtx-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 14px;
}

.vtx-loading span {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #e6007e;
    animation: vtx-bounce 0.8s infinite ease-in-out both;
}

.vtx-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.vtx-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes vtx-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.3;
    }
    40% {
        transform: scale(1.0);
        opacity: 1;
    }
}

/* ─── Search History ──────────────────────────────────────────────────── */
.vtx-history-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #dfdfdf;
    font-size: 12px;
    font-weight: 600;
    color: #444;
}

.vtx-clear-history-btn {
    background: none;
    border: none;
    color: #e6007e;
    cursor: pointer;
    font-size: 11px;
    text-decoration: underline;
    padding: 0;
    margin: 0;
    transition: color 0.15s;
}

.vtx-clear-history-btn:hover {
    color: #c8006e;
}

.vtx-history-item {
    padding: 8px 12px;
}

/* ─── Sections (Categories, Application Areas) ─────────────────────────── */
.vtx-section {
    display: flex;
    flex-direction: column;
}

.vtx-section-label {
    font-size: 11px;
    color: #888;
    padding: 8px 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-sizing: border-box;
}

.vtx-products-label {
    border-top: 1px solid #eee;
    margin-top: 4px;
    padding-top: 8px;
}

.vtx-cat-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    text-decoration: none;
    color: #333;
    box-sizing: border-box;
    transition: background 0.1s;
}

.vtx-cat-item:hover {
    background: #f5f5f5;
}

.vtx-cat-icon {
    margin-right: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}

.vtx-cat-icon svg {
    display: block;
}

.vtx-cat-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 1px;
}

.vtx-cat-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vtx-cat-breadcrumb {
    font-size: 11px;
    color: #999;
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Autocomplete suggestions ─────────────────────────────────────────── */
.vtx-suggestions {
    border-bottom: 1px solid #eee;
}

.vtx-suggest-item {
    display: flex;
    align-items: center;
    padding: 9px 16px;
    cursor: pointer;
    transition: background 0.1s;
    gap: 10px;
}

.vtx-suggest-item:hover,
.vtx-suggest-item.vtx-active {
    background: #f5f5f5;
}

.vtx-suggest-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    opacity: 0.5;
}

.vtx-suggest-icon svg {
    display: block;
}

.vtx-suggest-text {
    font-size: 14px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Page overlay when search is active (matches FiboSearch behavior) ── */
.vtx-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998; /* just below the search wrapper z-index */
    pointer-events: auto;
}

body.vtx-search-active .vtx-overlay {
    display: block;
}

/* ─── Shortcode test-page wrapper ──────────────────────────────────────── */
.vtx-search-section {
    padding: 20px 0;
    width: 100%;
    max-width: 480px;
}

/* ─── v1.19.6: Mobile fix — iOS Safari auto-zoom prevention ───────────── */
/* v1.19.30: Base .vtx-search-input is already 16px, so the !important on
   the input below is now defence-in-depth against any theme override.
   The rest of the rules remain useful — they bump suggestion / result
   typography for readability on small screens. */
@media screen and (max-width: 768px) {
    .vtx-search-input {
        font-size: 16px !important;
    }

    /* Also fix result text readability on mobile */
    .vtx-product-title {
        font-size: 16px !important;
    }

    .vtx-product-price {
        font-size: 15px !important;
    }

    .vtx-suggest-text {
        font-size: 16px !important;
    }

    .vtx-no-results {
        font-size: 16px !important;
    }
}

/* ─── v1.19.7: Hash-routed full results (non-EN pages) ─────────────────── */
/* Renders below the widget when /fr/vertex-ai-search-commerce/#vtxq=... loads */

/* v1.19.20: Removed max-width — the inner .container (theme's max-width: 1300px)
   controls content width, matching the EN template's layout exactly. */
.vtx-hash-results {
    margin: 30px auto 0;
    padding: 0;
}

.vtx-hash-results-header {
    margin-bottom: 20px;
    font-size: 15px;
    color: #333;
}

.vtx-hash-results-corrected {
    display: block;
    margin-top: 8px;
    font-size: 14px;
    color: #666;
    font-style: italic;
}

.vtx-hash-results-grid .grid-products {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.vtx-hash-loading {
    grid-column: 1 / -1;
}

.vtx-hash-pagination .pagination-list .page-link {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #ddd;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.vtx-hash-pagination .pagination-list .page-link:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.vtx-hash-pagination .pagination-list .active .page-link {
    background: #e6007e;
    color: #fff;
    border-color: #e6007e;
}

@media (max-width: 767px) {
    .vtx-hash-results-grid .grid-products {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .vtx-hash-results-grid .grid-products {
        grid-template-columns: 1fr;
    }
}
