/* ============================================================
   Seniore Free Shipping Bar - v4
   - Wrapper (sticky) نوار را نگه می‌دارد
   - دایره مستقل (fixed)
   - انیمیشن swap: کادر بالا می‌رود، دایره پایین می‌آید
   ============================================================ */

:root {
    --sen-primary: #0f172a;
    --sen-primary-2: #f97316;
}

/* ==================== Wrapper (sticky) ==================== */

#sen-fsb-wrapper {
    position: sticky !important;
    top: 0 !important;
    left: 0;
    right: 0;
    z-index: 99990 !important;
    max-height: 250px;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Shabnam', Tahoma, sans-serif !important;
}

#sen-fsb-wrapper.sen-fsb-position-bottom {
    top: auto !important;
    bottom: 0 !important;
}

/* جمع‌شده: max-height → 0 */
#sen-fsb-wrapper.sen-fsb-collapsed {
    max-height: 0 !important;
}

/* مخفی: display: none */
#sen-fsb-wrapper.sen-fsb-hidden {
    display: none !important;
}

/* ==================== Bar (داخل wrapper) ==================== */

#sen-fsb-bar {
    background: linear-gradient(135deg, var(--sen-primary), #1e293b) !important;
    color: #fff !important;
    border-bottom: 3px solid var(--sen-primary-2);
    box-shadow: 0 8px 30px -8px rgba(0, 0, 0, 0.4) !important;
    transform: translateY(0);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    opacity: 1;
    direction: rtl !important;
    box-sizing: border-box !important;
    line-height: 1.5 !important;
}

#sen-fsb-wrapper.sen-fsb-position-bottom #sen-fsb-bar {
    border-bottom: none;
    border-top: 3px solid var(--sen-primary-2);
    box-shadow: 0 -8px 30px -8px rgba(0, 0, 0, 0.4) !important;
    transform: translateY(0);
}

/* جمع‌شده: نوار بالا می‌رود */
#sen-fsb-wrapper.sen-fsb-collapsed #sen-fsb-bar {
    transform: translateY(-100%);
    opacity: 0;
}

#sen-fsb-wrapper.sen-fsb-position-bottom.sen-fsb-collapsed #sen-fsb-bar {
    transform: translateY(100%);
}

/* محتوای داخلی */
#sen-fsb-bar .sen-fsb-inner {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 56px 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-sizing: border-box;
}

/* ==================== دکمه بستن ==================== */

#sen-fsb-bar .sen-fsb-close,
#sen-fsb-bar #sen-fsb-close {
    position: absolute !important;
    top: 50% !important;
    left: 12px !important;
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
    transform: translateY(-50%) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: none !important;
    background: rgba(255, 255, 255, 0.12) !important;
    color: #fff !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    transition: background .2s, transform .2s !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 0 !important;
    line-height: 1 !important;
    box-shadow: none !important;
    text-align: center !important;
    font-weight: 400 !important;
    text-transform: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    outline: none !important;
    pointer-events: auto !important;
    z-index: 99991 !important;
}

#sen-fsb-bar .sen-fsb-close:hover,
#sen-fsb-bar #sen-fsb-close:hover {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: translateY(-50%) rotate(90deg) !important;
    color: #fff !important;
    border: none !important;
}

#sen-fsb-bar .sen-fsb-close svg {
    width: 18px !important;
    height: 18px !important;
    display: block !important;
    pointer-events: none !important;
}

/* ==================== لیست محصولات (اسکرول افقی) ==================== */

.sen-fsb-products {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--sen-primary-2) transparent;
    padding: 4px 2px;
    flex-shrink: 0;
    max-width: 220px;
    -webkit-overflow-scrolling: touch;
}

.sen-fsb-products::-webkit-scrollbar {
    height: 4px;
}
.sen-fsb-products::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}
.sen-fsb-products::-webkit-scrollbar-thumb {
    background: var(--sen-primary-2);
    border-radius: 2px;
}

.sen-fsb-product-thumb {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--sen-primary-2);
    background: #fff;
}

.sen-fsb-product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sen-fsb-qty-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--sen-primary-2);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--sen-primary);
    line-height: 1;
}

/* ==================== بخش پیشرفت ==================== */

.sen-fsb-progress-wrap {
    flex: 1;
    min-width: 0;
}

.sen-fsb-message {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.sen-fsb-message .sen-fsb-count-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(249, 115, 22, 0.2);
    border: 1px solid rgba(249, 115, 22, 0.4);
    border-radius: 50px;
    font-size: 11px;
    color: var(--sen-primary-2);
    font-weight: 700;
}

.sen-fsb-bar-track {
    position: relative;
    height: 14px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.sen-fsb-bar-fill {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--sen-primary-2), #ea580c, #fbbf24);
    border-radius: 8px;
    transition: width .6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 12px rgba(249, 115, 22, 0.5);
    overflow: hidden;
}

.sen-fsb-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0) 80%, transparent 100%);
    animation: sen-fsb-shimmer 2.2s linear infinite;
}

@keyframes sen-fsb-shimmer {
    0%   { left: -100%; }
    100% { left: 100%; }
}

.sen-fsb-bar-icon {
    position: absolute;
    top: 50%;
    transform: translate(50%, -50%);
    font-size: 11px;
    line-height: 1;
    transition: right .6s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    z-index: 2;
    right: 0;
}

.sen-fsb-amounts {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

.sen-fsb-amounts .sen-fsb-amount-current {
    color: var(--sen-primary-2);
    font-weight: 700;
}

/* ==================== بخش ارسال رایگان ==================== */

.sen-fsb-unlocked-wrap {
    flex: 1;
    min-width: 0;
}

.sen-fsb-unlocked-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(249, 115, 22, 0.2));
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: 12px;
    padding: 10px 16px;
    animation: sen-fsb-celebrate .6s ease;
}

