/* Stories Styles */

.stories-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.stories-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.create-story-btn {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-full);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.create-story-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Stories Bar */
.stories-bar {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin-bottom: 2rem;
}

.stories-bar::-webkit-scrollbar {
    display: none;
}

.story-preview {
    position: relative;
    min-width: 80px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.story-preview:hover {
    transform: scale(1.05);
}

.story-preview-img {
    width: 80px;
    height: 80px;
    border-radius: var(--border-radius-full);
    object-fit: cover;
    border: 3px solid var(--border-color);
    transition: var(--transition);
    display: block;
    margin: 0 auto;
}

.story-preview.has-new::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 86px;
    height: 86px;
    border-radius: var(--border-radius-full);
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    z-index: 1;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.story-preview-name {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    text-align: center;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

/* Stories Grid */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.story-item {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    aspect-ratio: 9/16;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.story-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.15);
}

.story-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--border-radius);
    transition: transform 0.5s ease;
}

.story-item:hover .story-thumbnail {
    transform: scale(1.08);
}

.story-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    color: white;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.3;
    font-weight: 500;
}

.story-user-avatar {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
    z-index: 2;
}

.story-time {
    display: block;
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 4px;
}

.story-type-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    z-index: 2;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 1rem;
    opacity: 0.8;
}

/* Story Viewer */
.story-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: black;
    z-index: 5000;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.story-viewer.show {
    display: flex;
    opacity: 1;
}

.story-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    color: white;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
    z-index: 10;
    pointer-events: none;
}

.story-viewer-header > * {
    pointer-events: auto;
}

.story-viewer-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.story-viewer-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-full);
    object-fit: cover;
    border: 2px solid white;
}

.story-viewer-username {
    font-weight: 600;
    font-size: 1.1rem;
}

.story-viewer-close {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.story-viewer-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.story-viewer-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

/* Зоны навигации в просмотрщике */
.story-viewer-nav-left,
.story-viewer-nav-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 33%;
    z-index: 1;
}

.story-viewer-nav-left {
    left: 0;
}

.story-viewer-nav-right {
    right: 0;
}

.story-media {
    display: none;
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

.story-media.show {
    display: block;
}

.story-video {
    display: none;
    max-width: 100%;
    max-height: 80vh;
    background: black;
}

.story-video.show {
    display: block;
}

.story-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 0.25rem;
    padding: 1rem;
    pointer-events: none;
    z-index: 5;
}

.story-progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius-full);
    flex: 1;
    position: relative;
    overflow: hidden;
}

.story-progress-bar.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 0;
    background: white;
    animation: progress 5s linear forwards;
}

.story-viewer-footer {
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    z-index: 10;
    pointer-events: none;
}

.story-viewer-footer > * {
    pointer-events: auto;
}

.story-viewer-actions {
    display: flex;
    gap: 1rem;
    margin-left: auto;
}

.story-action-btn {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    transition: var(--transition);
}

.story-action-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

@keyframes progress {
    to { width: 100%; }
}

.story-viewer-reply {
    flex: 1;
    position: relative;
}

.story-reply-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius-full);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
    cursor: text;
}

.story-reply-input:focus {
    outline: none;
    border-color: white;
    background: rgba(0, 0, 0, 0.8);
}

.story-reply-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.2rem;
}

.story-send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.story-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.5);
}

/* Анимации для кнопок */
.story-action-btn.liked {
    animation: pulse-heart 0.5s ease;
}

@keyframes pulse-heart {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Сообщения в просмотрщике */
@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -60%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

.story-viewer-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    z-index: 100;
    font-size: 1rem;
    text-align: center;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

.story-viewer-message-error {
    background: rgba(255, 71, 87, 0.8);
}

.story-viewer-message-success {
    background: rgba(46, 213, 115, 0.8);
}

.story-viewer-message-info {
    background: rgba(72, 133, 237, 0.8);
}

/* Индикатор загрузки */
.story-viewer-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}

.story-viewer-loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Create Story Modal */
.create-story-modal .modal-content {
    max-width: 600px;
    width: 95%;
}

.story-editor {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.story-preview-container {
    aspect-ratio: 9/16;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.story-preview-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.story-preview-media.show {
    display: block;
}

.story-editor-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.story-editor-btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    flex: 1;
    justify-content: center;
}

.story-editor-btn.primary {
    background: var(--primary);
    color: white;
}

.story-editor-btn.primary:hover {
    background: var(--primary-dark);
}

.story-editor-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.story-editor-btn.secondary:hover {
    background: var(--bg-secondary);
}

.story-upload-area {
    border: 3px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-tertiary);
}

.story-upload-area:hover {
    border-color: var(--primary-dark);
    background: var(--bg-secondary);
}

.story-upload-area i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.story-upload-input {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .stories-container {
        margin: rem auto;
    }
    
    .story-preview-img {
        width: 70px;
        height: 70px;
    }
    
    .story-preview-name {
        font-size: 0.8rem;
        max-width: 70px;
    }
    
    .stories-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }
    
    .story-viewer-header,
    .story-viewer-footer {
        padding: 1rem;
    }
    
    .story-reply-input {
        padding: 0.75rem 0.75rem 0.75rem 2.5rem;
    }
    
    .story-action-btn,
    .story-send-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .story-viewer-nav-left,
    .story-viewer-nav-right {
        width: 40%;
    }
}

@media (max-width: 480px) {
    .stories-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .story-preview-img {
        width: 60px;
        height: 60px;
    }
    
    .story-preview-name {
        font-size: 0.75rem;
        max-width: 60px;
    }
    
    .stories-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.75rem;
    }
    
    .story-title {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
    
    .story-user-avatar {
        width: 30px;
        height: 30px;
    }
    
    .story-type-badge {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
    
    .story-viewer-nav-left,
    .story-viewer-nav-right {
        width: 45%;
    }
}
.stories-bar {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    padding: 1rem 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin-bottom: 2rem;
    white-space: nowrap;
}

.stories-bar-content {
    display: flex;
    gap: 1rem;
    min-width: 100%;
}

.story-preview {
    min-width: 80px;
    flex-shrink: 0;
}
/* Статистика в просмотрщике - горизонтальный ряд */
.story-viewer-stats {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  padding: 0 1rem;
  color: white;
}

.viewer-stat {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.9;
  opacity: 0.9;
}

.viewer-stat i {
  font-size: 0.8rem;
}

/* Счетчики в кнопках действий */
.action-count {
  margin-left: 0.25rem;
  font-size: 0.85rem;
  font-weight: 500;
}