/*!
 * Story Player Styles v3.0.0
 * Author: Amir Rezaie (https://amir-rezaie.ir)
 * License: MIT
 */

#stories-container {
    display: flex;
    gap: 15px;
    padding: 15px;
    overflow-x: auto;
}

#stories-container {
    overflow-x: auto;
    display: flex;
    gap: 1rem;
    padding: 1rem;
    cursor: grab;
    scroll-snap-type: none !important;
    user-select: none;
    -webkit-user-drag: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#stories-container img {
    -webkit-user-drag: none;
    user-select: none;
    pointer-events: none; /* جلوگیری از تداخل کلیک تصویر با درگ */
}

#stories-container:active {
    cursor: grabbing;
}

#stories-container::-webkit-scrollbar {
    height: 5px;
    display: none;
}

#stories-container:hover::-webkit-scrollbar {
    display: block;
}

#stories-container::-webkit-scrollbar-track {
    background: transparent;
}

#stories-container::-webkit-scrollbar-thumb {
    background: #10b981;
    border-radius: 10px;
}

.story {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

/* کادر رنگی استوری‌های دیده نشده */
.story-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    padding: 3px; /* کمی پدینگ بیشتر برای مشخص شدن کادر */
    background: linear-gradient(45deg, #ff6b6b, #ff3838); /* کادر رنگی فعال */
    transition: background 0.3s, opacity 0.3s;
}

/* کادر استوری‌های دیده شده + سیاه و سفید شدن تصویر داخل آن */
.story-avatar.viewed {
    /* تغییر گرادینت رنگی به یک پس‌زمینه خاکستری یکدست */
    background: #9ca3af !important;
    opacity: 0.6; /* کدر کردن ملایم کل آواتار */
}

/* افکت سیاه و سفید روی تگ img موجود در آواتار دیده شده */
.story-avatar.viewed img {
    filter: grayscale(100%); /* سیاه و سفید کردن عکس کاربر */
    border: 2px solid #fff; /* حفظ حاشیه سفید داخلی */
    transition: filter 0.3s;
}

.story-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
    transition: filter 0.3s;
}
.story-username {
    margin-top: 5px;
    font-size: 12px;
    color: #333;
    white-space: nowrap;
}

.story-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
}



.progress-fill {
    width: 0%;
    height: 100%;
    background: #4CAF50;
    border-radius: 2px;
    transition: width linear;
}


.story-media {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    display: none;
}

.video-media {
    display: none;
}





/* بک‌گراند کل صفحه که تیره باقی می‌ماند */
.story-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85); /* تاریک کردن پشت استوری */
    z-index: 1000;
}

/* باکس اصلی محتوای استوری: ۸۰٪ ابعاد و وسط‌چین شده */
.story-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* تکنیک تراز دقیق افقی و عمودی در مرکز */
    width: 80vw;  /* ۸۰ درصد عرض صفحه نمایش */
    height: 80vh; /* ۸۰ درصد ارتفاع صفحه نمایش */
    max-width: 600px; /* اختیاری: جلوگیری از پهن شدن بیش از حد در دسکتاپ */
    background: #000; /* پس‌زمینه مشکی داخلی برای باکس استوری */
    border-radius: 16px; /* گرد کردن لبه‌های باکس استوری */
    overflow: hidden; /* جلوگیری از بیرون زدن ویدیو یا عکس از لبه‌های گرد */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5); /* سایه ملایم دور استوری */
}

/* ظرف نگهدارنده تصویر و ویدیو */
.media-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* تنظیم دقیق ابعاد رسانه‌ها متناسب با باکس جدید */
.story-media, .video-media {
    width: 100%;
    height: 100%;
    object-fit: contain; /* حفظ نسبت ابعاد تصویر و ویدیو بدون دفرمه شدن */
    display: block;
}

/* --- تنظیم موقعیت المان‌های داخلی بر اساس باکس جدید ۸۰ درصدی --- */

.progress-container {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    z-index: 1003; /* قرارگیری روی همه المان‌ها */
}

.close-button {
    position: absolute;
    top: 25px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    z-index: 1004;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.close-button:hover { background: rgba(255, 255, 255, 0.4); }

.nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    z-index: 1004;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.nav-button:hover { background: rgba(255, 255, 255, 0.4); }

.prev-button { right: 15px; }
.next-button { left: 15px; }

.story-link {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    color: #111;
    font-weight: bold;
    padding: 8px 20px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 13px;
    z-index: 1004;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}







/* پانل تعاملی اصلی (لایک، کامنت و ویو) */
.story-interaction-panel {
    position: absolute;
    bottom: 20px;
    right: 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 1005;
    align-items: center;
}

/* استایل دکمه‌های لایک و کامنت */
.interaction-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.like-btn-story, .comment-toggle-btn {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    font-size: 18px;
}

.like-btn-story:hover, .comment-toggle-btn:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.7);
}

/* تعداد لایک زیر دکمه */
.like-count-num {
    font-size: 11px;
    margin-top: 2px;
    display: block;
    font-family: sans-serif;
}

/* رنگ قرمز برای لایک‌های فعال شده */
.text-danger {
    color: #ff3838 !important;
}

/* نشانگر تعداد بازدید در بالای استوری */
.story-stats-top {
    position: absolute;
    top: 25px;
    left: 20px;
    z-index: 1004;
}

.story-views-badge {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* باکس نظرات پیاده‌سازی شده روی استوری */
.story-comments-box {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 50%;
    background: rgba(20, 20, 20, 0.95);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    display: flex;
    flex-direction: column;
    z-index: 1006;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* لیست کامنت‌ها با قابلیت اسکرول */
.comments-list-container {
    flex-content: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 180px;
}

.story-comment-item {
    font-size: 13px;
    color: #ddd;
    line-height: 1.4;
    text-align: right;
    direction: rtl;
}

.story-comment-item strong {
    color: #fff;
    margin-left: 5px;
}

/* بخش ورودی کامنت جدید */
.comment-input-group {
    display: flex;
    padding: 10px;
    border-top: 1px solid #333;
    background: #111;
    direction: rtl;
}

.story-comment-input {
    flex: 1;
    background: #222;
    border: 1px solid #444;
    border-radius: 20px;
    padding: 8px 15px;
    color: white;
    font-size: 13px;
    outline: none;
}

.story-comment-submit {
    background: #10b981;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 0 15px;
    margin-right: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
}

.story-comment-submit:hover {
    background: #059669;
}
/* نمایش تعداد کامنت در زیر آیکون کامنت */
.comment-count-num {
    font-size: 11px;
    margin-top: 2px;
    display: block;
    font-family: sans-serif;
    color: white;
}

/* استایل کانتینر نگه‌دارنده پاسخ‌ها */
.story-replies-container {
    margin-top: 8px;
    padding-right: 12px;
    border-right: 2px solid #34d399; /* خط سبز برای متمایز کردن بخش پاسخ‌ها */
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.story-reply-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 4px 8px;
    border-radius: 6px;
}
