/* استایل لیست استوری‌ها - RTL */
.npn-stories-wrapper {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 10px 0;
    direction: rtl;
    -webkit-overflow-scrolling: touch;
}

.npn-story-item {
    cursor: pointer;
    text-align: center;
    min-width: 80px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.npn-story-item:hover {
    transform: scale(1.05);
}

.npn-story-item.watched .npn-story-thumb {
    border-color: #888;
    opacity: 0.7;
}

.npn-story-thumb {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto 8px;
    border: 3px solid #e1306c;
    padding: 0;
    /* background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); */
}

.npn-story-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #fff;
}

.npn-story-title {
    font-size: 12px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}

/* ============ پاپ‌آپ استوری ============ */
.npn-story-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.npn-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

/* کانتینر اصلی پاپ‌آپ */
.npn-popup-wrapper {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 550px;
    height: 85vh;
    z-index: 100000;
    direction: ltr;
}

/* محتوای استوری */
.npn-popup-content {
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    margin: 0 auto;
    max-width: 450px;
}

/* Progress bars */
.npn-progress-bars {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    gap: 4px;
    z-index: 10;
}

.npn-progress-bar {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.npn-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: #fff;
    border-radius: 2px;
}

.npn-progress-bar.active .npn-progress-bar-fill {
    transition: width 0.1s linear;
}

.npn-progress-bar.paused .npn-progress-bar-fill {
    transition: none !important;
}

.npn-progress-bar.completed .npn-progress-bar-fill {
    width: 100%;
    background: #fff;
    transition: none;
}

/* Header */
.npn-story-header {
    position: absolute;
    top: 25px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    z-index: 10;
}

.npn-story-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.npn-story-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
}

.npn-story-header-title {
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.npn-story-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.npn-story-time {
    font-size: 12px;
    opacity: 0.8;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.npn-video-time {
    font-size: 11px;
    opacity: 0.7;
    background: rgba(0,0,0,0.5);
    padding: 2px 8px;
    border-radius: 10px;
    color: #fff;
}

/* Close button */
.npn-popup-close {
    position: absolute;
    top: 60px;
    left: 15px;
    z-index: 100;
    background: rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.npn-popup-close:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.6);
    transform: scale(1.1);
}

.npn-popup-close:active {
    transform: scale(0.95);
}

/* Media */
.npn-story-media {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    position: relative;
}

.npn-story-image,
.npn-story-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Tap areas */
.npn-tap-area {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    z-index: 5;
    cursor: pointer;
}

.npn-tap-prev {
    left: 0;
}

.npn-tap-next {
    right: 0;
}

/* نشانگرهای فلش */
.npn-tap-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 6;
}

.npn-tap-indicator::after {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    border-top: 2px solid white;
    border-right: 2px solid white;
    position: absolute;
    top: 50%;
}

.npn-tap-prev .npn-tap-indicator {
    left: 15px;
}

.npn-tap-prev .npn-tap-indicator::after {
    left: 50%;
    top: 50%;
    transform: translate(-30%, -50%) rotate(-135deg);
}

.npn-tap-next .npn-tap-indicator {
    right: 15px;
}

.npn-tap-next .npn-tap-indicator::after {
    left: 50%;
    top: 50%;
    transform: translate(-70%, -50%) rotate(45deg);
}

.npn-story-media:hover .npn-tap-indicator,
.npn-story-media.show-indicators .npn-tap-indicator {
    opacity: 0.8;
}

/* Tap ripple */
.npn-tap-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: rippleEffect 0.5s ease-out;
    pointer-events: none;
    z-index: 4;
    width: 40px;
    height: 40px;
    margin-left: -20px;
    margin-top: -20px;
}

@keyframes rippleEffect {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

/* ============ دکمه‌های ناوبری - بیرون از کادر ============ */
.npn-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255,255,255,0.4);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    z-index: 100001;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.npn-nav-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255,255,255,0.7);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.npn-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

/* دکمه قبلی - سمت چپ کادر */
.npn-prev-btn {
    left: -60px;
}

/* دکمه بعدی - سمت راست کادر */
.npn-next-btn {
    right: -60px;
}

/* فلش‌های داخل دکمه‌ها */
.npn-prev-btn::before {
    content: '‹';
    font-size: 30px;
    line-height: 1;
    font-weight: bold;
}

.npn-next-btn::before {
    content: '›';
    font-size: 30px;
    line-height: 1;
    font-weight: bold;
}

/* Pause indicator */
.npn-pause-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 14px;
    background: rgba(0,0,0,0.7);
    padding: 10px 20px;
    border-radius: 25px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
    border: 1px solid rgba(255,255,255,0.3);
}

.npn-pause-indicator.visible {
    opacity: 1;
}

/* Loading spinner */
.npn-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
}

.npn-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* دکمه پخش/قطع صدا ویدیو */
.npn-video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 8;
    cursor: pointer;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.5);
    transition: all 0.2s;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.npn-video-play-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.8);
    transform: translate(-50%, -50%) scale(1.1);
}

.npn-video-play-btn svg {
    width: 28px;
    height: 28px;
}

/* ============ کنترل‌های ویدیو ============ */
.npn-video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 60%, transparent 100%);
    padding: 40px 15px 20px;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* نمایش کنترل‌ها موقع پخش ویدیو */
