/* ============================================
   BUYLO ENHANCEMENT PACK - STANDALONE ONLY
   (No global overrides, no dark mode, NO STICKY HEADER OVERRIDE)
   Only adds NEW components: Wishlist, Compare, QuickView,
   FreeShip Bar, Toast Enhancements, Compare Bar, Recent Viewed,
   Instagram Stories (Buylo Story)
   ============================================ */

/* Note: Smart Sticky Header completely REMOVED to avoid conflicts
   with original template's GSAP animations and the amazing-offers banner. */

/* ============================================
   A. HEADER - NEW ACTION BUTTONS (Wishlist / Compare)
   Designed to blend with original buylo header style
   ============================================ */

/* Wishlist + Compare Buttons - header style (match cart button look) */
.buylo-action-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    padding: 0 12px;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: #444b75;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all .2s ease;
    white-space: nowrap;
}

.buylo-action-btn:hover {
    background: #f5f6fa;
    color: #ee1a45;
    transform: translateY(-1px);
}

.buylo-action-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.buylo-action-btn .action-label {
    display: inline;
}

/* Small badge counter on header buttons */
.buylo-badge {
    position: absolute;
    top: 2px;
    left: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9999px;
    background: var(--buylo-wishlist-color, #ee1a45);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(238,26,69,0.4);
    z-index: 3;
    font-family: inherit;
    transition: transform .35s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.buylo-badge.buylo-compare-count {
    background: var(--buylo-compare-color, #5b51d8);
}

.buylo-badge.buylo-badge--pulse {
    animation: buylo-badge-pop .4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
@keyframes buylo-badge-pop {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.6); }
    70%  { transform: scale(0.88); }
    100% { transform: scale(1); }
}

.buylo-wishlist-btn.buylo-is-active {
    color: var(--buylo-wishlist-color, #ee1a45);
    background: #fff1f3;
}
.buylo-wishlist-btn.buylo-is-active svg {
    fill: var(--buylo-wishlist-color, #ee1a45);
    animation: buylo-heart-beat .6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
@keyframes buylo-heart-beat {
    0%, 100% { transform: scale(1); }
    25%      { transform: scale(1.35); }
    50%      { transform: scale(0.9); }
    75%      { transform: scale(1.18); }
}

/* Hide labels on mobile so header doesn't break */
@media (max-width: 768px) {
    .buylo-action-btn {
        padding: 0 8px;
        font-size: 0;
        height: 40px;
        min-width: 40px;
    }
    .buylo-action-btn .action-label { display: none; }
    .buylo-badge {
        top: 0;
        left: 0;
    }
}

/* ============================================
   B. WISHLIST / QUICKVIEW / COMPARE BUTTONS ON PRODUCT CARD
   Floating hover actions on TOP-RIGHT for RTL template
   ============================================ */
.buylo-card-actions {
    position: absolute;
    top: 14px;
    right: 14px;
    left: auto !important;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 999 !important;
    opacity: 0;
    pointer-events: none;
    transform: translateX(10px);
    transition: opacity .25s ease, transform .25s ease;
}

/* Appear on card hover — use broad selectors that match buylo's card classes */
.best-item:hover .buylo-card-actions,
.product:hover .buylo-card-actions,
li.product:hover .buylo-card-actions,
.cat-card-independent:hover .buylo-card-actions,
.card:hover .buylo-card-actions,
.product-card:hover .buylo-card-actions,
.product-grid-para-card:hover .buylo-card-actions,
.product-card-item:hover .buylo-card-actions,
.item-card:hover .buylo-card-actions,
[data-product-id]:hover .buylo-card-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

/* Always show on mobile */
@media (max-width: 768px) {
    .buylo-card-actions {
        opacity: 1;
        transform: translateX(0);
        pointer-events: auto;
        top: 10px;
        right: 10px;
    }
}

/* ============================================
   B-2. OVERRIDE: Hide NATIVE bottom buttons in Buylo widgets
   (they are placed ON the "افزودن به سبد" button — user wants them ON IMAGE)
   Our floating buylo-card-actions will take over instead
   ============================================ */
.product-box-new-time-actions .quick-view-trigger,
.product-box-new-time-actions .add-to-wishlist-simple,
.product-box-new-time-actions .compare-trigger {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

/* Ensure parent cards are ALWAYS relative (critical for floating card-actions) */
.best-item,
.product,
li.product,
.cat-card-independent,
.card,
.product-card,
.product-grid-para-card,
.item-card,
[data-product-id],
.product-box-new-time-card,
.product-box-new-time-image {
    position: relative !important;
    /* overflow: hidden removed to let card-actions overflow softly if needed */
}

/* Appear on card hover — also include buylo native card classes */
.product-box-new-time-card:hover .buylo-card-actions,
.product-box-new-time-image:hover .buylo-card-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.buylo-card-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 9999px;
    background: #ffffff;
    border: 1px solid #edf2f7;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #4b5563;
    transition: all .18s ease;
}

.buylo-card-btn:hover {
    color: #ee1a45;
    border-color: rgba(238,26,69,0.25);
    transform: scale(1.12);
    box-shadow: 0 6px 14px rgba(0,0,0,0.1);
}

.buylo-card-btn svg {
    width: 18px;
    height: 18px;
    /* Important: SVG must be pointer-events: none so closest() on button always fires. */
    pointer-events: none !important;
    display: block;
}

/* Active states */
.buylo-card-btn.buylo-is-active {
    background: var(--buylo-wishlist-color, #ee1a45);
    color: #fff;
    border-color: var(--buylo-wishlist-color, #ee1a45);
}
.buylo-card-btn.buylo-is-active svg { fill: #fff; stroke: #fff; }

.buylo-card-btn.buylo-compare--active {
    background: var(--buylo-compare-color, #5b51d8);
    color: #fff;
    border-color: var(--buylo-compare-color, #5b51d8);
}

/* Simple tooltip */
.buylo-card-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    right: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%) translateX(4px);
    padding: 5px 10px;
    background: #0f172a;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all .15s ease;
    z-index: 20;
    font-family: inherit;
}
.buylo-card-btn:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* ============================================
   C. MODAL SYSTEM
   ============================================ */
.buylo-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999 !important;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    padding: 20px;
    direction: rtl;
}
.buylo-modal-overlay.buylo-is-open {
    opacity: 1;
    pointer-events: auto;
}

.buylo-modal {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 60px -15px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 920px;
    max-height: 88vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(30px) scale(0.97);
    transition: transform .35s cubic-bezier(0.16, 1, 0.3, 1);
    direction: rtl;
    color: #1f2937;
}
.buylo-modal--sm { max-width: 520px; }
.buylo-modal--lg { max-width: 1180px; }

.buylo-modal-overlay.buylo-is-open .buylo-modal {
    transform: translateY(0) scale(1);
}

.buylo-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #eef2f6;
    flex-shrink: 0;
}
.buylo-modal-title {
    font-size: 16px;
    font-weight: 800;
    color: #1f2937;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: inherit;
}
.buylo-modal-title svg {
    width: 22px;
    height: 22px;
    color: #ee1a45;
}

.buylo-modal-close {
    width: 38px;
    height: 38px;
    border-radius: 9999px;
    background: #f3f4f6;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
    transition: all .2s ease;
}
.buylo-modal-close:hover {
    background: #ee1a45;
    color: #fff;
    transform: rotate(90deg);
}

.buylo-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    font-family: inherit;
}

.buylo-modal-footer {
    padding: 14px 24px;
    border-top: 1px solid #eef2f6;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

/* ============================================
   D. GENERIC BUTTONS INSIDE MODALS
   ============================================ */
.buylo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 20px;
    border-radius: 10px;
    background: #ee1a45;
    color: #fff;
    border: 1px solid #ee1a45;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s ease;
    white-space: nowrap;
}
.buylo-btn:hover {
    background: #d4143d;
    border-color: #d4143d;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(238,26,69,0.28);
}
.buylo-btn svg { width: 17px; height: 17px; }

.buylo-btn--secondary {
    background: #ffffff;
    color: #4b5563;
    border-color: #e5e7eb;
}
.buylo-btn--secondary:hover {
    background: #f9fafb;
    color: #1f2937;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.buylo-btn--ghost {
    background: transparent;
    color: #ee1a45;
    border-color: rgba(238,26,69,0.3);
}
.buylo-btn--ghost:hover { background: #fff1f3; }

/* ============================================
   E. QUICK VIEW GRID INSIDE MODAL
   ============================================ */
.buylo-qv-grid {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    gap: 28px;
}
@media (max-width: 768px) {
    .buylo-qv-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}
.buylo-qv-image-wrap {
    position: relative;
    background: #f8f9fb;
    border-radius: 14px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    min-height: 280px;
    max-height: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    /* fix for browsers lacking aspect-ratio */
    width: 100%;
}
@supports not (aspect-ratio: 1) {
    .buylo-qv-image-wrap { min-height: 340px; padding-top: 100%; }
}
.buylo-qv-image-wrap img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    padding: 24px;
    margin: 0 auto;
    mix-blend-mode: multiply;
}
.buylo-qv-image-wrap img[src=""],
.buylo-qv-image-wrap img:not([src]) {
    display: none !important;
}
.buylo-qv-sale {
    position: absolute;
    top: 14px;
    left: 14px;
    background: #ee1a45;
    color: #fff;
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 800;
    font-family: inherit;
}
.buylo-qv-title {
    font-size: 20px;
    font-weight: 800;
    color: #1f2937;
    line-height: 1.4;
    margin: 0 0 10px;
    font-family: inherit;
}
.buylo-qv-price {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.buylo-qv-price ins {
    text-decoration: none;
    font-size: 24px;
    font-weight: 800;
    color: #ee1a45;
    background: transparent;
    padding: 0;
    display: inline-block;
}
.buylo-qv-price del {
    font-size: 15px;
    color: #9ca3af;
}
.buylo-qv-desc {
    color: #4b5563;
    line-height: 1.8;
    margin-bottom: 20px;
    font-size: 13px;
    font-family: inherit;
}

/* ============================================
   F. MODERN QUANTITY SELECTOR (+/-)
   Used in Quick View and wraps existing Woo .quantity
   ============================================ */
.buylo-qty {
    display: inline-flex;
    align-items: center;
    background: #f5f6fa;
    border: 1px solid #eef2f6;
    border-radius: 10px;
    overflow: hidden;
    height: 44px;
}
.buylo-qty-btn {
    width: 44px;
    height: 100%;
    background: transparent;
    border: none;
    color: #4b5563;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .15s ease;
    font-size: 18px;
    font-weight: 700;
    font-family: inherit;
}
.buylo-qty-btn:hover { background: #ee1a45; color: #fff; }
.buylo-qty-btn:active { transform: scale(0.92); }
.buylo-qty-btn svg { width: 15px; height: 15px; }

.buylo-qty-input {
    width: 54px;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    font-family: inherit;
    outline: none;
    -moz-appearance: textfield;
}
.buylo-qty-input::-webkit-outer-spin-button,
.buylo-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ============================================
   G. FREE SHIPPING PROGRESS BAR
   Inserted in mini-cart header + cart page
   ============================================ */
.buylo-freeship {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: 10px;
    font-family: inherit;
}
.buylo-freeship__text {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: #1d4ed8;
    margin-bottom: 8px;
    gap: 8px;
    line-height: 1.6;
}
.buylo-freeship__amount {
    font-weight: 800;
    white-space: nowrap;
}
.buylo-freeship__track {
    position: relative;
    height: 7px;
    background: rgba(59,130,246,0.13);
    border-radius: 9999px;
    overflow: hidden;
}
.buylo-freeship__fill {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 9999px;
    transition: width .7s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 8px rgba(59,130,246,0.4);
}
.buylo-freeship__fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.45), transparent);
    animation: buylo-fs-shimmer 2s infinite;
}
.buylo-freeship__done .buylo-freeship__fill {
    background: linear-gradient(90deg, #10b981, #34d399);
}
@keyframes buylo-fs-shimmer {
    0%   { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* Insert into mini-cart with consistent margins */
.cart-mega-menu .buylo-freeship {
    margin: 8px 16px 10px;
}

/* ============================================
   H. RECENTLY VIEWED (BEFORE FOOTER)
   ============================================ */
.buylo-recent {
    padding: 24px 0;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    direction: rtl;
    font-family: inherit;
}
.buylo-recent__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 0 8px;
}
.buylo-recent__title {
    font-size: 17px;
    font-weight: 800;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-family: inherit;
}
.buylo-recent__title svg {
    width: 22px;
    height: 22px;
    color: #ffbb18;
}
.buylo-recent__clear {
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all .15s ease;
    font-family: inherit;
}
.buylo-recent__clear:hover {
    background: #fef2f2;
    color: #ef4444;
}

.buylo-recent__list {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}
@media (max-width: 1024px) { .buylo-recent__list { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 768px)  { .buylo-recent__list { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 480px)  { .buylo-recent__list { grid-template-columns: repeat(2, 1fr); } }

.buylo-recent__item {
    background: #ffffff;
    border: 1px solid #eef2f6;
    border-radius: 10px;
    padding: 8px;
    transition: all .22s ease;
    text-decoration: none;
    display: block;
}
.buylo-recent__item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.07);
    border-color: #e5e7eb;
}
.buylo-recent__img {
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fb;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.buylo-recent__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.buylo-recent__name {
    font-size: 12px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.5;
    margin: 0 0 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: inherit;
}
.buylo-recent__price {
    font-size: 12px;
    font-weight: 800;
    color: #ee1a45;
    font-family: inherit;
}

/* ============================================
   I. EMPTY STATES
   ============================================ */
.buylo-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    font-family: inherit;
}
.buylo-empty__icon {
    width: 70px;
    height: 70px;
    border-radius: 9999px;
    background: #f3f4f6;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: #9ca3af;
}
.buylo-empty__icon svg { width: 32px; height: 32px; }
.buylo-empty__title {
    font-size: 15px;
    font-weight: 700;
    color: #4b5563;
    margin: 0 0 6px;
    font-family: inherit;
}
.buylo-empty__desc {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
    line-height: 1.7;
}

/* ============================================
   J. COMPARE FLOATING BAR (BOTTOM OF PAGE)
   ============================================ */
.buylo-compare-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(130%);
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 20px 50px -15px rgba(0,0,0,0.25);
    padding: 10px 14px 10px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9998;
    transition: transform .4s cubic-bezier(0.16, 1, 0.3, 1);
    direction: rtl;
    max-width: calc(100% - 32px);
    font-family: inherit;
}
.buylo-compare-bar.buylo-is-visible {
    transform: translateX(-50%) translateY(0);
}
@media (max-width: 520px) {
    .buylo-compare-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }
}

.buylo-compare-bar__items {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}
.buylo-compare-bar__slot {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.buylo-compare-bar__slot svg { width: 18px; height: 18px; }

.buylo-compare-bar__slot.buylo-filled {
    border: 2px solid var(--buylo-compare-color, #5b51d8);
    border-style: solid;
    background: #ffffff;
}
.buylo-compare-bar__slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.buylo-compare-bar__slot-remove {
    position: absolute;
    top: -5px;
    left: -5px;
    width: 18px;
    height: 18px;
    border-radius: 9999px;
    background: #ef4444;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    font-size: 11px;
    font-weight: 700;
    opacity: 0;
    transition: opacity .15s ease;
    line-height: 1;
}
.buylo-compare-bar__slot.buylo-filled:hover .buylo-compare-bar__slot-remove { opacity: 1; }

.buylo-compare-bar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.buylo-compare-bar__count {
    font-size: 12px;
    font-weight: 700;
    color: #4b5563;
    white-space: nowrap;
    padding-inline-end: 6px;
}

/* Body padding to avoid content getting covered */
body.buylo-compare-active {
    padding-bottom: 105px !important;
}
@media (max-width: 520px) {
    body.buylo-compare-active { padding-bottom: 210px !important; }
}

/* ============================================
   K. SCROLL PROGRESS BAR (TOP OF PAGE)
   ============================================ */
.buylo-scroll-progress {
    position: fixed;
    top: 0;
    right: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, #ee1a45, #5b51d8, #ffbb18);
    z-index: 100000;
    transition: width 50ms linear;
    box-shadow: 0 0 8px rgba(238,26,69,0.5);
}

/* ============================================
   M. NOTIFICATION / TOAST ENHANCEMENTS
   Override the existing notification positioning defaults (top-left)
   to be more modern. Also RTL body.
   ============================================ */
.custom-notification {
    font-family: inherit;
}
/* Move default to top-right for RTL better placement */
.custom-notification.top-left {
    top: 80px;
    right: 24px;
    left: auto;
}
@media (max-width: 520px) {
    .custom-notification {
        min-width: 0;
        width: calc(100% - 32px);
        max-width: calc(100% - 32px);
    }
    .custom-notification.top-left {
        top: 16px;
        right: 16px !important;
        left: 16px !important;
    }
}

/* ============================================
   Y. INSTAGRAM STORIES - BUYLO
   دایره استوری + مودال تمام‌صفحه
   ============================================ */

/* === لیست دایره‌های استوری === */
.buylo-stories-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    padding: 8px 0;
    --bsize: 80px;
    --bwidth: 3px;
}
.buylo-stories-track {
    display: flex;
    align-items: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 6px 8px 14px;
    gap: 0;
    scrollbar-width: none;
}
.buylo-stories-track::-webkit-scrollbar { display: none; }

.buylo-stories-item {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    scroll-snap-align: start;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    margin: 0 6px;
    max-width: calc(var(--bsize) + 20px);
}

/* حلقه بیرونی گرادیان */
.buylo-stories-ring {
    position: relative;
    width: var(--bsize);
    height: var(--bsize);
    border-radius: 50%;
    padding: var(--bwidth);
    background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af);
    box-sizing: border-box;
    transition: transform .2s ease;
}
.buylo-stories-item:hover .buylo-stories-ring {
    transform: scale(1.04);
}
.buylo-stories-item[data-buylo-story-seen="1"] .buylo-stories-ring {
    background: #9ca3af;
}

/* حلقه داخلی سفید (در حالت LTR) */
.buylo-stories-ring-inner {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    padding: 2px;
    background: #fff;
    box-sizing: border-box;
}
.buylo-stories-ring-inner > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
    background: #f3f4f6;
}
/* نشان تأیید شده */
.buylo-stories-verified {
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    box-sizing: border-box;
}
.buylo-stories-verified svg { width: 100%; height: 100%; }

/* نام کاربری زیر دایره */
.buylo-stories-username {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #111827;
    text-align: center;
    max-width: calc(var(--bsize) + 6px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

/* === مودال نمایش استوری === */
.buylo-story-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #000;
    display: none;
    align-items: stretch;
    justify-content: center;
    opacity: 0;
    transition: opacity .25s ease;
}
.buylo-story-modal.buylo-modal--open {
    display: flex;
    opacity: 1;
}
.buylo-story-modal * { box-sizing: border-box; }

/* قاب استوری - نسبت 9:16 مانند اینستاگرام */
.buylo-story-stage {
    position: relative;
    width: 100%;
    max-width: 450px;
    height: 100vh;
    max-height: 900px;
    margin: auto;
    background: #0f172a;
    overflow: hidden;
    border-radius: 0;
}
@media (min-width: 768px) {
    .buylo-story-stage {
        border-radius: 18px;
        height: calc(100vh - 40px);
        max-height: 860px;
        box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    }
}

/* لایه میانی محتوا */
.buylo-story-layer {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.buylo-story-layer img,
.buylo-story-layer video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #111;
}
/* گرادیان پایینی برای خوانایی متن */
.buylo-story-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 55%;
    pointer-events: none;
    background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.35) 55%, rgba(0,0,0,0) 100%);
    z-index: 3;
}

/* هدر مودال: آواتار + نام + زمان + بستن */
.buylo-story-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 52px 14px 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.55), rgba(0,0,0,0));
}
.buylo-story-avatar-mini {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.7);
    background: #e5e7eb;
}
.buylo-story-user-col { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.buylo-story-user-row { display: flex; align-items: center; gap: 6px; }
.buylo-story-username-mini {
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.buylo-story-verified-mini {
    width: 14px; height: 14px; display: inline-flex; flex-shrink: 0;
}
.buylo-story-verified-mini svg { width: 100%; height: 100%; }
.buylo-story-time-ago {
    color: rgba(255,255,255,0.75);
    font-size: 11px;
    margin-top: 2px;
}
.buylo-story-close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background .2s;
}
.buylo-story-close:hover { background: rgba(255,255,255,0.22); }
.buylo-story-close svg { width: 18px; height: 18px; }

/* نوارهای پیشرفت (استوری لاین) */
.buylo-story-progress-wrap {
    position: absolute;
    top: 14px;
    left: 10px;
    right: 10px;
    z-index: 11;
    display: flex;
    gap: 4px;
    pointer-events: none;
}
.buylo-story-prog-bar {
    flex: 1 1 auto;
    height: 3px;
    background: rgba(255,255,255,0.35);
    border-radius: 2px;
    overflow: hidden;
    min-width: 0;
}
.buylo-story-prog-fill {
    display: block;
    width: 0%;
    height: 100%;
    background: #fff;
    border-radius: 2px;
    transition: width .12s linear;
}
.buylo-story-prog-bar.buylo-prog--done .buylo-story-prog-fill { width: 100% !important; }

/* ناحیه‌های کلیک: بعدی / قبلی / مکث */
.buylo-story-hot {
    position: absolute;
    top: 96px;
    bottom: 110px;
    z-index: 9;
    cursor: pointer;
}
.buylo-story-hot--prev { left: 0; width: 30%; }
.buylo-story-hot--next { right: 0; width: 30%; }
.buylo-story-hot--pause {
    left: 30%; right: 30%;
    cursor: default;
    z-index: 8;
}
/* دکمه‌های بعدی/قبلی کنار (برای دسکتاپ) */
.buylo-story-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0,0,0,0.35);
    color: #fff;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 12;
    backdrop-filter: blur(8px);
    transition: background .2s, opacity .2s;
    opacity: 0;
}
.buylo-story-modal:hover .buylo-story-nav { opacity: 1; }
.buylo-story-nav:hover { background: rgba(0,0,0,0.55); }
.buylo-story-nav svg { width: 20px; height: 20px; }
.buylo-story-nav--prev { left: 12px; }
.buylo-story-nav--next { right: 12px; }
.buylo-story-nav[disabled] { opacity: 0.2 !important; cursor: not-allowed; }

