/* ============================================================================
   Live Search dropdown + Quick View modal
   مكوّنان للواجهة الأمامية أُعيد بناؤهما بشكل آمن بعد frontend-hardening.
   ========================================================================== */

/* ---- Live Search ---------------------------------------------------------- */
.pub-search { position: relative; }

.pub-ls {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 8px);
    z-index: 10000;
    min-width: min(420px, calc(100vw - 32px));
    background: rgba(253, 252, 248, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(203, 181, 119, 0.18);
    border-radius: 16px;
    box-shadow:
        0 4px 12px rgba(43, 45, 41, 0.06),
        0 12px 32px rgba(43, 45, 41, 0.1),
        0 24px 60px rgba(43, 45, 41, 0.12);
    overflow: hidden;
    max-height: min(72vh, 480px);
    overflow-y: auto;
    display: none;
    direction: rtl;
}
.pub-ls.is-open {
    display: block;
    animation: pub-ls-in .2s cubic-bezier(.22, .61, .36, 1);
}
@keyframes pub-ls-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.pub-ls::-webkit-scrollbar { width: 5px; }
.pub-ls::-webkit-scrollbar-track { background: transparent; }
.pub-ls::-webkit-scrollbar-thumb { background: rgba(203, 181, 119, 0.3); border-radius: 999px; }
.pub-ls::-webkit-scrollbar-thumb:hover { background: rgba(203, 181, 119, 0.5); }

