/* ===== تنسيق القصص (Stories) ===== */

/* حاوية القصص الرئيسية */
.stories-container {
    display: flex;
    gap: 15px;
    padding: 20px 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

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

.stories-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.stories-container::-webkit-scrollbar-thumb {
    background: #6c63ff;
    border-radius: 3px;
}

.stories-container::-webkit-scrollbar-thumb:hover {
    background: #5a52d5;
}

/* عنصر القصة الواحدة */
.story-item {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s ease;
    position: relative;
    min-width: 80px;
}

/* عداد القصص */
.stories-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(45deg, #ff6b6b, #ff8a80);
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    min-width: 22px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: pulse 2s infinite;
}

/* دعم RTL للعداد */
[dir="rtl"] .stories-count {
    right: auto;
    left: -5px;
}

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

/* صورة القصة */
.story-item img {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid transparent;
    background: linear-gradient(45deg, #ff6b6b, #6c63ff, #4ecdc4);
    padding: 3px;
    object-fit: cover;
    transition: all 0.3s ease;
}

.story-item:hover img {
    border-color: #ff6b6b;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.4);
}

/* اسم صاحب القصة */
.story-item span {
    margin-top: 8px;
    font-size: 12px;
    color: #333;
    text-align: center;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

/* مودال عرض القصة */
.story-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.story-modal.active {
    opacity: 1;
    visibility: visible;
}

/* محتوى المودال */
.story-content {
    position: relative;
    max-width: 400px;
    width: 90%;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* هيدر القصة */
.story-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #6c63ff 0%, #ff6b6b 100%);
    color: white;
}

.story-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    border: 2px solid white;
}

.story-header .story-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.story-header .story-info span {
    font-size: 12px;
    opacity: 0.9;
}

/* محتوى القصة */
.story-body {
    position: relative;
    min-height: 300px;
    max-height: 500px;
    overflow: hidden;
}

.story-body img,
.story-body video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* النص على القصة */
.story-text {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    padding: 30px 20px 20px;
    font-size: 14px;
    line-height: 1.4;
}

/* أزرار التحكم */
.story-controls {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
}

.story-nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.3s ease;
    backdrop-filter: blur(10px);
}

.story-nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* زر الإغلاق */
.story-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s ease;
    z-index: 10;
}

.story-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* شريط التقدم */
.story-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    width: 100%;
}

.story-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #6c63ff);
    width: 0%;
    transition: width 0.1s linear;
}

/* أزرار التفاعل */
.story-actions {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.story-action-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

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

.story-action-btn.liked {
    background: #ff6b6b;
    color: white;
}

/* التصميم المتجاوب */
@media (max-width: 768px) {
    .stories-container {
        gap: 10px;
        padding: 15px 0;
    }
    
    .story-item {
        min-width: 70px;
    }
    
    .story-item img {
        width: 60px;
        height: 60px;
    }
    
    .story-item span {
        font-size: 11px;
        max-width: 70px;
    }
    
    .story-content {
        width: 95%;
        max-width: 350px;
    }
    
    .story-header {
        padding: 12px 15px;
    }
    
    .story-header img {
        width: 35px;
        height: 35px;
        margin-right: 10px;
    }
    
    .story-header .story-info h4 {
        font-size: 14px;
    }
    
    .story-text {
        padding: 20px 15px 15px;
        font-size: 13px;
    }
}

/* حالة التحميل */
.story-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    background: #f8f9fa;
}

.story-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #6c63ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* تأثيرات خاصة */
.story-item.viewed img {
    border-color: #ccc;
    background: #f8f9fa;
}

.story-item.live::before {
    content: 'LIVE';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff4444;
    color: white;
    font-size: 8px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    animation: pulseWithTranslate 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes pulseWithTranslate {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.1); }
}

/* قسم القصص بدون محتوى */
.no-stories {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.no-stories i {
    font-size: 48px;
    margin-bottom: 15px;
    color: #dee2e6;
}

.no-stories h4 {
    margin-bottom: 10px;
    color: #495057;
}

.no-stories p {
    margin: 0;
    font-size: 14px;
}