/* قسمت پایین: کپشن + دکمه لینک */
.buylo-story-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 18px 16px 28px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}
.buylo-story-caption {
    color: #fff;
    font-size: 14px;
    line-height: 1.7;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
    max-height: 110px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.buylo-story-caption::-webkit-scrollbar { width: 4px; }
.buylo-story-caption::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 4px; }

.buylo-story-cta {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: #111827;
    font-weight: 700;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 999px;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    transition: transform .15s;
    cursor: pointer;
    border: none;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}
.buylo-story-cta:hover { transform: translateY(-2px); color: #111827; }
.buylo-story-cta svg { width: 16px; height: 16px; flex-shrink: 0; }

/* پخش/مکث نشانگر وسط */
.buylo-story-play-ind {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(.7);
    width: 80px;
    height: 80px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .25s;
}
.buylo-story-modal.buylo-paused .buylo-story-play-ind {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.buylo-story-play-ind svg { width: 34px; height: 34px; }

/* دکمه صدا */
.buylo-story-mute {
    position: absolute;
    bottom: 96px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    color: #fff;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    backdrop-filter: blur(6px);
    transition: background .2s;
}
.buylo-story-mute:hover { background: rgba(0,0,0,0.6); }
.buylo-story-mute svg { width: 18px; height: 18px; }

/* انیمیشن ورود اسلاید */
.buylo-story-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity .22s ease, transform .22s ease;
    will-change: opacity, transform;
}
.buylo-story-slide.buylo-slide--active {
    opacity: 1;
    transform: translateX(0);
}
.buylo-story-slide.buylo-slide--prev {
    transform: translateX(-30px);
}

