/* =========================================================
   BPRShop Compare - Header button, dropdown panel,
   product-card hover icon, mobile bottom-sheet.
   ========================================================= */

/* fa-code-compare icon — inline SVG element styling.
   Use as: <svg class="bpr-icon-compare" viewBox="0 0 512 512"><path d="..."/></svg>
   The icon is injected directly as <svg> (not background/mask) so it always renders. */
svg.bpr-icon-compare {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    fill: currentColor;
    overflow: visible;
}

/* Cart wrapper becomes a flex row so compare + cart sit on
   the same baseline. */
.sale-basket {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    vertical-align: middle;
    position: relative;            /* anchor for the dropdown panel */
}
.sale-basket > a { display: inline-flex; align-items: center; }

/* =========================================================
   HEADER CART BUTTON  -  borderless icon-only minimal pill
   (applies on every page where .sale-basket-panel-control renders)
   ========================================================= */
.sale-basket-panel-control {
    background: transparent !important;
    background-color: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    color: #1f2937 !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 0 !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    position: relative;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.sale-basket-panel-control:hover,
.sale-basket-panel-control:focus {
    background: rgba(15, 23, 42, 0.08) !important;
    background-color: rgba(15, 23, 42, 0.08) !important;
    color: #0f1c2e !important;
    outline: none;
}
.sale-basket-panel-control:active { transform: scale(0.94); }
/* Hide the "سبد خرید" label. We use the original .fa.fa-shopping-cart icon. */
.sale-basket-panel-control > span:not(.badge) { display: none !important; }
.sale-basket-panel-control .fa.fa-shopping-cart {
    font-size: 22px !important;
    line-height: 1 !important;
    color: inherit !important;
    display: inline-block !important;
    vertical-align: middle !important;
}
/* Hide any leftover injected SVG cart (the JS no longer injects it,
   but if an old cached page still has one in the DOM, keep it hidden). */
.sale-basket-panel-control svg.bpr-icon-cart { display: none !important; }

/* Floating cart count — RED, 40% larger Persian digit at the top corner. */
.sale-basket-panel-control .badge {
    position: absolute !important;
    top: -2px !important;
    left: -2px !important;
    background: transparent !important;
    background-color: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0 !important;
    width: auto !important;
    height: auto !important;
    border-radius: 0 !important;
    color: #dc2626 !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
    text-align: left !important;
    display: inline-block !important;
    text-shadow: 0 0 2px rgba(255, 255, 255, 1), 0 0 4px rgba(255, 255, 255, 0.85), 0 0 6px rgba(255, 255, 255, 0.6);
    direction: ltr;
    z-index: 2;
}

/* =========================================================
   HEADER COMPARE BUTTON  -  borderless icon-only, mirrors cart
   ========================================================= */
#bpr-compare-header-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: transparent !important;
    background-color: transparent !important;
    color: #1f2937 !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0;
    margin: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none !important;
    direction: rtl;
    vertical-align: middle;
    line-height: 1;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
    position: relative;
    z-index: 5;
}
#bpr-compare-header-btn.visible { display: inline-flex; }
#bpr-compare-header-btn:hover,
#bpr-compare-header-btn:focus {
    background: rgba(15, 23, 42, 0.08) !important;
    color: #0f1c2e !important;
    text-decoration: none !important;
    outline: none;
}
#bpr-compare-header-btn:active { transform: scale(0.94); }
#bpr-compare-header-btn .bpr-cmp-icon { font-size: 15px; line-height: 1; }
#bpr-compare-header-btn svg.bpr-icon-compare {
    width: 22px;
    height: 22px;
}
/* Label text is hidden (icon-only). */
#bpr-compare-header-btn .bpr-cmp-label { display: none !important; }
/* Floating compare count — RED, 40% larger Persian digit at the top corner. */
#bpr-compare-header-btn .bpr-cmp-badge {
    position: absolute;
    top: -2px;
    left: -2px;
    background: transparent;
    background-color: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
    min-width: 0;
    width: auto;
    height: auto;
    border-radius: 0;
    color: #dc2626;
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    text-align: left;
    display: inline-block;
    text-shadow: 0 0 2px rgba(255, 255, 255, 1), 0 0 4px rgba(255, 255, 255, 0.85), 0 0 6px rgba(255, 255, 255, 0.6);
    direction: ltr;
    z-index: 2;
}

