/* story/stories.css */
/* ماژول ردیف استوری‌ها */
.stories-module {
    padding: 9px 0;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
}
.stories-container {
    display: flex;
    gap: 12px;
    padding: 0 16px;
}

/* حذف هایلایت آبی هنگام کلیک روی نواحی ناوبری و دکمه‌ها */
.story-nav-left, 
.story-nav-right,
.story-viewer-mute,
.story-viewer-close,
.story-like-btn,
.story-comment-section button {
    -webkit-tap-highlight-color: transparent;  /* برای مرورگرهای موبایل (WebKit) */
    outline: none;                             /* حذف خط دور دکمه در دسکتاپ */
    user-select: none;                         /* جلوگیری از انتخاب متن در حین کلیک سریع */
}
.story-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    width: 70px;
}
.story-avatar {
    width: 71px;
    height: 71px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    border: 0;
    position: relative;
    isolation: isolate;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2), inset 0 0 0 1px rgba(255,255,255,.9);
}
.story-avatar::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 50%;
    background: conic-gradient(#ff8a00, #ff2d75, #7b4dff, #ff8a00);
    z-index: -1;
    pointer-events: none;
}
.story-username {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0px;
    font-size: 12px;
    color: #fff;
    text-align: center;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap; /* جلوگیری از شکستن خط */
}
.story-verified-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0; /* جلوگیری از فشرده شدن */
}
@media (max-width: 550px) {
    .story-avatar { width: 65px; height: 65px; }
    .story-item { width: 60px; }
}

/* نمایشگر استوری (overlay) */
.story-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
}
/* هدر اطلاعات کاربر و دکمه‌ها - پایین‌تر از نوارها */
.story-viewer-header {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    z-index: 10001;
    color: white;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
}
.story-viewer-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.story-viewer-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}
.story-time-ago {
    font-size: 11px;
    color: rgba(255,255,255,0.8);
    margin-top: 0px;
}
.story-viewer-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}
.story-viewer-mute, .story-viewer-close {
    background: rgba(0,0,0,0.0);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 22px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top:-5px;
}

.story-viewer-close{
    font-size:27px !important;
}

/* نوارهای پیشرفت - در بالاترین نقطه و بالای همه عناصر */
.story-viewer-progress-container {
    position: absolute;
    top: 5px;
    left: 7px;
    right: 7px;
    display: flex;
    gap: 3px;
    padding: 6px 8px;
    z-index: 10003;
}
.story-progress-bar {
    flex: 1;
    height: 3px;
    background: rgba(255,255,255,0.4);
    border-radius: 3px;
    overflow: hidden;
}
.story-progress-fill {
    width: 0%;
    height: 100%;
    background: white;
    transition: width linear;
}
.story-viewer-caption {
    position: absolute;
    bottom: 80px;
    left: 40px;
    right: 40px;
    display: flex;
    justify-content: center;
    z-index: 10001;
    pointer-events: none; /* اجازه عبور کلیک به لایه‌های زیرین */
}
.story-viewer-caption span {
    background: rgba(0,0,0,0.5);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    text-align: center;
    word-break: break-word;
    white-space: normal;
    max-width: 100%;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}
.story-viewer-caption span:empty {
    display: none;
}
.story-viewer-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
}
.story-viewer-content img, .story-viewer-content video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
/* فوتر – چسبیده به پایین، چپ و راست */
.story-viewer-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    z-index: 1000000001;
    background: rgba(0,0,0,0.6);
    padding: 12px 20px;
    backdrop-filter: blur(10px);
}
.story-like-section {
    display: flex;
    align-items: center;
    gap: 8px;
}
.story-like-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: white;
    transition: 0.1s;
}
.story-like-count {
    color: white;
    font-size: 16px;
    font-weight: bold;
}
.story-comment-section {
    flex: 1;
    display: flex;
    gap: 10px;
    align-items: center;
}
.story-comment-section input {
    flex: 1;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 40px;
    padding: 10px 18px;
    color: white;
    font-size: 14px;
}
.story-comment-section input::placeholder {
    color: #ccc;
}
.story-comment-section button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: white;
}
/* ناحیه ناوبری (وسط صفحه – فقط برای کلیک) */
.story-nav-area {
    position: absolute;
    top: 80px;
    bottom: 80px;
    width: 45%;
    z-index: 10000;
    cursor: pointer;
}
.story-nav-left {
    left: 0;
}
.story-nav-right {
    right: 0;
}

