/* ================================== */
/* ПРОСМОТРЩИК ИСТОРИЙ                */
/* ================================== */

.story-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--story-viewer-bg, #000000);
    z-index: var(--z-max);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(0px);
}

.story-viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 450px;
    background: var(--story-container-bg, #000);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Прогресс-бары */
.story-progress-bars {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
    z-index: 25;
}

.story-progress-segment {
    flex: 1;
    height: 3px;
    background: var(--story-progress-bg, rgba(255, 255, 255, 0.5));
    border-radius: 3px;
    overflow: hidden;
}

.story-progress-fill {
    height: 100%;
    background: var(--story-progress-fill, #ffffff);
    width: 0%;
    transition: width 0.1s linear;
}

/* Верхняя панель */
.story-header {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 25;
    color: var(--story-header-text, white);
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4), transparent);
    pointer-events: none;
}

.story-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

.story-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--story-avatar-border, rgba(255, 255, 255, 0.3));
}

.story-username {
    font-weight: 600;
    font-size: 15px;
    text-shadow: var(--story-username-shadow, 0 1px 2px rgba(0, 0, 0, 0.2));
    color: var(--story-header-text, white);
}

.story-time {
    font-size: 12px;
    opacity: 0.8;
    margin-left: 8px;
    color: var(--story-header-text, white);
}

.story-close-btn {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    backdrop-filter: blur(4px);
    transition: background var(--transition-fast);
    pointer-events: auto;
}

.story-close-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Контент медиа */
.story-media {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.story-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.story-video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #000;
}

.story-audio-container {
    text-align: center;
    padding: 20px;
    background: var(--story-audio-bg, rgba(0, 0, 0, 0.6));
    border-radius: var(--radius-xl);
    margin: 20px;
}

.story-audio-container audio {
    width: 280px;
    max-width: 80vw;
}

.story-caption {
    margin-top: 16px;
    color: var(--story-caption-text, white);
    font-size: 16px;
    text-shadow: var(--story-caption-shadow, 0 1px 2px black);
}

.story-caption-overlay {
    position: absolute;
    bottom: 40px;
    left: 20px;
    right: 20px;
    background: var(--story-caption-bg, rgba(0, 0, 0, 0.6));
    padding: 12px 16px;
    border-radius: var(--radius-xl);
    color: var(--story-caption-text, white);
    text-align: center;
    backdrop-filter: blur(8px);
    font-size: 14px;
}

/* Навигационные зоны (свайп) */
.story-nav-left,
.story-nav-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 25%;
    z-index: var(--z-popover);
    cursor: pointer;
    background: transparent;
}

.story-nav-left {
    left: 0;
}

.story-nav-right {
    right: 0;
}

/* ================================== */
/* СВЕТЛАЯ ТЕМА ДЛЯ ПРОСМОТРЩИКА ИСТОРИЙ */
/* ================================== */
body.light-theme {
    --story-viewer-bg: #ffffff;
    --story-container-bg: #ffffff;
    --story-progress-bg: rgba(0, 0, 0, 0.2);
    --story-progress-fill: var(--primary);
    --story-header-text: #1e2a3a;
    --story-avatar-border: rgba(0, 0, 0, 0.2);
    --story-username-shadow: none;
    --story-audio-bg: rgba(0, 0, 0, 0.08);
    --story-caption-text: #1e2a3a;
    --story-caption-bg: rgba(255, 255, 255, 0.8);
    --story-caption-shadow: none;
}

body.light-theme .story-close-btn {
    background: rgba(0, 0, 0, 0.2);
    color: #1e2a3a;
}

body.light-theme .story-close-btn:hover {
    background: rgba(0, 0, 0, 0.4);
    color: white;
}

body.light-theme .story-header {
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.4), transparent);
}

body.light-theme .story-audio-container {
    background: rgba(0, 0, 0, 0.08);
    color: #1e2a3a;
}

/* Мобильная адаптация просмотрщика */
@media (max-width: 600px) {
    .story-viewer-container {
        max-width: 100%;
        border-radius: 0;
    }
    .story-progress-bars {
        top: 10px;
        left: 10px;
        right: 10px;
    }
    .story-user-info {
        gap: 8px;
    }
    .story-username {
        font-size: 14px;
    }
    .story-time {
        font-size: 11px;
    }
    .story-caption-overlay {
        bottom: 20px;
        left: 12px;
        right: 12px;
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* Стили для модального окна просмотрщика (через Bootstrap-модалку) */
.story-viewer-modal-content {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    width: 100%;
    max-width: 100%;
    height: 100%;
}

.story-viewer-modal-overlay {
    background: #000000 !important;
    z-index: calc(var(--z-max) + 1) !important;
}

body.light-theme .story-viewer-modal-overlay {
    background: #ffffff !important;
}

/* Уважение prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .story-progress-fill {
        transition: none;
    }
    .story-close-btn {
        transition: none;
    }
    .story-close-btn:hover {
        background: rgba(0, 0, 0, 0.5);
    }
    body.light-theme .story-close-btn:hover {
        background: rgba(0, 0, 0, 0.2);
    }
}