/* =========================================
   MyStories - نسخه 2.1
   ========================================= */

.mystories-bar-wrapper {
    background: #fff;
    border-bottom: 1px solid #e6e6e6;
    padding: 12px 0;
    margin-bottom: 15px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.mystories-bar {
    display: flex;
    gap: 14px;
    padding: 0 12px;
    align-items: center;
}

.story-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 72px;
    text-decoration: none !important;
    color: inherit !important;
}

.story-avatar {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.story-avatar.seen {
    border: 2px solid #dbdbdb;
}

.story-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #fff;
    box-sizing: border-box;
}

.story-avatar.add {
    border: 2px dashed #aaa;
    background: #f5f5f5;
    font-size: 28px;
    color: #777;
    font-weight: bold;
}

.story-rings {
    width: 66px;
    height: 66px;
    position: relative;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-ring {
    border-radius: 50%;
    padding: 2.5px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.story-ring.global {
    background: linear-gradient(45deg, #7b2cbf, #9d4edd, #c77dff);
}

.story-ring.friends {
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}

.story-ring.close-friends {
    background: linear-gradient(45deg, #00c853, #64dd17, #aeea00);
}

.story-avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #fff;
    box-sizing: border-box;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-avatar-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.story-username {
    font-size: 11px;
    margin-top: 5px;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    color: #262626;
}

/* ---------- ویوئر ---------- */
.story-viewer-body {
    margin: 0;
    padding: 0;
    background: #000;
    overflow: hidden;
    font-family: Tahoma, Arial, sans-serif;
    height: 100vh;
    direction: ltr;
}

.story-viewer {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    direction: ltr;
}

.story-progress {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    flex-direction: row;
    gap: 3px;
    z-index: 30;
    direction: ltr;
}

.story-progress span {
    flex: 1;
    height: 2.5px;
    background: rgba(255,255,255,0.35);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.story-progress span i {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #fff;
    width: 0%;
}

.story-progress span.seen i {
    width: 100% !important;
    animation: none !important;
}

.story-progress span.active i {
    animation: progressAnim 20s linear forwards;
}

@keyframes progressAnim {
    from { width: 0%; }
    to { width: 100%; }
}

.story-header {
    position: absolute;
    top: 18px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 40;
    color: #fff;
    direction: ltr;
}

.story-header .username-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.story-header .username {
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.privacy-badge {
    font-size: 11px;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 12px;
    color: #fff;
    text-shadow: none;
    letter-spacing: 0.3px;
    display: none;
}

.privacy-badge.global {
    background: linear-gradient(45deg, #7b2cbf, #9d4edd);
}

.privacy-badge.friends {
    background: linear-gradient(45deg, #e6683c, #dc2743, #bc1888);
}

.privacy-badge.close-friends {
    background: linear-gradient(45deg, #00c853, #64dd17);
}

.close-viewer {
    color: #fff;
    font-size: 28px;
    text-decoration: none;
    line-height: 1;
    padding: 4px;
    z-index: 50;
}

.story-content {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 1;
}

.story-slide {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
    align-items: center;
    justify-content: center;
}

.story-slide.active {
    display: flex;
}

/* کادر ثابت 9:16 */
.story-media-916 {
    width: min(100vw, calc(100vh * 9 / 16));
    aspect-ratio: 9 / 16;
    height: auto;
    max-height: 100vh;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    background: #000;
}

.story-media-916 img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    max-width: none !important;
    max-height: none !important;
    display: block;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.story-nav {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40%;
    z-index: 20;
}

.story-nav.prev { left: 0; }
.story-nav.next { right: 0; }

.delete-story {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(220, 50, 50, 0.85);
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    text-decoration: none;
    z-index: 50;
}

/* لایک */
.story-like-btn {
    position: fixed !important;
    bottom: 28px !important;
    right: 18px !important;
    z-index: 2147483000 !important;
    pointer-events: auto !important;
    background: rgba(0, 0, 0, 0.45);
    border: none;
    border-radius: 50%;
    width: 58px;
    height: 58px;
    color: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.story-like-btn .like-icon {
    display: block;
    font-size: 30px;
    line-height: 1;
    transition: transform 0.2s ease, color 0.2s ease;
}

.story-like-btn .like-count {
    font-size: 11px;
    font-weight: bold;
    margin-top: 1px;
    min-height: 12px;
}

.story-like-btn.liked {
    background: rgba(255, 45, 85, 0.3);
}

.story-like-btn.liked .like-icon {
    color: #ff2d55;
}

.story-like-btn.anim-like .like-icon {
    animation: heartPop 0.45s cubic-bezier(0.17, 0.89, 0.32, 1.4);
    color: #ff2d55;
}

.story-like-btn.anim-unlike .like-icon {
    animation: heartShrink 0.35s ease;
}

@keyframes heartPop {
    0% { transform: scale(1); }
    25% { transform: scale(0.75); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

@keyframes heartShrink {
    0% { transform: scale(1.2); color: #ff2d55; }
    100% { transform: scale(1); color: #fff; }
}

.viewers-btn {
    position: absolute;
    bottom: 28px;
    right: 18px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    padding: 10px 16px;
    border-radius: 22px;
    font-size: 13px;
    cursor: pointer;
    z-index: 50;
}

.viewers-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 50%;
    background: #1a1a1a;
    border-radius: 16px 16px 0 0;
    z-index: 60;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.viewers-header {
    padding: 14px 16px;
    font-weight: bold;
    color: #fff;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.viewers-header span {
    font-size: 22px;
    cursor: pointer;
}

.viewers-list {
    overflow-y: auto;
    padding: 8px 12px 16px;
    color: #ddd;
    font-size: 14px;
}

.viewer-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 6px;
    border-bottom: 1px solid #2a2a2a;
    direction: ltr;
    text-align: left;
}

.viewer-item img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.viewer-name {
    flex: 1;
    text-align: left;
    color: #eee;
    font-size: 14px;
}

.viewer-liked {
    color: #ff2d55;
    font-size: 18px;
    flex-shrink: 0;
    margin-left: 8px;
}

.viewer-item.is-liked {
    background: rgba(255, 45, 85, 0.08);
    border-radius: 8px;
}

.story-time {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    white-space: nowrap;
    direction: rtl;
    unicode-bidi: embed;
}

/* ---------- صفحه ساخت استوری ---------- */
.ms-composer {
    max-width: 480px;
    margin: 20px auto;
    padding: 16px;
    box-sizing: border-box;
}

.ms-composer-title {
    text-align: center;
    margin: 0 0 16px;
    font-size: 18px;
}

.ms-hidden { display: none !important; }

.ms-pick-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 2px dashed #aaa;
    border-radius: 16px;
    padding: 40px 16px;
    cursor: pointer;
    background: #fafafa;
    color: #444;
    font-size: 15px;
}

.ms-pick-icon {
    font-size: 36px;
    line-height: 1;
    color: #1a73e8;
}

#story_image {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.ms-hint {
    font-size: 12px;
    color: #777;
    text-align: center;
    margin: 10px 0 0;
}

.ms-preview-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.ms-preview-frame {
    width: min(100%, 320px);
    aspect-ratio: 9 / 16;
    background: #111;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    touch-action: none;
    cursor: grab;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.ms-preview-frame:active { cursor: grabbing; }

.ms-preview-frame img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: none;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.ms-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 12px 0 4px;
    flex-wrap: wrap;
}

.ms-tool-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #eee;
    color: #222;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.ms-tool-btn:active {
    background: #ddd;
    transform: scale(0.96);
}

.ms-toolbar input[type=range] {
    width: 120px;
    max-width: 40vw;
}

.ms-privacy-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 16px 0;
    justify-content: center;
}

.ms-privacy-row select {
    padding: 8px 12px;
    min-width: 180px;
}

.ms-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.ms-btn-secondary {
    background: #eee !important;
    color: #333 !important;
}

@media (max-width: 480px) {
    .ms-composer { padding: 12px; margin: 10px auto; }
    .ms-preview-frame { width: min(100%, 280px); }
}