/* ========== پنل جزئیات ========== */
.stats-panel {
    position: absolute;
    bottom: 60px; /* ارتفاع فوتر */
    left: 7px;
    right: 7px;
    border:1px solid #ffffff4a;
    max-height: 50vh;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 20px 20px 0 0;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    overflow: hidden;
    padding-bottom:10px;
}
.stats-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-weight: bold;
    font-size: 16px;
    cursor: grab;
}
.stats-panel-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}
.stats-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 16px;
    color: white;
}
.stats-empty {
    text-align: center;
    padding: 20px;
    color: #aaa;
}
.stats-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.stats-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid white;
}
.stats-info {
    flex: 1;
}
.stats-name {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.stats-verified-icon {
    width: 16px;
    height: 16px;
}
.stats-time {
    font-size: 11px;
    color: #bbb;
    margin-top: 2px;
}
.stats-like-type {
    font-size: 18px;
}
.stats-comment-text {
    font-size: 12px;
    color: #ddd;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}
/* در story/stories.css اضافه شود */
.story-avatar.loading {
    position: relative;
    overflow: visible;
}
.story-avatar.loading::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 4px solid transparent;
    border-top-color: #e95e05;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    z-index: 2;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
/* حاشیه قهوه‌ای برای کاربران دیده شده */
.story-item.seen .story-avatar::before {
    background: #aab5bb;
}
/* دکمه‌های فوتر مالک */
.owner-footer {
    justify-content: space-around;
}
.footer-stat-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 30px;
    padding: 10px 16px;
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.story-item-placeholder {
    text-decoration: none; /* حذف زیرخط لینک */
    color: inherit;
}
/* استایل آیتم placeholder (کاربر جاری بدون استوری) */
.story-item-placeholder .story-avatar {
    border: none;
    position: relative;
    opacity: 0.8;
    color: inherit;
}
.story-item-placeholder .story-avatar::before {
    display: none;
}

.story-item .story-avatar {
    background-size: cover;
    background-position: center;
}
.story-avatar-plus {
    position: absolute;
    bottom: -2px;
    right: 5px;
    background: #0095f6;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid white;
}

/* ظرف دکمه لایک (برای موقعیت‌دهی نسبی پاپ‌آپ) */
.like-btn-container {
    position: relative;
    display: inline-block;
}
/* پاپ‌آپ واکنش‌ها */
.reaction-popup {
    display: none;
    position: absolute;
    bottom: 110%; /* بالای دکمه */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    border-radius: 30px;
    padding: 8px 12px;
    flex-direction: column;
    gap: 8px;
    z-index: 10002;
}
.reaction-popup .reaction-option {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.1s;
}
.reaction-popup .reaction-option:active {
    transform: scale(1.3);
}
@media (max-width: 550px) {
    .story-viewer-header { padding: 22px 15px; }
    .story-viewer-avatar { width: 39px; height: 39px; }
    .story-viewer-mute, .story-viewer-close { width: 32px; height: 32px; font-size: 16px; }
    .story-viewer-caption { bottom: 100px; font-size: 12px; }
    .story-viewer-footer { padding: 8px 15px; }
    .story-like-btn { font-size: 24px; }
    .story-comment-section button { font-size: 20px; }
    .story-nav-area { top: 70px; bottom: 70px; width: 50%; }
}
/* v1.0.50 - همگام‌سازی زنده و ترتیب قطعی استوری‌ها */
.stories-module:empty { display: none; }
.stories-container { min-height: 92px; align-items: flex-start; }
.story-item { flex: 0 0 auto; -webkit-tap-highlight-color: transparent; }
.story-item[role="button"]:focus-visible .story-avatar { outline: 2px solid #fff; outline-offset: 2px; }

/* v1.0.105 shared embedded viewer helpers */
.story-view-only-footer{justify-content:center!important}
.story-view-only-note{width:100%;text-align:center;color:rgba(255,255,255,.86);font-size:.78rem;padding:10px 14px}
html.bk-story-viewer-open,body.bk-story-viewer-open{overscroll-behavior:none}

/* v1.0.105: story box ring matches the thin chat avatar ring. */
.story-item:not(.story-item-placeholder) .story-avatar{
    padding:3px;
    background-origin:content-box;
    background-clip:content-box;
    background-color:#fff;
}
.story-item:not(.story-item-placeholder).seen .story-avatar{background-color:#fff}

/* v1.0.106: exactly one visible ring in the story box. */
.story-item .story-avatar{
    box-sizing:border-box!important;
    padding:2.5px!important;
    border:0!important;
    background-color:#fff!important;
    background-origin:content-box!important;
    background-clip:content-box!important;
    box-shadow:0 2px 8px rgba(0,0,0,.18)!important;
}
.story-item:not(.story-item-placeholder) .story-avatar::before{
    display:block!important;
    inset:0!important;
    z-index:-1!important;
    background:conic-gradient(#ff8a00,#ff2d75,#7b4dff,#ff8a00)!important;
}
.story-item:not(.story-item-placeholder).seen .story-avatar::before{background:#98a4aa!important}
.story-item-placeholder .story-avatar{background-color:#fff!important;padding:2.5px!important}
.story-item-placeholder .story-avatar::before{display:none!important}

/* v1.0.106 compact admin story controls. */
.story-admin-follow-state{display:inline-flex;align-items:center;justify-content:center;height:22px;padding:0 7px;border-radius:999px;font-size:9px;font-weight:800;white-space:nowrap;background:rgba(255,255,255,.15);color:#fff;border:1px solid rgba(255,255,255,.22)}
.story-admin-follow-state.is-followed{background:rgba(22,136,188,.85)}
.story-admin-follow-state.not-followed{background:rgba(126,88,38,.88)}
.story-admin-action-wrap{position:relative;display:flex;align-items:center}
.story-admin-action-btn{width:30px;height:30px;border:0;border-radius:50%;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.28);color:#fff;font-size:21px;line-height:1;cursor:pointer}
.story-admin-menu{display:none;position:absolute;top:35px;left:0;min-width:112px;padding:5px;background:rgba(15,25,31,.96);border:1px solid rgba(255,255,255,.18);border-radius:10px;box-shadow:0 10px 24px rgba(0,0,0,.35);z-index:10020}
.story-admin-menu.open{display:block}
.story-admin-menu button{width:100%;border:0;border-radius:7px;background:#bd3030;color:#fff;padding:8px 9px;font:inherit;font-size:11px;font-weight:800;cursor:pointer;white-space:nowrap}
@media(max-width:550px){.story-viewer-controls{gap:6px!important}.story-admin-follow-state{height:20px;padding:0 6px;font-size:8px}.story-admin-action-btn{width:28px;height:28px}}

/* v1.0.108: fast, reliable story avatars. Use a real image instead of CSS background. */
.story-item .story-avatar{
    display:grid!important;
    place-items:center!important;
    padding:2.5px!important;
    box-sizing:border-box!important;
    background:#fff!important;
    background-image:none!important;
    overflow:visible!important;
    isolation:isolate!important;
}
.story-item .story-avatar::before{display:none!important}
.story-item.has-story .story-avatar{
    background:conic-gradient(#ff8a00,#ff2d75,#7b4dff,#ff8a00)!important;
}
.story-item.has-story.seen .story-avatar{background:#98a4aa!important}
.story-item-placeholder .story-avatar{background:#fff!important}
.story-avatar-image{
    display:block!important;
    width:100%!important;
    height:100%!important;
    min-width:0!important;
    min-height:0!important;
    border:0!important;
    border-radius:50%!important;
    object-fit:cover!important;
    background:#edf3f5!important;
    box-sizing:border-box!important;
    position:relative!important;
    z-index:1!important;
}
.story-avatar-plus{z-index:3!important}
.story-avatar.loading::after{z-index:4!important;border-width:2px!important;inset:-3px!important}

/* v1.0.116: منوی مالک استوری و حالت توقف پخش */
.story-admin-action-btn{font-family:Arial,sans-serif;font-weight:900;padding:0 0 2px;user-select:none;-webkit-user-select:none}
.story-admin-action-btn[aria-expanded="true"]{background:rgba(255,255,255,.2)}
.story-admin-menu button:disabled{opacity:.65;cursor:wait}
