/* ============================================
   Story Pages Styles with Custom Scrollbar
   ============================================ */

.story-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-6);
}

.story-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
    gap: var(--space-4);
}

.story-title {
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
    margin: 0;
}

.btn-create-story {
    padding: var(--space-3) var(--space-5);
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-create-story:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Stories Scroll Wrapper */
.stories-scroll-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    overflow: visible;
    width: 100%;
}

/* Stories Grid - кастомный скролл */
.stories-grid {
    display: flex;
    gap: var(--space-4);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    padding: var(--space-2) var(--space-2) var(--space-4);
    min-height: 420px;
    flex: 1;
    min-width: 0;
    scroll-behavior: smooth;
}

/* Кастомная полоса прокрутки для .stories-grid */
.stories-grid::-webkit-scrollbar {
    height: 8px;
}

.stories-grid::-webkit-scrollbar-track {
    background: var(--surface-200);
    border-radius: 10px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stories-grid::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.stories-grid::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
    cursor: pointer;
}

/* User Stories Block */
.user-stories {
    flex: 0 0 340px;
    scroll-snap-align: start;
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--surface-0);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    height: 420px;
    border: 1px solid var(--border-primary);
}

.user-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
    color: var(--text-inverse);
    flex-shrink: 0;
    height: 70px;
    box-sizing: border-box;
    position: relative;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.4);
    transition: transform var(--transition-fast);
}

.user-avatar:hover {
    transform: scale(1.1);
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-info .username {
    font-weight: var(--font-semibold);
    font-size: var(--text-base);
    margin-bottom: var(--space-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stories-count {
    font-size: var(--text-sm);
    opacity: 0.9;
}

/* Stories List - кастомный скролл */
.stories-list {
    display: flex;
    flex-direction: row;
    gap: var(--space-3);
    padding: var(--space-4);
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    min-height: 0;
}

/* Кастомная полоса прокрутки для .stories-list */
.stories-list::-webkit-scrollbar {
    height: 6px;
}

.stories-list::-webkit-scrollbar-track {
    background: var(--surface-200);
    border-radius: 10px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stories-list::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, var(--primary-500) 0%, var(--primary-600) 100%);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.stories-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, var(--primary-600) 0%, var(--primary-700) 100%);
    cursor: pointer;
}

/* Story Item */
.story-item {
    position: relative;
    flex: 0 0 130px;
    scroll-snap-align: start;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    width: 130px;
    height: 220px;
    background: linear-gradient(180deg, var(--surface-100) 0%, var(--surface-0) 100%);
    border: 2px solid var(--border-primary);
    overflow: hidden;
}

.story-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.35) 100%);
    pointer-events: none;
}

.story-item:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-400);
}

/* Story Image Container */
.story-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.story-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.story-item:hover .story-image {
    transform: scale(1.1);
}

/* Story Time Left */
.story-time-left {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: var(--font-semibold);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    z-index: 10;
    backdrop-filter: blur(4px);
}

/* Story Caption */
.story-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40px 8px 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    color: white;
    font-size: 11px;
    z-index: 5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Story Buttons */
.story-buttons {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    z-index: 15;
}

.story-view-btn,
.story-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.story-view-btn {
    background: rgba(59, 130, 246, 0.9);
    color: white;
}

.story-view-btn:hover {
    background: rgba(37, 99, 235, 1);
    transform: scale(1.15);
}