/* =========================================================
   DROPDOWN PANEL  (desktop dropdown + mobile bottom-sheet)
   ========================================================= */
/* Force the site's Persian font on every element inside the panel.
   Site body is `font-family: byekan`. Explicit stack matches the basket
   hover panel, so the two dropdowns are visually consistent. */
#bpr-compare-panel,
#bpr-compare-panel * {
    font-family: byekan, iranyekan, BYekan1, Tahoma, sans-serif;
}
#bpr-compare-panel {
    display: none;
    position: fixed;
    width: 340px;
    max-width: calc(100vw - 16px);
    background: #ffffff;
    color: #1f2937;
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22), 0 4px 14px rgba(15, 23, 42, 0.08);
    z-index: 99999;
    direction: rtl;
    text-align: right;
    overflow: hidden;
}
#bpr-compare-panel.open { display: block !important; animation: bprCmpDrop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes bprCmpDrop {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* Header bar — soft gradient, badge-like count */
.bpr-cmp-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: linear-gradient(135deg, #f8fbff 0%, #eef7fc 100%);
    border-bottom: 1px solid #e6eef5;
}
.bpr-cmp-panel-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #334155;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.bpr-cmp-panel-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    margin-left: 4px;
    border-radius: 12px;
    background: #5bc0de;
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1;
}
.bpr-cmp-panel-header .bpr-cmp-clear-all {
    color: #ef4444;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 14px;
    transition: background 0.15s, border-color 0.15s;
    font-family: inherit;
}
.bpr-cmp-panel-header .bpr-cmp-clear-all:hover {
    background: #fff1f1;
    border-color: #fecaca;
}

/* Items list */
.bpr-cmp-panel-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 6px 0;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}
.bpr-cmp-panel-list::-webkit-scrollbar { width: 6px; }
.bpr-cmp-panel-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.bpr-cmp-panel-list::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.bpr-cmp-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #f3f5f8;
    transition: background 0.15s;
    animation: bprCmpItemIn 0.22s ease-out both;
}
@keyframes bprCmpItemIn {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: translateX(0); }
}
.bpr-cmp-item:last-child { border-bottom: none; }
.bpr-cmp-item:hover { background: #f7fafc; }

.bpr-cmp-item-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none !important;
    color: #1f2937 !important;
    min-width: 0;
}
.bpr-cmp-item-link img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #eef1f5;
    padding: 3px;
    flex-shrink: 0;
    transition: transform 0.18s, border-color 0.18s;
}
.bpr-cmp-item-link:hover img {
    transform: scale(1.05);
    border-color: #5bc0de;
}
.bpr-cmp-item-name {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.5;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    transition: color 0.15s;
}
.bpr-cmp-item-link:hover .bpr-cmp-item-name { color: #0fa89f !important; }

.bpr-cmp-item-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f3f5f8;
    border: 0;
    color: #94a3b8;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s, transform 0.2s;
}
.bpr-cmp-item-remove:hover {
    background: #fee2e2;
    color: #dc2626;
    transform: rotate(90deg) scale(1.05);
}

