/* ============================================================
 * Jims User Assistant
 * Inherits Quick Add's accent/font variables when present.
 * ============================================================ */
.jims-ua {
    --jims-ua-accent-c: var( --jims-ua-accent, var( --jims-qa-accent, #f47b20 ) );
    --jims-ua-accent-h: var( --jims-qa-accent-hover, #e56a10 );
    --jims-ua-font: var( --jims-qa-font-family, 'Rubik', sans-serif );
    font-family: var( --jims-ua-font );
}

html.jims-ua-locked,
html.jims-ua-locked body { overflow: hidden; }

/* ---------------- Launcher ---------------- */
.jims-ua-launcher-wrap {
    position: fixed;
    right: var( --jims-ua-right, 20px );
    bottom: calc( var( --jims-ua-bottom, 20px ) + env( safe-area-inset-bottom, 0px ) );
    z-index: 80;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    font-family: var( --jims-ua-font );
    transition: right .35s ease, bottom .25s ease;
}

.jims-ua.is-peeking .jims-ua-launcher-wrap {
    right: calc(24px - var(--jims-ua-size, 60px));
}
.jims-ua.is-peeking .jims-ua-launcher { transform: rotate(-30deg); }
.jims-ua.is-peeking .jims-ua-bubble { display: none; }
.jims-ua-hide { display: block; margin: 16px 0 0 auto; }
.jims-ua .jims-ua-hide,
.jims-ua .jims-ua-hide:hover { color: #b42318; }

html.jims-mobile-menu-active .jims-ua-launcher-wrap,
html.jims-ua-locked .jims-ua-launcher-wrap,
body:has(.wc-block-product-filters.is-overlay-opened) .jims-ua-launcher-wrap,
body:has(.wc-block-components-drawer__screen-overlay:not(.wc-block-components-drawer__screen-overlay--is-hidden)) .jims-ua-launcher-wrap,
body:has(.wp-block-navigation__responsive-container.is-menu-open) .jims-ua-launcher-wrap,
body:has(dialog[open]) .jims-ua-launcher-wrap {
    visibility: hidden;
    pointer-events: none;
}

.jims-ua-launcher {
    width: var( --jims-ua-size, 60px );
    height: var( --jims-ua-size, 60px );
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var( --jims-ua-accent-c );
    color: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    cursor: pointer;
    overflow: hidden;
    transition: transform .35s ease, box-shadow .15s ease, background-color .15s ease;
}
.jims-ua-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0,0,0,.22); }
.jims-ua-launcher:active { transform: scale(.95); }
.jims-ua-launcher:focus-visible { outline: 3px solid color-mix( in srgb, var( --jims-ua-accent-c ) 40%, transparent ); outline-offset: 3px; }
.jims-ua-launcher.has-image { background: #fff; }
.jims-ua-launcher img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.jims-ua-bubble {
    position: relative;
    max-width: 220px;
    margin-bottom: calc( var( --jims-ua-size, 60px ) * .25 );
    background: #fff;
    color: #111;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 8px 28px rgba(0,0,0,.16);
    opacity: 0;
    transform: translateY(8px) scale(.96);
    transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s ease;
}
.jims-ua-bubble.is-visible { opacity: 1; transform: none; }
.jims-ua-bubble[hidden] { display: none; }

.jims-ua-bubble-text {
    display: block;
    padding: 12px 30px 12px 14px;
    border: 0;
    background: none;
    color: inherit;
    font: 500 13px/1.35 var( --jims-ua-font );
    text-align: left;
    cursor: pointer;
}
.jims-ua-bubble-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #888;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.jims-ua-bubble-close:hover { background: #f2f2f2; color: #111; }

/* ---------------- Modal shell (mirrors Quick Add) ---------------- */
.jims-ua-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.jims-ua-modal.is-open { display: flex; }

.jims-ua-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.5);
    background: color-mix( in srgb, var( --jims-qa-modal-backdrop, #000 ) 50%, transparent );
    backdrop-filter: blur(2px);
    animation: jims-ua-fade .2s ease;
}

.jims-ua-panel {
    position: relative;
    width: 100%;
    max-width: 560px;
    height: min( 640px, calc( 100vh - 40px ) );
    height: min( 640px, calc( 100dvh - 40px ) );
    background: var( --jims-qa-modal-panel-bg, #fff );
    border-radius: var( --jims-qa-modal-radius, 20px );
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    outline: none;
    animation: jims-ua-pop .25s cubic-bezier(.2,.9,.3,1.2);
}

@keyframes jims-ua-fade { from { opacity: 0; } }
@keyframes jims-ua-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.jims-ua-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 12px 18px;
    flex: 0 0 auto;
}
.jims-ua-head-icon {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var( --jims-ua-accent-c );
    color: #fff;
    overflow: hidden;
}
.jims-ua-head-icon.has-image { background: #fff; border: 1px solid #eee; }
.jims-ua-head-icon img { width: 100%; height: 100%; object-fit: cover; }
.jims-ua-heading {
    flex: 1;
    min-width: 0;
    font-size: 15px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jims-ua-back,
.jims-ua-close {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f4f4f4;
    color: #333;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background-color .15s ease;
}
.jims-ua-back[hidden] { display: none; }
.jims-ua-back:hover,
.jims-ua-close:hover { background: #e9e9e9; }

.jims-ua-progress {
    height: 3px;
    margin: 0 18px;
    background: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
    flex: 0 0 auto;
}
.jims-ua-progress span {
    display: block;
    height: 100%;
    width: 8%;
    background: var( --jims-ua-accent-c );
    border-radius: inherit;
    transition: width .35s ease;
}

/* ---------------- Slides ---------------- */
.jims-ua-viewport {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.jims-ua-slide {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    transition: transform .34s cubic-bezier(.25,.8,.25,1), opacity .34s ease;
}
.jims-ua-slide.from-right { transform: translateX(100%); }
.jims-ua-slide.from-left  { transform: translateX(-100%); }
.jims-ua-slide.is-leaving { pointer-events: none; opacity: 0; }
.jims-ua-slide.to-left    { transform: translateX(-30%); }
.jims-ua-slide.to-right   { transform: translateX(30%); }

@media ( prefers-reduced-motion: reduce ) {
    .jims-ua-slide, .jims-ua-panel, .jims-ua-backdrop,
    .jims-ua-launcher-wrap, .jims-ua-launcher { transition: none; animation: none; }
}

.jims-ua-slide-inner {
    padding: 20px 22px 24px;
}

.jims-ua-hero {
    display: block;
    width: 100%;
    max-height: 160px;
    object-fit: contain;
    margin: 0 auto 14px;
    border-radius: 12px;
}

.jims-ua-title {
    margin: 0 0 6px;
    font-family: inherit;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
    color: #111;
}
.jims-ua-text {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.45;
    color: #555;
}
.jims-ua-text p { margin: 0 0 8px; }

/* ---------------- Choices ---------------- */
.jims-ua-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}
.jims-ua-choices.is-grid {
    display: grid;
    grid-template-columns: repeat( 2, minmax(0, 1fr) );
}

.jims-ua-choice {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 58px;
    padding: 12px 14px;
    border: 1px solid var( --jims-qa-btn-border, #ddd );
    border-radius: 14px;
    background: #fff;
    color: #111;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.jims-ua-choice:hover,
.jims-ua-choice:focus-visible {
    border-color: var( --jims-ua-accent-c );
    box-shadow: 0 0 0 2px color-mix( in srgb, var( --jims-ua-accent-c ) 12%, transparent );
    outline: none;
}
.jims-ua-choice.is-selected {
    border-color: var( --jims-ua-accent-c );
    background: color-mix( in srgb, var( --jims-ua-accent-c ) 8%, #fff );
    box-shadow: 0 0 0 2px color-mix( in srgb, var( --jims-ua-accent-c ) 18%, transparent );
}
.jims-ua-choice.is-selected .jims-ua-choice-arrow {
    color: var( --jims-ua-accent-c );
}
.jims-ua-choice:active { transform: scale(.98); }

.jims-ua-choice-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: color-mix( in srgb, var( --jims-ua-accent-c ) 10%, #fff );
    font-size: 20px;
    line-height: 1;
    overflow: hidden;
}
.jims-ua-choice-icon img { width: 100%; height: 100%; object-fit: cover; }

.jims-ua-choice-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.jims-ua-choice-label { font-size: 15px; font-weight: 600; line-height: 1.25; }
.jims-ua-choice-sub { font-size: 12.5px; color: #777; line-height: 1.3; }
.jims-ua-choice-arrow { flex: 0 0 auto; color: #bbb; display: flex; transition: color .15s ease, transform .15s ease; }
.jims-ua-choice:hover .jims-ua-choice-arrow { color: var( --jims-ua-accent-c ); transform: translateX(2px); }

.jims-ua-choices.is-grid .jims-ua-choice {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    min-height: 110px;
}
.jims-ua-choices.is-grid .jims-ua-choice-arrow { display: none; }

/* ---------------- Results ---------------- */
.jims-ua-group { margin-top: 18px; }
.jims-ua-group-title {
    margin: 0 0 10px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: #666;
}
.jims-ua-resistance-note {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.45;
    color: #555;
}

.jims-ua-row {
    display: flex;
    gap: 10px;
    margin: 0 -22px;
    padding: 2px 22px 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 22px;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}

.jims-ua-card {
    position: relative;
    flex: 0 0 148px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border: 1px solid #eaeaea;
    border-radius: 14px;
    background: #fff;
    scroll-snap-align: start;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.jims-ua-card.is-selected {
    border-color: var( --jims-ua-accent-c );
    box-shadow: 0 0 0 2px color-mix( in srgb, var( --jims-ua-accent-c ) 18%, transparent );
}
.jims-ua-card.is-skeleton {
    height: 228px;
    border-color: transparent;
    background: linear-gradient( 90deg, #f3f3f3 0%, #fafafa 50%, #f3f3f3 100% ) 0 0 / 200% 100%;
    animation: jims-ua-shimmer 1.2s linear infinite;
}
@keyframes jims-ua-shimmer { to { background-position: -200% 0; } }

.jims-ua-card-img {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.jims-ua-card-img img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: var( --jims-qa-modal-image-fit, contain );
}
.jims-ua-card-name {
    display: -webkit-box;
    padding: 0;
    border: 0;
    background: transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.3;
    color: #111;
    text-decoration: none;
}
.jims-ua-card-name > * { display: inline; }
.jims-ua-card-name:hover { color: var( --jims-ua-accent-c ); }
.jims-ua-card-img:focus-visible,
.jims-ua-card-name:focus-visible { outline: 2px solid var(--jims-ua-accent-c); outline-offset: 2px; }
.jims-ua-card-price { margin-top: auto; font-size: 13px; font-weight: 500; color: #111; text-align: center; }

.jims-ua-card-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var( --jims-ua-accent-c );
    border-radius: 50px;
    background: var( --jims-ua-accent-c );
    color: #fff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, transform .1s ease;
}
.jims-ua-card-btn:hover { background: var( --jims-ua-accent-h ); color: #fff; }
.jims-ua-card-btn:active { transform: scale(.96); }
.jims-ua-card-btn:disabled { opacity: .7; cursor: wait; }
.jims-ua-card-btn.is-ghost,
.jims-ua-card-btn.is-select {
    background: #fff;
    color: #111;
    border-color: var( --jims-qa-btn-border, #ddd );
}
.jims-ua-card-btn.is-ghost:hover,
.jims-ua-card-btn.is-select:hover { border-color: var( --jims-ua-accent-c ); color: #111; background: #fff; }
.jims-ua-card.is-selected .jims-ua-card-btn.is-select,
.jims-ua-card-btn.is-done {
    background: var( --jims-ua-accent-c );
    border-color: var( --jims-ua-accent-c );
    color: #fff;
}

.jims-ua-empty {
    margin: 20px 0;
    font-size: 14px;
    color: #777;
    text-align: center;
}

.jims-ua-summary-item {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid #e5e5e5;
}
.jims-ua-summary-item > img {
    width: 56px;
    height: 56px;
    object-fit: contain;
}
.jims-ua-summary-details { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.jims-ua-summary-name { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.jims-ua-summary-price { font-size: 14px; font-weight: 600; }
.jims-ua-summary-option,
.jims-ua-summary-note { font-size: 13px; line-height: 1.45; color: #555; }

.jims-ua-inline-addon {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    color: #444;
    font-size: 13px;
    font-weight: 600;
}
.jims-ua-select,
.jims-ua-input {
    box-sizing: border-box;
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid var( --jims-qa-btn-border, #ddd );
    border-radius: 10px;
    background: #fff;
    color: #111;
    font: inherit;
}
.jims-ua-select:focus,
.jims-ua-input:focus { outline: 2px solid color-mix( in srgb, var( --jims-ua-accent-c ) 35%, transparent ); outline-offset: 1px; }

/* ---------------- Footer ---------------- */
.jims-ua-foot {
    flex: 0 0 auto;
    padding: 12px 18px calc( 14px + env( safe-area-inset-bottom, 0px ) );
    border-top: 1px solid #eee;
    background: var( --jims-qa-modal-panel-bg, #fff );
}
.jims-ua-foot[hidden] { display: none; }

.jims-ua-status {
    min-height: 18px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #444;
    text-align: center;
    transition: color .2s ease;
}
.jims-ua-status:empty { display: none; }
.jims-ua-status.is-flash { color: var( --jims-ua-accent-c ); }

.jims-ua-foot-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 14px;
}

.jims-ua-primary,
.jims-ua-secondary {
    flex: 1 1 200px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 18px;
    border-radius: 50px;
    font-family: inherit;
    font-size: 13px;
    font-weight: var( --jims-qa-modal-button-weight, 600 );
    letter-spacing: .3px;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}
.jims-ua-primary {
    border: 0;
    background: var( --jims-ua-accent-c );
    color: #fff;
}
.jims-ua-primary:hover:not(:disabled) { background: var( --jims-ua-accent-h ); color: #fff; }
.jims-ua-primary:disabled { background: #ccc; cursor: not-allowed; }
.jims-ua-secondary {
    border: 1px solid var( --jims-qa-btn-border, #ddd );
    background: #fff;
    color: #111;
}
.jims-ua-secondary:hover { border-color: var( --jims-ua-accent-c ); color: #111; }
.jims-ua-primary:active:not(:disabled),
.jims-ua-secondary:active { transform: scale(.97); }

.jims-ua-link {
    padding: 4px;
    border: 0;
    background: none;
    color: #666;
    font: 500 13px/1 var( --jims-ua-font );
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.jims-ua-link:hover { color: var( --jims-ua-accent-c ); }

/* ---------------- Shortcode trigger ---------------- */
.jims-ua-trigger { cursor: pointer; }
.jims-ua-trigger--link { text-decoration: underline; }

/* ---------------- Mobile ---------------- */
@media ( max-width: 720px ) {
    .jims-ua-launcher-wrap { bottom: calc( var( --jims-ua-bottom-m, 80px ) + env( safe-area-inset-bottom, 0px ) ); }
    .jims-ua.is-scrolling-up .jims-ua-launcher-wrap { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
    .jims-ua--hide-mobile .jims-ua-launcher-wrap { display: none; }

    .jims-ua-modal {
        padding: max(10px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
    }
    .jims-ua-panel {
        max-width: 100%;
        height: calc( 100vh - 20px );
        height: calc( 100dvh - 20px );
        max-height: 100%;
        border-radius: 16px;
    }
    .jims-ua-slide-inner { padding: 16px 16px 20px; }
    .jims-ua-title { font-size: 18px; }
    .jims-ua-row { margin: 0 -16px; padding: 2px 16px 8px; scroll-padding: 0 16px; }
    .jims-ua-card { flex-basis: 42%; }
    .jims-ua-foot { padding-left: 14px; padding-right: 14px; }
    .jims-ua-choices.is-grid .jims-ua-choice { min-height: 96px; }
}