.story-delete-btn {
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

.story-delete-btn:hover {
    background: rgba(220, 38, 38, 1);
    transform: scale(1.15);
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-10);
    text-align: center;
    background: var(--surface-50);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.upload-area:hover {
    border-color: var(--primary-600);
    background: var(--primary-50);
}

.upload-area.dragover {
    border-color: var(--primary-600);
    background: var(--primary-50);
    transform: scale(1.02);
}

.upload-icon {
    font-size: var(--text-5xl);
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

/* Story View Modal */
.story-view-wrapper {
    padding: 20px;
    max-height: 85vh;
    overflow-y: auto;
}

/* Кастомный скролл для просмотра истории */
.story-view-wrapper::-webkit-scrollbar {
    width: 8px;
}

.story-view-wrapper::-webkit-scrollbar-track {
    background: var(--surface-200);
    border-radius: 10px;
}

.story-view-wrapper::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    border-radius: 10px;
}

.story-view-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.story-view-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.story-view-username {
    font-weight: bold;
    font-size: 16px;
}

.story-view-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.story-view-image-container {
    text-align: center;
    cursor: pointer;
}

.story-view-image {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 12px;
}

.story-view-caption {
    margin-top: 16px;
    padding: 16px;
    background: linear-gradient(135deg, var(--surface-800) 0%, var(--surface-700) 100%);
    color: var(--text-primary);
    border-radius: 12px;
}

.story-view-caption:is(.dark .story-view-modal .story-view-caption),
:is([data-theme="dark"]) .story-view-modal .story-view-caption {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.75));
    color: white;
}

.story-view-meta {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

@media (prefers-color-scheme: dark) {
    .story-view-caption {
        background: linear-gradient(135deg, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.75));
        color: white;
    }
}

/* Scroll Buttons */
.scroll-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--surface-0);
    border: 1px solid var(--border-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 24px;
    color: var(--text-primary);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.scroll-btn:hover {
    background: var(--primary-500);
    color: white;
    border-color: var(--primary-500);
    transform: scale(1.1);
}

/* Empty State */
.empty-state, .guest-state {
    text-align: center;
    padding: var(--space-12);
    background: var(--surface-0);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
}

.empty-icon, .guest-icon {
    font-size: var(--text-5xl);
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 1024px) {
    .user-stories {
        flex: 0 0 300px;
    }
}

@media (max-width: 768px) {
    .story-container {
        padding: var(--space-4);
    }
    
    .story-header {
        flex-direction: column;
        text-align: center;
    }
    
    .user-stories {
        flex: 0 0 260px;
        height: 380px;
    }
    
    .story-item {
        flex: 0 0 110px;
        height: 190px;
    }
    
    .story-view-btn,
    .story-delete-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .scroll-btn {
        width: 30px;
        height: 30px;
        font-size: 20px;
    }
    
    .fullscreen-exit-btn {
        top: 10px;
        right: 10px;
        padding: 8px 14px;
        font-size: var(--text-sm);
    }
    
    /* Адаптивные кастомные скроллы */
    .stories-grid::-webkit-scrollbar {
        height: 6px;
    }
    
    .stories-list::-webkit-scrollbar {
        height: 4px;
    }
}

@media (max-width: 480px) {
    .story-container {
        padding: var(--space-3);
    }
    
    .user-stories {
        flex: 0 0 220px;
        height: 340px;
    }
    
    .story-item {
        flex: 0 0 95px;
        height: 170px;
    }
    
    .user-avatar {
        width: 36px;
        height: 36px;
    }
    
    .user-info .username {
        font-size: var(--text-sm);
    }
    
    .stories-count {
        font-size: var(--text-xs);
    }
    
    .story-view-btn,
    .story-delete-btn {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

.story-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-6);
}

/* ==================== Context Menu ==================== */
.message-context-menu {
    position: fixed;
    z-index: 100002;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e0e0e0;
    overflow: hidden;
    min-width: 150px;
    animation: contextMenuFadeIn 0.15s ease;
}

@keyframes contextMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
    color: #333333;
}

.context-menu-item:last-child {
    border-bottom: none;
}

.context-menu-item:hover {
    background: #f5f5f5;
}

.context-menu-item.delete-story-btn,
.context-menu-item.delete-message-btn {
    color: #e74c3c;
    font-weight: 500;
}

.context-menu-item.delete-story-btn:hover,
.context-menu-item.delete-message-btn:hover {
    background: #ffeaea;
}
