/* ===========================
   INSTAGRAM REELS-STYLE VIDEO PLAYER
   Улучшенная версия для ROXODY
   =========================== */

/* Full-screen video player overlay */
.insta-video-player {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overflow: hidden; /* Prevent scrolling */
}

.insta-video-player.active {
    opacity: 1;
    visibility: visible;
}

/* Main container - different for desktop vs mobile */
.insta-player-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row; /* Side by side on desktop */
    align-items: center;
    justify-content: center;
    max-width: 1200px;
}

/* Video content container - responsive sizing */
.insta-player-content {
    position: relative;
    height: 100vh;
    max-height: 90vh;
    width: auto;
    max-width: 100%;
    background-color: #000;
    overflow: hidden;
    
    /* Default aspect ratio, will be overridden by JS */
    --video-ratio: 0.5625; /* 9:16 default vertical video ratio */
}

/* Video element styles */
.insta-player-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: #000;
}

/* Video overlay for click events */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 15;
    cursor: pointer;
}

/* Play/Pause visual indicator */
.play-pause-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 16;
    pointer-events: none;
}

.play-pause-icon.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    animation: fadeOutIcon 1.5s forwards;
}

.play-pause-icon svg {
    width: 40px;
    height: 40px;
}

@keyframes fadeOutIcon {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
}

/* Vertical video styles */
.insta-player-content.vertical-video {
    aspect-ratio: 9/16;
    width: auto;
    height: 90vh;
}

/* Horizontal video styles */
.insta-player-content.horizontal-video {
    aspect-ratio: var(--video-ratio, 16/9);
    width: 65%;
    height: auto;
}

/* Information panel on desktop */
.insta-player-info {
    position: relative;
    width: 30%;
    max-width: 400px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    margin-left: 20px;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
}

/* Header with blogger info and close button */
.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Blog author info styles */
.blogger-info {
    display: flex;
    align-items: center;
}

.blogger-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 10px;
}

.blogger-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.blogger-username {
    font-weight: 600;
    font-size: 15px;
}

/* Close button styles */
.insta-player-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease;
    z-index: 20;
}

.insta-player-close:hover {
    transform: rotate(90deg);
}

