/* Search by photo (assets/js/visual-search.js): camera triggers in the search bars + the photo window.
   Shared by the shop (Bootstrap 5) and the admin (Bootstrap 4): no framework classes needed.
   Navy #1B3A5F for structure, orange #E85D04 for the action and the match meter. */
:root { --vs-navy: #1B3A5F; --vs-navy-ink: #0F2540; --vs-orange: #E85D04; --vs-ease: cubic-bezier(.23, 1, .32, 1); }

/* ---------- Triggers ---------- */
.vs-trigger-hero {
    position: relative; display: inline-flex; align-items: center; gap: .4rem; flex-shrink: 0;
    height: 2.75rem; padding: 0 .9rem; border: 1px solid rgba(27, 58, 95, .14); border-radius: 12px;
    background: linear-gradient(180deg, #fff, #F3F6FA); color: var(--vs-navy); font-weight: 700; font-size: .88rem; cursor: pointer;
    transition: color .2s, border-color .2s, box-shadow .2s, transform .2s var(--vs-ease);
}
.vs-trigger-hero i { font-size: 1.15rem; color: var(--vs-orange); transition: transform .3s var(--vs-ease); }
.vs-trigger-hero::after { /* soft "lens" ring that draws attention once */
    content: ""; position: absolute; inset: -3px; border-radius: 14px; border: 2px solid rgba(232, 93, 4, .55);
    opacity: 0; animation: vsRing 2.4s var(--vs-ease) 1.2s 2; pointer-events: none;
}
.vs-trigger-hero:hover { border-color: var(--vs-orange); color: var(--vs-orange); box-shadow: 0 8px 20px -10px rgba(232, 93, 4, .7); transform: translateY(-1px); }
.vs-trigger-hero:hover i { transform: scale(1.12) rotate(-6deg); }
.vs-trigger-hero:focus-visible, .vs-trigger:focus-visible, .vs-header-btn:focus-visible { outline: 2px solid var(--vs-orange); outline-offset: 2px; }
@keyframes vsRing { 0% { opacity: .9; transform: scale(.96); } 100% { opacity: 0; transform: scale(1.14); } }
@media (max-width: 575.98px) {
    .vs-trigger-hero { width: 2.75rem; padding: 0; justify-content: center; }
    .vs-trigger-hero .vs-trigger-label { display: none; }
    .hero-search .vs-trigger-hero { order: 1; }
}
.header-search .vs-trigger { color: var(--vs-navy); background: transparent; border: 0; padding: 0 .55rem; }
.header-search .vs-trigger:hover { color: var(--vs-orange); }
.vs-header-btn { border: 0; background: transparent; cursor: pointer; color: var(--vs-navy); }
.vs-header-btn:hover { color: var(--vs-orange); }

/* ---------- Window ---------- */
html.vs-lock, html.vs-lock body { overflow: hidden; }
.vs-overlay {
    position: fixed; inset: 0; z-index: 2100; display: flex; align-items: center; justify-content: center; padding: 1rem;
    background: rgba(11, 26, 42, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    opacity: 0; transition: opacity .18s ease;
}
.vs-overlay.is-open { opacity: 1; }
.vs-overlay[hidden] { display: none; }
.vs-dialog {
    width: min(100%, 46rem); max-height: calc(100vh - 2rem); overflow: auto; border-radius: 1.25rem; background: #fff;
    box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .6); color: #22364D;
    transform: translateY(12px) scale(.98); transition: transform .28s var(--vs-ease);
    font-family: inherit; text-align: start;
}
.vs-overlay.is-open .vs-dialog { transform: none; }
.vs-head { display: flex; align-items: flex-start; gap: .85rem; padding: 1.2rem 1.25rem .9rem; border-bottom: 1px solid rgba(27, 58, 95, .08); }
.vs-head-icon { display: grid; place-items: center; flex-shrink: 0; width: 2.6rem; height: 2.6rem; border-radius: .8rem; background: var(--vs-navy); color: #fff; }
.vs-head-icon svg { width: 1.35rem; height: 1.35rem; }
.vs-title { margin: 0; font-size: 1.12rem; font-weight: 800; color: var(--vs-navy-ink); }
.vs-sub { margin: .15rem 0 0; font-size: .83rem; color: #5F7088; }
.vs-close { margin-inline-start: auto; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border: 0; border-radius: .6rem; background: rgba(27, 58, 95, .06); color: var(--vs-navy); cursor: pointer; }
.vs-close svg { width: 1.1rem; height: 1.1rem; }
.vs-close:hover { background: var(--vs-orange); color: #fff; }
.vs-body { padding: 1.25rem; }

.vs-drop {
    display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 2rem 1rem; text-align: center; cursor: pointer;
    border: 1.5px dashed rgba(27, 58, 95, .28); border-radius: 1rem; background: rgba(27, 58, 95, .03); color: #5F7088; font-size: .85rem;
    transition: border-color .2s, background-color .2s;
}
.vs-drop strong { color: var(--vs-navy-ink); font-size: 1rem; }
.vs-drop-icon { display: grid; place-items: center; width: 3.4rem; height: 3.4rem; margin-bottom: .35rem; border-radius: 1rem; background: #fff; color: var(--vs-orange); box-shadow: 0 4px 14px -6px rgba(15, 37, 64, .3); }
.vs-drop-icon svg { width: 1.7rem; height: 1.7rem; }
.vs-drop:hover, .vs-drop.is-over { border-color: var(--vs-orange); background: rgba(232, 93, 4, .06); }
.vs-drop:focus-visible { outline: 2px solid var(--vs-orange); outline-offset: 3px; }

.vs-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.vs-actions .vs-btn { flex: 1 1 12rem; justify-content: center; }
.vs-btn {
    display: inline-flex; align-items: center; gap: .45rem; min-height: 2.75rem; padding: 0 1rem; border-radius: .75rem;
    border: 1px solid rgba(27, 58, 95, .2); background: #fff; color: var(--vs-navy); font-weight: 700; font-size: .9rem;
    cursor: pointer; text-decoration: none; transition: background-color .15s, border-color .15s, color .15s, transform .15s;
}
.vs-btn svg { width: 1.15rem; height: 1.15rem; }
.vs-btn:hover { border-color: var(--vs-navy); background: var(--vs-navy); color: #fff; }
.vs-btn-primary { border-color: var(--vs-orange); background: var(--vs-orange); color: #fff; }
.vs-btn-primary:hover { border-color: #C44E03; background: #C44E03; color: #fff; }
.vs-btn:active { transform: scale(.98); }
.vs-btn:focus-within, .vs-btn:focus-visible { outline: 2px solid var(--vs-orange); outline-offset: 2px; }
.vs-tip { margin: .9rem 0 0; font-size: .8rem; color: #7B8BA0; }

/* Scanning */
.vs-scan { display: flex; flex-direction: column; align-items: center; gap: .9rem; padding: .5rem 0 1rem; }
.vs-preview { position: relative; overflow: hidden; width: min(100%, 16rem); aspect-ratio: 1; border-radius: 1rem; background: #EEF2F7; box-shadow: 0 0 0 1px rgba(27, 58, 95, .12); }
.vs-preview img { width: 100%; height: 100%; object-fit: cover; }
.vs-scanline {
    position: absolute; inset-inline: 0; top: 0; height: 32%;
    background: linear-gradient(180deg, rgba(232, 93, 4, 0), rgba(232, 93, 4, .28) 85%, rgba(232, 93, 4, .95) 100%);
    animation: vsScan 1.4s cubic-bezier(.65, 0, .35, 1) infinite alternate;
}
@keyframes vsScan { from { transform: translateY(-100%); } to { transform: translateY(220%); } }
.vs-status { margin: 0; font-weight: 700; color: var(--vs-navy); }

/* Results */
.vs-results-head { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.vs-results-head > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vs-results-head strong { color: var(--vs-navy-ink); }
.vs-note { font-size: .78rem; color: #7B8BA0; }
.vs-thumb { width: 3.2rem; height: 3.2rem; flex-shrink: 0; object-fit: cover; border-radius: .7rem; box-shadow: 0 0 0 2px var(--vs-orange); }
.vs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: .8rem; }
.vs-card {
    display: flex; flex-direction: column; overflow: hidden; border-radius: .9rem; border: 1px solid rgba(27, 58, 95, .12);
    background: #fff; color: inherit; text-decoration: none; animation: vsCardIn .35s var(--vs-ease) both;
    transition: transform .2s var(--vs-ease), box-shadow .2s, border-color .2s;
}
.vs-card:hover { transform: translateY(-3px); border-color: var(--vs-orange); box-shadow: 0 16px 30px -18px rgba(15, 37, 64, .55); color: inherit; }
@keyframes vsCardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.vs-card-img { aspect-ratio: 4 / 3; background: linear-gradient(180deg, #fff, #EEF2F7); }
.vs-card-img img { width: 100%; height: 100%; object-fit: contain; padding: .5rem; }
.vs-card-body { display: flex; flex-direction: column; gap: .25rem; padding: .6rem .7rem .75rem; }
.vs-match { display: flex; align-items: center; gap: .4rem; font-size: .7rem; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; color: var(--vs-orange); }
.vs-medium .vs-match { color: #B4580C; }
.vs-low .vs-match { color: #7B8BA0; }
.vs-meter { flex: 0 0 2.6rem; height: .3rem; border-radius: 999px; background: rgba(27, 58, 95, .1); overflow: hidden; }
.vs-meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #FFB37A, var(--vs-orange)); }
.vs-low .vs-meter i { background: #A9B6C6; }
.vs-card-name { font-size: .84rem; font-weight: 700; line-height: 1.3; color: var(--vs-navy-ink);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vs-card-ref { font-size: .72rem; color: #7B8BA0; }
.vs-card-price { margin-top: auto; font-size: .82rem; font-weight: 800; color: var(--vs-navy); }
.vs-empty { grid-column: 1 / -1; padding: 1rem; border-radius: .9rem; background: rgba(232, 93, 4, .06); text-align: center; }
.vs-empty p { margin: 0 0 .75rem; color: #3E5068; font-size: .88rem; }
/* "Nous avons détecté : …" — editable by the customer */
.vs-detected { margin: 0 0 1rem; padding: .8rem .9rem; border-radius: .9rem; background: rgba(27, 58, 95, .05); border: 1px solid rgba(27, 58, 95, .12); }
.vs-detected[hidden] { display: none; }
.vs-detected-label { display: block; margin-bottom: .35rem; font-size: .8rem; font-weight: 800; color: var(--vs-navy); }
.vs-detected-row { display: flex; gap: .5rem; }
.vs-detected-input {
    flex: 1; min-width: 0; height: 2.75rem; padding: 0 .8rem; border-radius: .7rem; border: 1px solid rgba(27, 58, 95, .25);
    background: #fff; color: var(--vs-navy-ink); font: inherit; font-weight: 700;
}
.vs-detected-input:focus { outline: 2px solid var(--vs-orange); outline-offset: 1px; border-color: transparent; }
.vs-detected-hint { display: block; margin-top: .35rem; font-size: .75rem; color: #7B8BA0; }
.vs-not-part { margin: 0 0 1rem; padding: .7rem .9rem; border-radius: .7rem; background: #FFF4EC; color: #8A3E05; font-size: .85rem; font-weight: 600; }
.vs-not-part[hidden] { display: none; }
.vs-ai-note { margin-top: .35rem; font-size: .74rem; }

/* Why a product matches */
.vs-why { display: flex; flex-wrap: wrap; gap: .25rem; }
.vs-why span { padding: .05rem .4rem; border-radius: 999px; background: rgba(27, 58, 95, .07); color: var(--vs-navy); font-size: .66rem; font-weight: 700; }
.vs-why .vs-why-reference { background: rgba(232, 93, 4, .12); color: #B4580C; }

/* Nothing sure: WhatsApp first */
.vs-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.vs-btn-wa { border-color: #25D366; background: #25D366; color: #fff; }
.vs-btn-wa:hover { border-color: #1EBE5B; background: #1EBE5B; color: #fff; }
.vs-wa-hint { display: block; margin-top: .5rem; font-size: .75rem; color: #5F7088; }

.vs-error { margin: 1rem 0 0; padding: .7rem .9rem; border-radius: .7rem; background: #FDECEA; color: #A93226; font-size: .85rem; font-weight: 600; }

@media (max-width: 575.98px) {
    .vs-overlay { align-items: flex-end; padding: 0; }
    .vs-dialog { width: 100%; max-height: 92vh; border-radius: 1.25rem 1.25rem 0 0; }
    .vs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
    .vs-trigger-hero::after, .vs-scanline, .vs-card { animation: none; }
    .vs-dialog, .vs-overlay { transition: none; }
}
