/* ============================================
   📸 STORIES SYSTEM - Instagram-like Design
   ============================================ */

/* === شريط الستوريات === */
#stories-container {
    display: flex;
    gap: 15px;
    padding: 25px 15px;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    margin-bottom: 30px;
    margin-top: 90px;
    scrollbar-width: none;
    /* إخفاء شريط التمرير الافتراضي */
}

#stories-container .empty-stories-msg {
    width: 100%;
    text-align: center;
    padding: 20px;
    color: var(--text);
    opacity: 0.4;
    font-style: italic;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#stories-container .empty-stories-msg i {
    font-size: 1.5rem;
}

#stories-container::-webkit-scrollbar {
    height: 6px;
}

#stories-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

/* === دائرة الستوري === */
.story-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

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

.story-avatar {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    background-size: 200% 200%;
    animation: gradientRotate 3s linear infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

@keyframes gradientRotate {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.story-circle.viewed .story-avatar {
    background: rgba(255, 255, 255, 0.3);
}

.story-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bg);
}

.story-username {
    font-size: 0.75rem;
    color: var(--text);
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* === زر إضافة ستوري === */
.add-story .story-avatar {
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed var(--primary);
}

.add-story-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg);
}

.add-story-icon i {
    font-size: 0.7rem;
    color: white;
}

/* === عارض الستوري (Story Viewer) === */
.story-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.story-viewer {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 90vh;
    background: #000;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

/* === رأس الستوري === */
.story-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
    z-index: 10;
}

.story-progress-bars {
    display: flex;
    gap: 4px;
    margin-bottom: 15px;
}

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

.progress-bar.completed {
    background: white;
}

.progress-bar.active {
    background: white;
    animation: progressFill 5s linear forwards;
}

@keyframes progressFill {
    from {
        width: 0%;
    }

    to {
        width: 100%;
    }
}

.story-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.story-user-info img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid white;
}

.story-user-info span {
    font-weight: bold;
    font-size: 0.9rem;
}

.story-time {
    opacity: 0.7;
    font-size: 0.8rem !important;
    font-weight: normal !important;
    margin-right: auto;
}

.story-close-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.story-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* === محتوى الستوري === */
.story-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.story-content img,
.story-content video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* === أزرار التنقل === */
.story-nav {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 15px;
    pointer-events: none;
}

.story-nav-btn {
    pointer-events: all;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.story-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* === زر الحذف === */
.story-delete-btn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 59, 48, 0.9);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
}

.story-delete-btn:hover {
    background: rgba(255, 59, 48, 1);
    transform: translateX(-50%) scale(1.05);
}

/* === منطقة رفع الستوري === */
.story-upload-area {
    text-align: center;
    padding: 30px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    margin: 20px 0;
}

.upload-preview {
    margin-bottom: 20px;
}

/* === زر الستوري في الهيدر (Desktop) === */
.story-btn-desktop {
    position: fixed;
    top: 18px;
    right: 180px;
    /* على اليمين بجانب الإشعارات */
    width: 55px;
    height: 55px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    /* سيتم إظهاره من JavaScript */
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    /* زيادة لتظهر فوق الشريط العلوي */
    padding: 0;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.story-btn-desktop:hover {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.7);
}

.story-btn-desktop:active {
    transform: scale(0.95);
}

.story-btn-desktop svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* === زر الستوري في الشريط السفلي (Mobile) === */
.story-nav-item {
    position: relative;
    flex: 0 0 auto !important;
}

.story-btn-mobile {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 5px solid var(--bg);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 -5px 25px rgba(102, 126, 234, 0.6), 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
}

.story-btn-mobile:hover {
    transform: translateX(-50%) scale(1.1) rotate(-10deg);
    box-shadow: 0 -8px 30px rgba(102, 126, 234, 0.8), 0 8px 20px rgba(0, 0, 0, 0.4);
}

.story-btn-mobile:active {
    transform: translateX(-50%) scale(0.95);
}

/* إخفاء زر Desktop على الهاتف */
@media (max-width: 768px) {
    .story-btn-desktop {
        display: none !important;
    }
}

/* إخفاء زر Mobile على الحاسوب */
@media (min-width: 769px) {
    .story-btn-mobile {
        display: none !important;
    }

    .story-btn-desktop {
        display: flex !important;
    }
}

/* === Responsive === */
@media (max-width: 768px) {
    .story-viewer {
        max-width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    .story-avatar {
        width: 60px;
        height: 60px;
    }

    .story-username {
        font-size: 0.7rem;
    }

    #stories-container {
        padding: 15px 10px;
        gap: 12px;
    }
}

/* === Animation === */
/* === بطاقة الرد على الستوري في الدردشة === */
.story-reply-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.story-reply-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border-color: var(--primary) !important;
}

.story-reply-card video,
.story-reply-card img {
    transition: transform 0.5s ease;
}

.story-reply-card:hover video,
.story-reply-card:hover img {
    transform: scale(1.1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}