/* Modern Stories Module CSS */
.stories-modern-module {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Scroll Container */
.stories-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 10px 0;
}

.stories-scroll-container::-webkit-scrollbar {
    display: none;
}

/* Stories List */
.stories-list {
    display: flex;
    gap: 15px;
    padding: 5px;
    white-space: nowrap;
}

/* Story Circle */
.story-circle {
    flex: 0 0 auto;
    width: var(--circle-size);
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.story-circle:hover {
    transform: scale(1.05);
}

.story-avatar {
    width: var(--circle-size);
    height: var(--circle-size);
    margin: 0 auto 5px;
    border-radius: 50%;
    padding: var(--circle-border-width);
    background: var(--circle-color);
    transition: background 0.3s ease;
    border: var(--circle-border-width) var(--circle-border-style) var(--circle-border-color);
    box-sizing: border-box;
}

.story-avatar.viewed {
    background: var(--circle-viewed-color);
}

.story-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-sizing: border-box;
}

.story-title {
    font-size: 12px;
    color: #262626;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: var(--circle-size);
}

/* Stories Viewer Modal */
.stories-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
}

.stories-viewer.active {
    display: block;
}

.stories-viewer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.stories-viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 400px;
    margin: 0 auto;
    background: #000;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Стили для PC - отступы сверху и снизу */
@media (min-width: 769px) {
    .stories-viewer-container {
        margin: var(--modal-margin) auto;
        border-radius: var(--modal-radius);
        height: calc(100% - (var(--modal-margin) * 2));
    }
}

/* Header */
.stories-viewer-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    padding: 15px 15px 0;
}

.stories-viewer-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    position: relative;
}

.stories-viewer-logo {
    position: absolute;
    left: 15px;
    top: 15px;
    z-index: 30;
}

.stories-viewer-logo img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
}

.stories-viewer-close {
    position: absolute;
    right: 15px;
    top: 15px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
    z-index: 30;
}

.stories-viewer-close:hover {
    opacity: 1;
}

.stories-viewer-close svg {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Progress Bars */
.stories-progress-container {
    display: flex;
    gap: 3px;
    margin-top: 60px;
    padding: 0 15px;
}

.progress-bar {
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--progress-bar-color);
    border-radius: 2px;
    transition: width linear;
}

/* Content */
.stories-viewer-content {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.stories-slides-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.story-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.story-slide.active {
    display: block;
}

.story-slide video,
.story-slide iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: none;
}

/* Navigation */
.stories-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 25;
}

.stories-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.stories-nav-prev {
    left: 10px;
}

.stories-nav-next {
    right: 10px;
}

.stories-nav svg {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Pause Button - теперь в правом верхнем углу, под крестиком */
.stories-pause-btn {
    position: absolute;
    right: 60px;
    top: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 30;
    backdrop-filter: blur(4px);
}

.stories-pause-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.stories-pause-btn svg {
    width: 16px;
    height: 16px;
    fill: white;
}

/* Footer - теперь наложен на историю снизу */
.stories-viewer-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px 20px 20px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    z-index: 20;
    pointer-events: none;
}

.stories-viewer-footer > * {
    pointer-events: auto;
}

/* Story Link */
.story-link {
    display: inline-block;
    background: #0095f6;
    color: #fff;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.story-link:hover {
    background: #0081d6;
}

/* Product Card */
.story-product {
    display: flex;
    gap: 15px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 15px;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.story-product img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
}

.product-info {
    flex: 1;
}

.product-name {
    font-weight: 600;
    color: #262626;
    margin-bottom: 5px;
    font-size: 16px;
}

.product-price {
    margin-bottom: 8px;
}

.price {
    color: #262626;
    font-weight: 600;
    font-size: 16px;
}

.price-old {
    color: #999;
    text-decoration: line-through;
    font-size: 14px;
    margin-right: 8px;
}

.price-new {
    color: #ed4956;
    font-weight: 600;
    font-size: 16px;
}

.story-product .btn {
    background: #0095f6;
    color: #fff;
    border: none;
    padding: 5px 15px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-block;
}

.story-product .btn:hover {
    background: #0081d6;
}

/* Responsive */
@media (max-width: 768px) {
    .stories-viewer-container {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        height: 100%;
    }
    
    .stories-nav {
        display: none;
    }
    
    .stories-pause-btn {
        right: 50px;
    }
    
    .stories-viewer-footer {
        padding: 20px 15px 15px;
    }
    
    .story-product {
        padding: 10px;
    }
    
    .story-product img {
        width: 60px;
        height: 60px;
    }
    
    .product-name {
        font-size: 14px;
    }
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Overlay для слайдов с товарами */
.story-slide-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 1;
}

.story-slide {
    position: relative;
}

.story-slide.active {
    z-index: 2;
}

/* Убедимся, что видео и iframe не перекрывают overlay */
.story-slide video,
.story-slide iframe {
    position: relative;
    z-index: 1;
}
.stories-viewer.active .stories-viewer-container {
    animation: fadeIn 0.3s ease;
}