/* Empty state */
.bpr-cmp-empty {
    text-align: center;
    padding: 36px 18px 30px;
    color: #94a3b8;
}
.bpr-cmp-empty svg.bpr-icon-compare {
    width: 44px;
    height: 44px;
    color: #cbd5e1;
    margin-bottom: 12px;
}
.bpr-cmp-empty p {
    margin: 0 0 4px;
    font-size: 13.5px;
    font-weight: 700;
    color: #475569;
}
.bpr-cmp-empty span { font-size: 11.5px; color: #94a3b8; }

/* Footer / CTA */
.bpr-cmp-panel-footer {
    padding: 12px 14px;
    border-top: 1px solid #eef1f5;
    background: #fafbfd;
}
.bpr-cmp-go {
    width: 100%;
    padding: 10px 14px;
    background: linear-gradient(135deg, #5bc0de 0%, #31b0d5 100%);
    color: #fff;
    border: 0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
    font-family: inherit;
    box-shadow: 0 4px 12px rgba(91, 192, 222, 0.30);
}
.bpr-cmp-go:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(91, 192, 222, 0.45);
}
.bpr-cmp-go.disabled,
.bpr-cmp-go[disabled] {
    background: #cbd5e1;
    color: #fff;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* =========================================================
   HOVER-COMPARE ICON ON PRODUCT CARDS
   ========================================================= */
.bpr-card-cmp-icon {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 4;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #ffffff;
    color: #5bc0de;
    border: 1px solid #d6e3eb;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.10);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.18s ease, transform 0.18s ease, background 0.15s, color 0.15s;
    padding: 0;
    line-height: 1;
}
.bpr-card-cmp-icon:hover {
    background: #5bc0de;
    color: #fff;
    border-color: #46b8da;
    transform: scale(1);
}
.bpr-card-cmp-icon.active {
    background: #5bc0de;
    color: #fff;
    border-color: #46b8da;
    opacity: 1;
    transform: scale(1);
}
.bpr-card-cmp-icon.busy { opacity: 0.6; pointer-events: none; }

/* Show on hover of the surrounding card */
.product-container:hover .bpr-card-cmp-icon,
.product-image:hover .bpr-card-cmp-icon,
.image-holder:hover .bpr-card-cmp-icon,
.product-card:hover .bpr-card-cmp-icon,
.contet-holder:hover .bpr-card-cmp-icon,
[class*="col-md-"]:hover > .bpr-card-cmp-icon {
    opacity: 1;
    transform: scale(1);
}

/* Touch devices: always show */
@media (hover: none), (max-width: 768px) {
    .bpr-card-cmp-icon {
        opacity: 1;
        transform: scale(1);
        width: 32px;
        height: 32px;
        font-size: 13px;
    }
}


/* =========================================================
   MOBILE — header button compact + dropdown as bottom sheet
   ========================================================= */
@media (max-width: 640px) {
    /* Keep compare + cart on the SAME row even when the column is tight. */
    .sale-basket {
        gap: 2px !important;
        flex-wrap: nowrap !important;
        min-width: 0;
        margin-left: 10px !important;
        position: relative !important;
    }
    .sale-basket > a {
        padding: 0 !important;
        margin: 0 !important;
        line-height: 0 !important;
        position: relative;
        display: inline-flex !important;
        align-items: center;
    }

    /* Keep compare button hidden until it has 2+ items */
    #bpr-compare-header-btn:not(.visible) { display: none !important; }

    /* Slightly smaller circles on mobile */
    .sale-basket-panel-control,
    #bpr-compare-header-btn.visible {
        width: 36px !important;
        height: 36px !important;
    }
    .sale-basket-panel-control svg.bpr-icon-cart,
    #bpr-compare-header-btn svg.bpr-icon-compare {
        width: 20px !important;
        height: 20px !important;
    }
    .bpr-card-cmp-icon svg.bpr-icon-compare { width: 15px; height: 15px; }
    .bpr-compare-btn svg.bpr-icon-compare { width: 15px; height: 15px; }
    .bpr-cmp-empty svg.bpr-icon-compare { width: 36px; height: 36px; color: #cbd5e1; }

    /* Dropdown becomes a bottom sheet on small screens */
    #bpr-compare-panel {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -14px 36px rgba(15, 23, 42, 0.25);
        z-index: 99999;
        padding-top: 12px;        /* space for the grab handle */
    }
    /* Grab handle */
    #bpr-compare-panel::before {
        content: "";
        display: block !important;
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 42px;
        height: 4px;
        border-radius: 2px;
        background: #cbd5e1;
        border: none;
    }
    #bpr-compare-panel.open {
        display: block !important;
        animation: bprCmpSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    }
    @keyframes bprCmpSlideUp {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
    .bpr-cmp-panel-list { max-height: 55vh; padding: 8px 0; }
    .bpr-cmp-panel-header { padding: 12px 18px; }
    .bpr-cmp-panel-title { font-size: 14px; }
    .bpr-cmp-panel-count { min-width: 26px; height: 26px; font-size: 13px; }
    .bpr-cmp-item { padding: 12px 16px; gap: 14px; }
    .bpr-cmp-item-link img { width: 56px; height: 56px; }
    .bpr-cmp-item-name { font-size: 13px; }
    .bpr-cmp-item-remove { width: 32px; height: 32px; font-size: 13px; }
    .bpr-cmp-panel-footer { padding: 14px 16px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
    .bpr-cmp-go { padding: 13px 14px; font-size: 15px; border-radius: 10px; }

    /* Dim overlay behind the bottom sheet */
    body.bpr-cmp-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.50);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        z-index: 99998;
        animation: bprCmpFadeIn 0.22s ease-out;
    }
    @keyframes bprCmpFadeIn {
        from { opacity: 0; }
        to   { opacity: 1; }
    }
    /* Prevent body scroll when sheet is open */
    body.bpr-cmp-open { overflow: hidden; }
}