.npn-story-media.show-controls .npn-video-controls,
.npn-story-media:hover .npn-video-controls {
    opacity: 1;
}

/* Timeline */
.npn-video-timeline {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    overflow: visible;
}

.npn-video-timeline-fill {
    height: 100%;
    background: #e1306c;
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
    position: relative;
}

.npn-video-timeline-fill::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ردیف دکمه‌ها */
.npn-video-buttons {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.npn-video-buttons-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.npn-video-buttons-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* دکمه‌های ویدیو */
.npn-video-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.npn-video-btn:hover {
    opacity: 1;
}

.npn-video-btn svg {
    width: 22px;
    height: 22px;
    fill: white;
}

/* دکمه پخش/توقف */
.npn-btn-playpause {
    width: 36px;
    height: 36px;
}

.npn-btn-playpause svg {
    width: 26px;
    height: 26px;
}

/* زمان ویدیو */
.npn-video-current-time,
.npn-video-duration {
    font-size: 12px;
    color: #fff;
    opacity: 0.9;
    min-width: 40px;
    text-align: center;
}

.npn-video-time-separator {
    font-size: 12px;
    color: #fff;
    opacity: 0.7;
}

/* دکمه صدا */
.npn-btn-volume {
    width: 36px;
    height: 36px;
}

/* دکمه تمام‌صفحه */
.npn-btn-fullscreen {
    width: 36px;
    height: 36px;
}

/* مخفی کردن دکمه پخش وسط صفحه وقتی کنترل‌ها هست */
.npn-story-media.show-controls .npn-video-play-btn {
    opacity: 0;
    pointer-events: none;
}

/* تنظیمات responsive برای کنترل‌ها */
@media (max-width: 768px) {
    .npn-video-controls {
        padding: 35px 12px 15px;
        gap: 6px;
    }
    
    .npn-video-timeline {
        height: 3px;
    }
    
    .npn-video-timeline-fill::after {
        width: 10px;
        height: 10px;
        right: -5px;
    }
    
    .npn-video-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .npn-btn-playpause {
        width: 32px;
        height: 32px;
    }
    
    .npn-btn-playpause svg {
        width: 22px;
        height: 22px;
    }
    
    .npn-video-current-time,
    .npn-video-duration {
        font-size: 11px;
    }
}

/* ============ Responsive - موبایل ============ */
@media (max-width: 768px) {
    /* کانتینر اصلی با فاصله از بالا و پایین */
    .npn-popup-wrapper {
        position: fixed;
        top: 3vh; /* فاصله از بالا */
        left: 15px; /* فاصله از چپ */
        right: 15px; /* فاصله از راست */
        bottom: 3vh; /* فاصله از پایین */
        width: auto !important;
        max-width: none !important;
        height: auto !important;
        transform: none !important;
    }
    
    /* محتوای استوری - گرد شده با فاصله */
    .npn-popup-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        border-radius: 20px; /* گوشه‌های گرد */
        overflow: hidden;
    }
    
    /* overlay تیره در پس‌زمینه */
    .npn-popup-overlay {
        background: rgba(0, 0, 0, 0.9);
    }
    
    /* دکمه‌های ناوبری روی کادر */
    .npn-nav-btn {
        width: 36px;
        height: 36px;
        z-index: 100;
        background: rgba(0,0,0,0.4);
        border-color: rgba(255,255,255,0.3);
    }
    
    .npn-prev-btn {
        left: 5px;
    }
    
    .npn-next-btn {
        right: 5px;
    }
    
    /* دکمه بستن */
    .npn-popup-close {
        top: 55px;
        left: 10px;
        width: 32px;
        height: 32px;
        font-size: 20px;
        z-index: 101;
    }
    
    /* Progress bars */
    .npn-progress-bars {
        top: 12px;
        left: 12px;
        right: 12px;
    }
    
    /* Header */
    .npn-story-header {
        top: 22px;
        left: 12px;
        right: 12px;
    }
    
    /* Tap indicators کوچک‌تر */
    .npn-tap-indicator {
        width: 32px;
        height: 32px;
    }
    
    .npn-tap-indicator::after {
        width: 8px;
        height: 8px;
    }
    
    .npn-tap-prev .npn-tap-indicator {
        left: 10px;
    }
    
    .npn-tap-next .npn-tap-indicator {
        right: 10px;
    }
    
    /* دکمه ویدیو */
    .npn-video-play-btn {
        width: 45px;
        height: 45px;
    }
    
    .npn-video-play-btn svg {
        width: 24px;
        height: 24px;
    }
}

/* موبایل‌های خیلی کوچک */
@media (max-width: 380px) {
    .npn-popup-wrapper {
        top: 2vh;
        left: 8px;
        right: 8px;
        bottom: 2vh;
    }
    
    .npn-popup-content {
        border-radius: 16px;
    }
    
    .npn-nav-btn {
        width: 32px;
        height: 32px;
    }
    
    .npn-prev-btn {
        left: 3px;
    }
    
    .npn-next-btn {
        right: 3px;
    }
}

/* تبلت - landscape */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
    .npn-popup-wrapper {
        height: 90vh;
    }
    
    .npn-popup-content {
        max-width: 400px;
    }
}

/* دسکتاپ - دکمه‌ها بیرون */
@media (min-width: 769px) {
    .npn-prev-btn {
        left: -55px;
    }
    
    .npn-next-btn {
        right: -55px;
    }
}