.pub-ls__item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--pub-ink, #2B2D29);
    border-bottom: 1px solid rgba(43, 45, 41, 0.06);
    transition: background .15s ease;
    cursor: pointer;
}
.pub-ls__item:last-child { border-bottom: 0; }
.pub-ls__item:hover,
.pub-ls__item:focus-visible { background: rgba(203, 181, 119, 0.1); }
.pub-ls__item.is-active {
    background: rgba(203, 181, 119, 0.14);
    box-shadow: inset -4px 0 0 var(--pub-primary, #CBB577);
}

.pub-ls__name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.pub-ls__name {
    font-weight: 700;
    font-size: .92rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--pub-ink, #2B2D29);
    letter-spacing: 0;
}

.pub-ls__hl {
    background: rgba(203, 181, 119, 0.25);
    color: var(--pub-primary-dark, #3A4B29);
    border-radius: 3px;
    padding: 0 2px;
}

.pub-ls__badge {
    flex-shrink: 0;
    font-size: .6rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    line-height: 1.6;
    letter-spacing: .02em;
}
.pub-ls__badge--product { background: rgba(203, 181, 119, 0.18); color: #8A7025; }
.pub-ls__badge--category { background: rgba(58, 75, 41, 0.12); color: var(--pub-primary-dark, #3A4B29); }
.pub-ls__badge--page { background: rgba(43, 45, 41, 0.08); color: var(--pub-ink, #2B2D29); }

.pub-ls__thumb {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    border-radius: 10px;
    object-fit: cover;
    background: #f0efe8;
    display: grid;
    place-items: center;
    color: #c5c3b8;
    border: 1px solid rgba(203, 181, 119, 0.12);
}
.pub-ls__info { flex: 1 1 auto; min-width: 0; }

.pub-ls__price-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}
.pub-ls__price { font-size: .88rem; color: var(--pub-primary-dark, #3A4B29); font-weight: 800; }
.pub-ls__old { color: #b5b3a8; text-decoration: line-through; font-weight: 400; margin-inline-start: 6px; font-size: .75rem; }
.pub-ls__oos { color: #c0392b; font-size: .7rem; margin-inline-start: 6px; font-weight: 600; }

.pub-ls__foot {
    padding: 14px 16px;
    text-align: center;
    font-size: .85rem;
    color: var(--pub-ink-soft, rgba(43, 45, 41, 0.72));
    border-top: 1px solid rgba(203, 181, 119, 0.12);
    font-weight: 700;
}
.pub-ls__foot a {
    color: var(--pub-primary-dark, #3A4B29);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

@media (max-width: 640px) {
    .pub-ls {
        position: fixed;
        inset-inline: 12px;
        top: 92px;
        min-width: 0;
        max-height: min(70vh, 520px);
        border-radius: 12px;
    }

    .pub-ls__item {
        padding: 12px;
        gap: 10px;
    }

    .pub-ls__thumb {
        flex-basis: 46px;
        width: 46px;
        height: 46px;
    }

    .pub-ls__badge {
        display: none;
    }
}

.pub-ls__empty {
    padding: 24px 16px;
    text-align: center;
    font-size: .85rem;
    color: var(--pub-ink-soft, rgba(43, 45, 41, 0.72));
}
.pub-ls__empty-icon {
    display: block;
    font-size: 1.5rem;
    color: #d5d3c8;
    margin-bottom: 8px;
}

.pub-ls__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 16px;
}
.pub-ls__loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pub-primary, #CBB577);
    animation: pub-ls-pulse 1.2s ease-in-out infinite;
}
.pub-ls__loading-dot:nth-child(2) { animation-delay: .15s; }
.pub-ls__loading-dot:nth-child(3) { animation-delay: .3s; }
@keyframes pub-ls-pulse {
    0%, 80%, 100% { transform: scale(0.5); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ---- Quick View modal ----------------------------------------------------- */
.qv-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, .55);
}
.qv-modal.is-open { display: flex; }

.qv-modal__dialog {
    position: relative;
    width: min(820px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: var(--pub-r-lg, 16px);
    box-shadow: var(--pub-shadow-lg, 0 24px 60px rgba(0, 0, 0, .22));
    animation: qv-pop .2s ease;
    overscroll-behavior: contain;
}
@keyframes qv-pop { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.qv-modal__close {
    position: absolute;
    top: 10px;
    inset-inline-end: 10px;
    z-index: 2;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: #f1f1f1;
    cursor: pointer;
    font-size: 1.1rem;
    color: #333;
    transition: background-color var(--pub-transition-base, .2s ease), color var(--pub-transition-base, .2s ease), transform var(--pub-transition-base, .2s ease);
}
.qv-modal__close:hover { background: #e4e4e4; transform: translateY(-1px); }
.qv-modal__close:focus-visible {
    outline: var(--pub-focus-outline, 2px solid rgba(203, 181, 119, 0.52));
    outline-offset: 2px;
}

.qv-modal__loading { padding: 48px; text-align: center; color: #888; font-size: 1.4rem; }

.qv { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; padding: 22px; }
@media (max-width: 640px) { .qv { grid-template-columns: 1fr; } }

.qv__media {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #f6f6f6;
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
}
.qv__media img { width: 100%; height: 100%; object-fit: cover; }
.qv__media-fallback { font-size: 3rem; color: #cfcfcf; }
.qv__badge {
    position: absolute;
    top: 10px;
    inset-inline-start: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    color: #fff;
}
.qv__badge--discount { background: #c0392b; }
.qv__badge--special { background: var(--brand, #1f7a4d); }

.qv__body { display: flex; flex-direction: column; gap: 12px; }
.qv__name { font-size: 1.25rem; font-weight: 800; margin: 0; }
.qv__rating { color: #f1b000; font-size: .9rem; }
.qv__rating small { color: #888; margin-inline-start: 4px; }
.qv__price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.qv__price strong { font-size: 1.5rem; color: var(--brand, #1f7a4d); }
.qv__unit { color: #777; font-size: .82rem; }
.qv__old { color: #999; text-decoration: line-through; font-size: .95rem; }
.qv__desc { color: #555; line-height: 1.7; margin: 0; }
.qv__stock { font-weight: 600; margin: 0; }
.qv__stock.is-in { color: #1f7a4d; }
.qv__stock.is-out { color: #c0392b; }
.qv__actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: auto; }

/* زر العرض السريع — يظهر في وسط الصورة عند hover/touch */
.home-product__quickview {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    z-index: 3;
    padding: 8px 20px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .95);
    color: #222;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s cubic-bezier(.34,1.56,.64,1);
    box-shadow: var(--pub-shadow-md, 0 4px 20px rgba(0, 0, 0, .16));
    white-space: nowrap;
}
.home-product:hover .home-product__quickview {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}
.home-product__quickview:hover {
    background: #fff;
    box-shadow: var(--pub-shadow-lg, 0 6px 28px rgba(0, 0, 0, .20));
}

/* الأجهزة اللمسية: يظهر الزر بشكل خفيف ويتفاعل مع اللمس */
@media (hover: none) {
    .home-product__quickview {
        opacity: .75;
        transform: translate(-50%, -50%) scale(0.92);
        pointer-events: auto;
        background: rgba(255, 255, 255, .88);
        padding: 6px 16px;
        font-size: .78rem;
    }
    .home-product__quickview:active {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        background: #fff;
    }
}