/* =========================================================
   COMPARE BUTTON on Product Detail Page (replaces old PNG)
   ========================================================= */
.bpr-compare-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    background-color: #ffffff !important;
    color: #232f3e !important;
    border: 1px solid #d0d6dd !important;
    border-radius: 5px !important;
    padding: 5px 12px !important;
    font-family: inherit;
    font-size: 14px !important;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    direction: rtl;
    width: auto !important;
    height: auto !important;
    position: relative !important;
    top: 0 !important;
    vertical-align: middle;
    line-height: 1.45;
}
.bpr-compare-btn:hover {
    background-color: #f4f6f8 !important;
    border-color: #b8c0c9 !important;
    color: #232f3e !important;
}
.bpr-compare-btn.bpr-compare-added {
    background-color: #5bc0de !important;
    color: #fff !important;
    border-color: #46b8da !important;
}
.bpr-compare-btn.bpr-compare-added:hover {
    background-color: #31b0d5 !important;
    border-color: #269abc !important;
}
.bpr-compare-btn .fa { font-size: 15px; color: inherit; line-height: 1; }
.bpr-compare-btn-text { font-size: 14px; font-weight: 500; }

/* Favorite button — same shell as the compare button, heart turns red when active */
.bpr-fav-btn .fa { font-size: 16px; transition: color 0.15s ease; }
.bpr-fav-btn:hover .fa { color: #e0245e; }
.bpr-fav-btn.bpr-fav-added {
    background-color: #fff0f3 !important;
    color: #e0245e !important;
    border-color: #f5b8c7 !important;
}
.bpr-fav-btn.bpr-fav-added:hover {
    background-color: #ffe3ea !important;
    border-color: #f0a0b5 !important;
    color: #e0245e !important;
}
.bpr-fav-btn.bpr-fav-added .fa { color: #e0245e !important; }

.hp-prolist-compare.containerbox {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: #555;
    font-size: 13px;
    font-weight: 600;
    direction: rtl;
    padding: 4px 0;
    user-select: none;
}

/* =========================================================
   TOAST — centered confirmation after add-to-compare
   ========================================================= */
#bpr-cmp-toast,
#bpr-cmp-toast * {
    font-family: byekan, iranyekan, BYekan1, Tahoma, sans-serif;
}
#bpr-cmp-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% - 16px));
    z-index: 100001;
    background: #ffffff;
    color: #1f2937;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.28), 0 6px 18px rgba(15, 23, 42, 0.10);
    padding: 14px 18px;
    direction: rtl;
    text-align: right;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: calc(100vw - 32px);
    border: 1px solid #e2e8f0;
    opacity: 0;
    transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}
#bpr-cmp-toast.visible {
    opacity: 1;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}
.bpr-cmp-toast-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5bc0de 0%, #31b0d5 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    box-shadow: 0 4px 10px rgba(91, 192, 222, 0.35);
}
.bpr-cmp-toast-msg {
    font-size: 13.5px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.5;
    flex: 1;
    min-width: 0;
}
.bpr-cmp-toast-link {
    flex-shrink: 0;
    font-size: 12.5px;
    font-weight: 700;
    color: #0891b2 !important;
    text-decoration: none !important;
    padding: 4px 10px;
    border-radius: 14px;
    background: #ecfeff;
    border: 1px solid #a5f3fc;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.bpr-cmp-toast-link:hover {
    background: #cffafe;
    border-color: #67e8f9;
    color: #0e7490 !important;
    text-decoration: none !important;
}
.bpr-cmp-toast-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    border: 0;
    color: #94a3b8;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}
.bpr-cmp-toast-close:hover {
    background: #f1f5f9;
    color: #1f2937;
}
@media (max-width: 480px) {
    #bpr-cmp-toast {
        min-width: 0;
        width: calc(100vw - 24px);
        padding: 12px 14px;
        gap: 10px;
    }
    .bpr-cmp-toast-icon { width: 30px; height: 30px; font-size: 13px; }
    .bpr-cmp-toast-msg { font-size: 12.5px; }
    .bpr-cmp-toast-link { font-size: 11.5px; padding: 4px 8px; }
}
