/* ============================================
   Stories CSS - استایل استوری‌ها (نسخه نهایی)
   گلسرای پارسا
============================================ */

/* ============================================
   ۱) نوار استوری
============================================ */
.stories-wrapper {
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
    border-bottom: 1px solid rgba(34, 197, 94, 0.1);
    padding: 16px 0;
    margin-bottom: 20px;
    position: relative;
    z-index: 10;
}

.stories-bar {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 4px 4px 12px 4px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #22c55e transparent;
}

.stories-bar::-webkit-scrollbar { height: 4px; }
.stories-bar::-webkit-scrollbar-track { background: transparent; }
.stories-bar::-webkit-scrollbar-thumb { background: #22c55e; border-radius: 10px; }
.stories-bar::-webkit-scrollbar-thumb:hover { background: #16a34a; }

/* ============================================
   ۲) آیتم استوری
============================================ */
.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.3s ease;
    width: 84px;
    position: relative;
}

.story-item:hover { transform: translateY(-4px); }
.story-item:active { transform: translateY(-1px) scale(0.98); }

/* ============================================
   ۳) دایره استوری
============================================ */
.story-circle {
    position: relative;
    width: 74px;
    height: 74px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg, #22c55e, #16a34a, #15803d);
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.25);
    flex-shrink: 0;
}

.story-item:hover .story-circle {
    background: linear-gradient(135deg, #16a34a, #15803d, #14532d);
    box-shadow: 0 8px 22px rgba(34, 197, 94, 0.45);
    transform: scale(1.05);
}

.story-item.seen .story-circle {
    background: #cbd5e1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.story-item.seen:hover .story-circle {
    background: #94a3b8;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.story-item:not(.seen) .story-circle::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 2px solid #22c55e;
    animation: storyPulse 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes storyPulse {
    0% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.08); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

/* ============================================
   ۴) تصویر استوری در نوار
============================================ */
.story-image {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    background: #f1f5f9;
    display: block;
    transition: transform 0.3s ease;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
    pointer-events: none;
}

.story-item:hover .story-image { transform: scale(1.02); }

/* ============================================
   ۵) برچسب دسته‌بندی
============================================ */
.story-category-badge {
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.35);
    z-index: 3;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   ۶) عنوان استوری
============================================ */
.story-title {
    font-size: 11px;
    color: #475569;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    font-weight: 600;
    line-height: 1.4;
    padding: 0 4px;
}

.story-item.seen .story-title { color: #94a3b8; }
.story-item:hover .story-title { color: #16a34a; }
.story-item.seen:hover .story-title { color: #64748b; }

/* ============================================
   ۷) حالت خالی و لودینگ
============================================ */
.stories-empty {
    text-align: center;
    padding: 20px;
    color: #94a3b8;
    font-size: 13px;
    background: #f8fafc;
    border-radius: 12px;
    width: 100%;
}

.stories-loading { display: flex; gap: 16px; padding: 4px; }
.stories-loading .skeleton-item { width: 84px; flex-shrink: 0; text-align: center; }
.stories-loading .skeleton-circle {
    width: 74px; height: 74px; border-radius: 50%;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeletonLoad 1.5s ease-in-out infinite;
    margin: 0 auto 8px;
}
.stories-loading .skeleton-title {
    height: 10px; width: 70%;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeletonLoad 1.5s ease-in-out infinite;
    border-radius: 4px; margin: 0 auto;
}

@keyframes skeletonLoad {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   ۸) مودال استوری (overlay)
============================================ */
.story-viewer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.story-viewer-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ============================================
   ۹) کادر اصلی استوری (دسکتاپ)
============================================ */
.story-viewer {
    position: relative;
    width: auto;
    max-width: 95vw;
    height: auto;
    max-height: 95vh;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    animation: viewerZoomIn 0.3s ease;
}

@keyframes viewerZoomIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ============================================
   ۱۰) کادر تصویر
============================================ */
.story-viewer-image-wrap {
    position: relative;
    width: auto;
    height: auto;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

/* ============================================
   ۱۱) تصویر استوری در مودال (دسکتاپ)
============================================ */
.story-viewer-image {
    width: auto;
    height: auto;
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
    object-position: center;
    display: block;
    background: #000;
    animation: storyImageFade 0.3s ease;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
    pointer-events: none;
}

@keyframes storyImageFade {
    from { opacity: 0; transform: scale(1.05); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================
   ۱۲) گرادیانت روی تصویر
============================================ */
.story-viewer-overlay-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.65) 0%,
        transparent 22%,
        transparent 65%,
        rgba(0, 0, 0, 0.85) 100%
    );
    pointer-events: none;
    z-index: 5;
}

/* ============================================
   ۱۳) نوار پیشرفت (بالاترین z-index)
============================================ */
.story-progress-container {
    position: absolute !important;
    top: 12px !important;
    left: 12px !important;
    right: 12px !important;
    display: flex !important;
    gap: 4px !important;
    z-index: 200 !important;
    pointer-events: none !important;
}

.story-progress-segment {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.story-progress-fill {
    height: 100%;
    width: 0%;
    background: #fff;
    border-radius: 3px;
    transition: width 0.1s linear;
}

.story-progress-segment.completed .story-progress-fill { width: 100%; }

/* ============================================
   ۱۴) دکمه بستن
============================================ */
.story-viewer-close {
    position: absolute;
    top: 22px;
    right: 16px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    z-index: 200;
    transition: all 0.3s;
    border: none;
    backdrop-filter: blur(10px);
}

.story-viewer-close:hover {
    background: #ef4444;
    transform: rotate(90deg) scale(1.1);
}

/* ============================================
   ۱۵) هدر استوری
============================================ */
.story-viewer-header {
    position: absolute;
    top: 30px;
    left: 16px;
    right: 60px;
    color: #fff;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.story-viewer-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.story-viewer-header-info { flex: 1; min-width: 0; }

.story-viewer-title {
    font-size: 14px;
    font-weight: 700;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.story-viewer-category {
    display: inline-block;
    background: rgba(34, 197, 94, 0.9);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    margin-top: 3px;
    backdrop-filter: blur(10px);
}

/* ============================================
   ۱۶) دکمه CTA زیر تصویر
============================================ */
.story-cta-below {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 20px 22px;
    z-index: 200;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    display: flex;
    justify-content: center;
    pointer-events: auto;
}

.story-cta-below .story-viewer-cta {
    max-width: 360px;
    margin: 0 auto;
}

.story-viewer-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    text-decoration: none;
    text-align: center;
    border-radius: 30px;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 8px 20px rgba(34, 197, 94, 0.4);
    transition: all 0.3s;
    border: none;
    cursor: pointer;
}

.story-viewer-cta:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(34, 197, 94, 0.55);
}

/* ============================================
   ۱۷) نواحی ناوبری
============================================ */
.story-nav-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30%;
    z-index: 150;
    cursor: pointer;
    background: transparent;
    border: none;
    transition: background 0.3s;
}

.story-nav-zone:hover { background: rgba(255, 255, 255, 0.03); }
.story-nav-zone.prev { right: 0; }
.story-nav-zone.next { left: 0; }

.story-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    z-index: 200;
    border: none;
    backdrop-filter: blur(10px);
    transition: all 0.3s;
    opacity: 0;
}