@keyframes sen-fsb-celebrate {
    0%   { transform: scale(0.9); opacity: 0; }
    60%  { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.sen-fsb-unlocked-emoji {
    font-size: 22px;
    animation: sen-fsb-bounce 1.4s ease-in-out infinite;
}

@keyframes sen-fsb-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

.sen-fsb-unlocked-text {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    line-height: 1.5;
}

/* ============================================================
   دایره جمع‌شده (مستقل، fixed)
   - دسکتاپ: بالا چپ
   - موبایل: بالا راست، کوچکتر، کمی پایین‌تر
   انیمیشن: از بالا پایین می‌آید (translateY از -150% به 0)
   ============================================================ */

#sen-fsb-collapsed-btn {
    position: fixed !important;
    top: 16px;
    left: 16px;
    width: 56px;
    height: 56px;
    border: none !important;
    background: linear-gradient(135deg, var(--sen-primary), #1e293b) !important;
    color: #fff !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 24px !important;
    line-height: 1 !important;
    box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.5) !important;
    transition: transform .5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity .4s ease !important;
    padding: 0 !important;
    margin: 0 !important;
    font-weight: 400 !important;
    text-transform: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    outline: none !important;
    z-index: 99991 !important;
    transform: translateY(-150%);
    opacity: 0;
    pointer-events: none;
}

/* نمایش: از بالا پایین می‌آید */
#sen-fsb-collapsed-btn.sen-fsb-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#sen-fsb-collapsed-btn:hover {
    transform: translateY(0) scale(1.08) !important;
}

#sen-fsb-collapsed-btn:active {
    transform: translateY(0) scale(0.95) !important;
}

/* حلقه‌های پالس */
#sen-fsb-collapsed-btn::before,
#sen-fsb-collapsed-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--sen-primary-2);
    animation: sen-fsb-pulse 2s ease-out infinite;
    pointer-events: none;
}

#sen-fsb-collapsed-btn::after {
    animation-delay: 1s;
}

@keyframes sen-fsb-pulse {
    0%   { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.6); opacity: 0; }
}

.sen-fsb-collapsed-icon {
    line-height: 1;
    pointer-events: none;
}

/* نشانگر تعداد روی دایره */
.sen-fsb-collapsed-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: var(--sen-primary-2);
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    line-height: 1;
    z-index: 2;
}

/* موقعیت پایین */
#sen-fsb-collapsed-btn.sen-fsb-position-bottom {
    top: auto;
    bottom: 16px;
    transform: translateY(150%);
}

#sen-fsb-collapsed-btn.sen-fsb-position-bottom.sen-fsb-visible {
    transform: translateY(0);
}

/* ============================================================
   ریسپانسیو - موبایل فرست
   ============================================================ */

@media (max-width: 768px) {
    #sen-fsb-bar .sen-fsb-inner {
        padding: 10px 48px 10px 12px;
        gap: 12px;
    }

    .sen-fsb-products {
        max-width: 170px;
    }

    .sen-fsb-product-thumb {
        width: 36px;
        height: 36px;
    }

    .sen-fsb-message {
        font-size: 12px;
    }

    .sen-fsb-unlocked-content {
        padding: 8px 12px;
    }

    .sen-fsb-unlocked-text {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    /* دایره: بالا راست، کوچکتر، ۳۰px از بالا */
    #sen-fsb-collapsed-btn {
        right: 12px !important;
        left: auto !important;
        top: 75px !important;
        width: 44px !important;
        height: 44px !important;
        font-size: 20px !important;
    }

    #sen-fsb-collapsed-btn.sen-fsb-position-bottom {
        top: auto !important;
        bottom: 30px !important;
    }

    /* عرض محتوا بیشتر */
    #sen-fsb-bar .sen-fsb-inner {
        padding: 10px 36px 10px 8px;
        gap: 10px;
        flex-direction: column;
        align-items: stretch;
    }

    /* محصولات: عرض کامل */
    .sen-fsb-products {
        max-width: 100%;
        padding: 4px 0;
    }

    .sen-fsb-product-thumb {
        width: 36px;
        height: 36px;
    }

    .sen-fsb-message {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .sen-fsb-bar-track {
        height: 12px;
    }

    .sen-fsb-amounts {
        font-size: 10px;
    }

    .sen-fsb-unlocked-content {
        padding: 8px 12px;
        justify-content: center;
    }

    .sen-fsb-unlocked-emoji {
        font-size: 20px;
    }

    .sen-fsb-unlocked-text {
        font-size: 12px;
    }

    #sen-fsb-bar .sen-fsb-close,
    #sen-fsb-bar #sen-fsb-close {
        width: 26px !important;
        height: 26px !important;
        min-width: 26px !important;
        max-width: 26px !important;
        left: 6px !important;
    }
}

@media (max-width: 360px) {
    #sen-fsb-bar .sen-fsb-inner {
        padding: 8px 32px 8px 6px;
    }

    .sen-fsb-product-thumb {
        width: 32px;
        height: 32px;
    }

    .sen-fsb-message {
        font-size: 11px;
    }

    .sen-fsb-products {
        gap: 6px;
    }
}

@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
    #sen-fsb-bar .sen-fsb-inner {
        padding: 8px 48px 8px 12px;
        flex-direction: row;
        align-items: center;
    }

    .sen-fsb-products {
        max-width: 120px;
    }

    .sen-fsb-product-thumb {
        width: 32px;
        height: 32px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