/* Information content section */
.info-content {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Caption container with expand/collapse */
.video-caption-container {
    margin-bottom: 20px;
    position: relative;
    max-height: 120px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.video-caption-container.expanded {
    max-height: 1000px;
}

.video-caption {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 10px;
}

.caption-toggle {
    display: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.caption-toggle:hover {
    color: #fff;
}

/* Video engagement section */
.video-engagement {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.engagement-time {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

/* Progress bar (Instagram Stories style) */
.insta-player-progress {
    position: absolute;
    top: 15px;
    left: 10px;
    right: 10px;
    height: 5px;
    display: flex;
    gap: 3px;
    z-index: 20;
}

.progress-segment {
    flex: 1;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0;
    background-color: #fff;
    border-radius: 3px;
    transition: width 0.1s linear;
}

.progress-segment.completed .progress-fill {
    width: 100%;
}

/* Sound toggle button */
.sound-toggle {
    background-color: transparent;
    position: absolute;
    top: 30px;
    z-index: 20;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sound-toggle svg {
    width: 24px;
    height: 24px;
}

.sound-toggle:hover {
    background-color: transparent;
}

/* Navigation buttons on sides of video */
.video-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 16;
}

.navigation-btns {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-btn {
    width: 50px;
    height: 100%;  /* Extended height to cover the full video height */
    background-color: rgba(0, 0, 0, 0.1);
    border: none;
    color: #fff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    opacity: 0.1;
    transition: opacity 0.3s ease, background 0.3s ease;
}

.nav-btn:hover {
    opacity: 0.8;
    background-color: rgba(0, 0, 0, 0.3);
}

.nav-btn.disabled {
    opacity: 0;
    pointer-events: none;
}

.prev-video {
    padding-right: 15px;
    justify-content: flex-start;
    border-radius: 0 20px 20px 0;
}

.next-video {
    padding-left: 15px;
    justify-content: flex-end;
    border-radius: 20px 0 0 20px;
}

.nav-btn svg {
    width: 36px;
    height: 36px;
    filter: drop-shadow(0px 0px 3px rgba(0, 0, 0, 0.5));
}

/* Mobile-specific styles */
.mobile-only {
    display: none; /* Hidden on desktop */
}

/* Author info and caption on mobile */
.video-author-info {
    position: absolute;
    bottom: 60px;
    left: 15px;
    right: 60px; /* Space for sound toggle */
    z-index: 17;
    color: #fff;
}

.author-info {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 10px;
    border: 2px solid rgba(255, 255, 255, 0.8);
}

.author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.author-name {
    font-weight: 600;
    font-size: 15px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Caption preview with read more/less functionality */
.caption-preview {
    position: relative;
    border-radius: 10px;
    max-height: 80px;
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin-top: 10px;
}

.caption-preview.expanded {
    max-height: 300px;
    overflow-y: auto;
}

.mobile-caption {
    display: block;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

.read-more-btn {
    background-color: transparent;
    border: none;
    outline: none;
    border-radius: 20px;
    font-size: 13px;
    color: #fff;
    cursor: pointer;
    display: inline-block;
    margin-top: 4px;
    transition: background-color 0.3s ease;
}

.read-more-btn:hover,
.read-more-btn:active {
    background-color: transparent;
}

/* Short caption with ellipsis and "еще" button inline */
.caption-preview:not(.expanded) .mobile-caption {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    max-width: calc(100% - 50px);
    vertical-align: middle;
}

/* Media queries for responsive design */
@media (max-width: 1024px) {
    .insta-player-container {
        flex-direction: row;
        justify-content: center;
    }
    
    .insta-player-content {
        width: auto !important;
        height: 70vh !important;
        max-height: 70vh;
    }
    
    .insta-player-content.vertical-video {
        aspect-ratio: 9/16;
        width: auto !important;
        height: 70vh !important;
    }
    
    .insta-player-content.horizontal-video {
        aspect-ratio: var(--video-ratio, 16/9);
        width: 90% !important;
        height: auto !important;
        max-height: 70vh;
    }
    
    .insta-player-info {
        position: relative;
        width: 30%;
        max-width: 400px;
        height: 90vh;
        display: flex;
        flex-direction: column;
        margin-left: 20px;
        color: #fff;
        background-color: rgba(0, 0, 0, 0.5);
        border-radius: 10px;
        overflow: hidden;
    }
}

@media (max-width: 768px) {
    /* Switch to Instagram Reels mobile layout */
    .insta-player-container {
        flex-direction: column;
    }
    
    .insta-player-content {
        width: 100% !important;
        height: 100vh !important;
        max-height: none;
        border-radius: 0;
    }
    
    .insta-player-content.vertical-video,
    .insta-player-content.horizontal-video {
        width: 100% !important;
        height: 100vh !important;
        max-height: none;
        aspect-ratio: auto;
    }
    
    /* Hide desktop info panel on mobile */
    .insta-player-info {
        display: none;
    }
    
    /* Show mobile overlay elements */
    .mobile-only {
        display: block;
    }
    
    /* Close button position on mobile - ALWAYS VISIBLE */
    .insta-player-close.mobile-only {
        position: absolute;
        top: 30px;
        right: 15px;
        z-index: 30;
        opacity: 0.9;
        border-radius: 50%;
        width: 36px;
        height: 36px;
    }

    /* Sound toggle position on mobile */
    .sound-toggle {
        top: 30px;
        left: 15px;
        right: auto;
        bottom: auto;
        opacity: 0.9;
    }
    
    /* Navigation buttons - more visible but subtler on mobile */
    .nav-btn {
        width: 50px;
        opacity: 0.6;
    }
    
    .nav-btn svg {
        width: 36px;
        height: 36px;

    }
    
    /* Full-screen video */
    .insta-player-video {
        width: 100%;
        height: 100%;
        object-fit: cover; /* Cover on mobile for better experience */
    }
    
    /* Read more button - make it more tappable */
    .read-more-btn {
        font-size: 14px;
    }
    
    /* Special styling for truncated captions on mobile */
    .caption-preview:not(.expanded) {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;    
        padding-right: 0px;
    }
    
    .caption-preview:not(.expanded) .read-more-btn {
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        margin-top: 0;
    }
    
    .caption-preview.expanded {
        white-space: normal;
        padding-right: 15px;
    }
    
    .caption-preview.expanded .read-more-btn {
        position: static;
        transform: none;
        margin-top: 8px;
    }
}