/* ==================== ریست و پایه ==================== */
* {
    box-sizing: border-box;
}

button.wp-story-close {
    position: absolute !important;
    background: transparent !important;
    color: white;
}

button.wp-story-prev {
    position: absolute!important;
    background: transparent !important;
}

button.wp-story-next {
    position: absolute!important;
    background: transparent !important;
}

/* ==================== هایلایت‌ها ==================== */
.wp-story-highlight {
    position: relative;
    display: inline-block;
    cursor: pointer;
    margin: 10px;
    text-align: center;
}

/* حلقه گرادیانت اینستاگرام */
.wp-story-highlight::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    z-index: 0;
}

.wp-story-avatar {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #fff;
    background: #fafafa;
    z-index: 1;
}

.wp-story-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.wp-story-title {
    font-size: 12px;
    margin-top: 6px;
    color: #262626;
    font-weight: 400;
    max-width: 74px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== مودال استوری - تمام صفحه ==================== */
.wp-story-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important; /* برای موبایل */
    z-index: 9999999999 !important;
    background: #000 !important;
    display: none;
    margin: 0 !important;
    padding: 0 !important;
}

.wp-story-modal-overlay {
    display: none;
}

.wp-story-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== کانتینر استوری ==================== */
.wp-story-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-story-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
}

.wp-story-item.active {
    display: flex;
}

.wp-story-item img,
.wp-story-item video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* ==================== نوار پیشرفت ==================== */
.wp-story-progress {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
    z-index: 100;
    direction: ltr;
}

.wp-story-progress-bar {
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 1px;
    overflow: hidden;
    direction: ltr;
}

.wp-story-progress-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    direction: ltr;
}

.wp-story-progress-bar.active .wp-story-progress-fill {
    animation: progressFill linear forwards;
}

.wp-story-progress-bar.completed .wp-story-progress-fill {
    width: 100%;
}

@keyframes progressFill {
    from { width: 0%; }
    to { width: 100%; }
}

/* ==================== دکمه بستن - بدون پس‌زمینه ==================== */
.wp-story-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-weight: 300;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
    transition: opacity 0.2s;
}

.wp-story-close:hover {
    opacity: 0.7;
}

/* ==================== فلش‌های ناوبری - Overlay مثل ویدیو پلیر ==================== */
.wp-story-prev,
.wp-story-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.wp-story-modal-content:hover .wp-story-prev,
.wp-story-modal-content:hover .wp-story-next {
    opacity: 1;
}

.wp-story-prev:hover,
.wp-story-next:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.wp-story-prev:active,
.wp-story-next:active {
    transform: translateY(-50%) scale(0.95);
}

.wp-story-prev {
    left: 24px;
}

.wp-story-next {
    right: 24px;
}

.wp-story-prev svg,
.wp-story-next svg {
    width: 28px;
    height: 28px;
}

/* ==================== دکمه مشاهده ==================== */
.wp-story-cta {
    position: absolute;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    color: #000;
    padding: 10px 24px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    z-index: 100;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.wp-story-cta:hover {
    background: #fff;
}

/* ==================== موبایل ==================== */
@media (max-width: 768px) {
    .wp-story-modal {
        height: 100vh !important;
        height: 100dvh !important;
    }
    
    .wp-story-container {
        max-height: 100vh;
        max-height: 100dvh;
    }
    
    .wp-story-progress {
        top: 10px;
        left: 10px;
        right: 10px;
    }
    
    .wp-story-close {
        top: 14px;
        right: 14px;
        font-size: 28px;
        width: 32px;
        height: 32px;
    }
    
    /* مخفی کردن فلش‌ها در موبایل */
    .wp-story-prev,
    .wp-story-next {
        display: none !important;
    }
    
    .wp-story-cta {
        bottom: 40px;
        padding: 9px 20px;
        font-size: 13px;
    }
}

/* ==================== تبلت ==================== */
@media (min-width: 769px) and (max-width: 1024px) {
    .wp-story-modal-content {
        max-width: none;
        margin: 0 auto;
    }
    
    .wp-story-container {
        max-width: 500px;
        max-height: 100vh;
    }
    
    .wp-story-progress {
        left: 0;
        right: 0;
        max-width: 100%;
        padding: 0 12px;
    }
    
    .wp-story-close {
        right: 12px;
    }
    
    /* نمایش دکمه‌های overlay */
    .wp-story-prev,
    .wp-story-next {
        display: flex;
    }
    
    .wp-story-prev {
        left: 20px;
    }
    
    .wp-story-next {
        right: 20px;
    }
}

/* ==================== دسکتاپ ==================== */
@media (min-width: 1025px) {
    .wp-story-modal {
        background: rgba(0, 0, 0, 0.95) !important;
    }
    
    .wp-story-modal-content {
        max-width: none;
        margin: 0 auto;
    }
    
    .wp-story-container {
        max-width: 500px;
        max-height: 100vh;
    }
    
    .wp-story-progress {
        left: 0;
        right: 0;
        max-width: 100%;
        padding: 0 12px;
    }
    
    .wp-story-close {
        right: 12px;
    }
    
    /* نمایش دکمه‌های overlay با hover */
    .wp-story-prev,
    .wp-story-next {
        display: flex;
    }
}

/* ==================== صفحه‌نمایش بسیار بزرگ ==================== */
@media (min-width: 1400px) {
    .wp-story-modal-content {
        max-width: none;
    }
    
    .wp-story-container {
        max-width: 480px;
    }
}

/* ==================== بهینه‌سازی عملکرد ==================== */
.wp-story-item img,
.wp-story-item video {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.wp-story-progress-fill {
    will-change: width;
}

/* ==================== منع انتخاب ==================== */
.wp-story-modal,
.wp-story-modal * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -webkit-touch-callout: none;
}

.wp-story-cta {
    user-select: auto;
    -webkit-user-select: auto;
}

/* ==================== منع اسکرول body ==================== */
body.wp-story-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ==================== لودینگ ==================== */
.wp-story-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ==================== تاچ ایریا برای موبایل ==================== */
@media (max-width: 768px) {
    .wp-story-container {
        touch-action: pan-y;
    }
    
    .wp-story-item {
        cursor: pointer;
    }
}

/* ==================== رفع مشکلات Safari ==================== */
@supports (-webkit-touch-callout: none) {
    .wp-story-modal {
        height: -webkit-fill-available !important;
    }
    
    .wp-story-container {
        max-height: -webkit-fill-available;
    }
}

/* ==================== تنظیمات نوتیفیکیشن بار موبایل ==================== */
@media (max-width: 768px) {
    .wp-story-progress {
        top: env(safe-area-inset-top, 10px);
        top: max(env(safe-area-inset-top), 10px);
    }
    
    .wp-story-close {
        top: calc(env(safe-area-inset-top, 10px) + 4px);
        top: calc(max(env(safe-area-inset-top), 10px) + 4px);
    }
    
    .wp-story-cta {
        bottom: calc(env(safe-area-inset-bottom, 20px) + 20px);
        bottom: calc(max(env(safe-area-inset-bottom), 20px) + 20px);
    }
}

/* ==================== پنهان کردن اسکرول‌بار ==================== */
.wp-story-modal::-webkit-scrollbar {
    display: none;
}

.wp-story-modal {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ==================== اصلاح برای حالت افقی موبایل ==================== */
@media (max-width: 768px) and (orientation: landscape) {
    .wp-story-progress {
        top: 8px;
    }
    
    .wp-story-close {
        top: 10px;
    }
    
    .wp-story-cta {
        bottom: 20px;
        padding: 8px 18px;
        font-size: 12px;
    }
}