.story-viewer:hover .story-nav-arrow { opacity: 1; }

.story-nav-arrow:hover {
    background: rgba(34, 197, 94, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.story-nav-arrow.prev-arrow { right: 12px; }
.story-nav-arrow.next-arrow { left: 12px; }

/* ============================================
   ۱۸) ✅ موبایل: به اندازه تصویر، نه تمام صفحه
============================================ */
@media (max-width: 600px) {
    /* کادر اصلی: به اندازه تصویر */
    .story-viewer {
        width: auto;
        height: auto;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    /* کادر تصویر: به اندازه تصویر */
    .story-viewer-image-wrap {
        width: auto;
        height: auto;
        max-width: 100vw;
        max-height: 100vh;
    }

    /* ✅ تصویر: اندازه واقعی، بدون کشیدگی */
    .story-viewer-image {
        width: auto;
        height: auto;
        max-width: 100vw;
        max-height: 100vh;
        object-fit: contain;
        object-position: center;
    }

    .story-progress-container {
        top: 10px !important;
        left: 10px !important;
        right: 10px !important;
        z-index: 300 !important;
    }

    .story-viewer-close {
        top: 18px;
        right: 12px;
        z-index: 300;
    }

    .story-viewer-header {
        top: 26px;
        left: 12px;
        right: 56px;
        z-index: 300;
    }

    .story-cta-below {
        padding: 12px 14px 18px;
        z-index: 300;
    }

    .story-viewer-cta {
        padding: 12px 16px;
        font-size: 13px;
    }

    .story-nav-arrow { display: none; }
}

/* ============================================
   ۱۹) Responsive نوار استوری
============================================ */
@media (max-width: 768px) {
    .stories-wrapper { padding: 12px 0; margin-bottom: 15px; }
    .stories-bar { gap: 12px; padding: 4px 4px 10px 4px; }
    .story-item { width: 70px; }
    .story-circle { width: 64px; height: 64px; padding: 2.5px; }
    .story-image { border-width: 2.5px; }
    .story-title { font-size: 10px; }
    .story-category-badge { font-size: 8px; padding: 1.5px 6px; max-width: 60px; }
    .stories-loading .skeleton-item { width: 70px; }
    .stories-loading .skeleton-circle { width: 64px; height: 64px; }
}

@media (max-width: 480px) {
    .stories-wrapper { padding: 10px 0; margin-bottom: 12px; }
    .stories-bar { gap: 10px; padding: 4px 4px 8px 4px; }
    .story-item { width: 62px; }
    .story-circle { width: 56px; height: 56px; padding: 2px; }
    .story-image { border-width: 2px; }
    .story-title { font-size: 9px; }
    .story-category-badge { font-size: 7px; padding: 1px 5px; border-width: 1.5px; max-width: 50px; }
    .stories-loading .skeleton-item { width: 62px; }
    .stories-loading .skeleton-circle { width: 56px; height: 56px; }
}

/* ============================================
   ۲۰) Accessibility
============================================ */
.story-item:focus,
.story-viewer-close:focus,
.story-viewer-cta:focus,
.story-nav-zone:focus {
    outline: 2px solid #22c55e;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .story-item,
    .story-circle,
    .story-image,
    .story-viewer,
    .story-viewer-image,
    .story-viewer-cta {
        animation: none !important;
        transition: none !important;
    }
    .story-item:not(.seen) .story-circle::after { animation: none; }
}