/* Modern Reel Modal Styles */
.reel-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.reel-modal.active {
    opacity: 1;
    visibility: visible;
}

.reel-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.reel-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 100%;
    max-width: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    padding: 20px;
}

.reel-modal.active .reel-modal-content {
    transform: translate(-50%, -50%) scale(1);
}

.reel-close-btn {
    position: absolute;
    top: 26px; /* 2/3 of screen height */
    right: 24px;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 12px;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 1000;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reel-close-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.reel-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 380px;
    max-height: calc(380px * 16 / 9); /* 9:16 aspect ratio */
    aspect-ratio: 9/16;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.reel-media-section {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reel-slides {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reel-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.reel-slide.active {
    opacity: 1;
    transform: translateX(0);
}

.reel-slide img,
.reel-slide video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: 9/16;
}

/* Responsive adjustments for horizontal videos */
@media (max-width: 768px) {
    .reel-slide.horizontal-video video {
        width: 100%;
        height: auto;
        max-height: 70vh; /* Don't let it get too tall on mobile */
    }
    
    .reel-slide.horizontal-video {
        padding: 20px 0;
    }
}

@media (orientation: landscape) and (max-height: 600px) {
    /* For landscape mobile devices */
    .reel-slide.horizontal-video video {
        height: 80vh;
        width: auto;
        max-width: 100%;
    }
}
.reel-slide.horizontal-video video {
    aspect-ratio: auto;
    object-fit: contain;
    background: #000;
    height: auto;
    max-height: 100%;
    width: 100%;
}

.reel-slide.horizontal-video {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

/* Ensure vertical videos maintain portrait aspect */
.reel-slide.vertical-video video {
    aspect-ratio: 9/16;
    object-fit: cover;
}

/* Square videos */
.reel-slide.square-video video {
    aspect-ratio: 1/1;
    object-fit: contain;
    background: #000;
}

.reel-slide video {
    outline: none;
    cursor: pointer;
}

.video-play-reel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 1;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
    border-radius: 16px;
}

.video-play-reel.hidden {
    opacity: 0;
}

/* Adjust play overlay for horizontal videos */
.reel-slide.horizontal-video .video-play-reel {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
}

.reel-slide.horizontal-video .play-pause-btn {
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.play-pause-btn {
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    border: 3px solid rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
}

.play-pause-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.play-pause-btn svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.reel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #333;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.reel-nav:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-50%) scale(1.1);
}

.reel-nav-prev {
    left: 16px;
}

.reel-nav-next {
    right: 16px;
}

.reel-progress-bar {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    gap: 4px;
    z-index: 200;
}

.progress-segment {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.progress-segment.active {
    background: rgba(255, 255, 255, 0.9);
}

.reel-info-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 60px 20px 20px;
    color: white;
    z-index: 200;
}

.reel-user-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.reel-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reel-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #ccc;
}

.reel-user-details {
    display: flex;
    flex-direction: column;
}

.reel-user-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.reel-timestamp {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 2px;
}

.reel-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.reel-action-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reel-follow-btn {
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.reel-follow-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.reel-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.reel-description {
    margin-bottom: 16px;
}

.reel-description p {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
    word-wrap: break-word;
    max-height: 60px; /* Default max height for text */
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.reel-description p.expanded {
    max-height: 300px; /* Expanded max height for text */
    overflow-y: auto; /* Enable vertical scrolling */
}

/* Custom scrollbar for description text */
.reel-description p.expanded::-webkit-scrollbar {
    width: 4px;
}

.reel-description p.expanded::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.reel-description p.expanded::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.reel-description p.expanded::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.see-more {
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    display: inline-block;
    margin-top: 8px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.see-more:hover {
    opacity: 1;
}

.reel-interaction-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reel-stats {
    display: flex;
    gap: 16px;
}

.reel-stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
}

.reel-stat-item svg {
    flex-shrink: 0;
}

.reel-action-buttons {
    display: flex;
    gap: 12px;
}

.reel-like-btn,
.reel-comment-btn,
.reel-share-btn,
.reel-bookmark-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.reel-like-btn:hover,
.reel-comment-btn:hover,
.reel-share-btn:hover,
.reel-bookmark-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.reel-like-btn.liked {
    color: #ff3040;
}

.reel-bookmark-btn.bookmarked {
    color: #ffd700;
}

.reel-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 10000;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.reel-dropdown {
    position: absolute;
    right: 24px;
    bottom: 26px;
}

.reel-dropdown::after {
    display: none;
}

/* Desktop and larger screens */
@media (min-width: 769px) {
    .reel-container {
        /* Ensure container doesn't exceed reasonable size on large screens */
        max-width: min(380px, 25vw);
        max-height: min(calc(380px * 16 / 9), 90vh);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .reel-container {
        max-width: 100vw;
        max-height: 100vh;
        width: 100vw;
        height: calc(100vw * 16 / 9); /* Maintain 9:16 aspect ratio on mobile */
        border-radius: 0;
        /* Center vertically if screen is taller than video */
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    
    /* If calculated height exceeds screen height, use screen height and adjust width */
    @media (max-height: calc(100vw * 16 / 9)) {
        .reel-container {
            width: calc(100vh * 9 / 16);
            height: 100vh;
            max-width: calc(100vh * 9 / 16);
            max-height: 100vh;
        }
    }
    
    .reel-close-btn {
        top: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
        padding: 10px;
    }
    
    .reel-nav {
        width: 40px;
        height: 40px;
    }
    
    .reel-nav-prev {
        left: 12px;
    }
    
    .reel-nav-next {
        right: 12px;
    }
    
    .reel-progress-bar {
        top: 12px;
        left: 12px;
        right: 12px;
    }
    
    .reel-info-overlay {
        padding: 40px 16px 16px;
    }
    
    .reel-user-avatar {
        width: 32px;
        height: 32px;
    }
    
    .reel-user-name {
        font-size: 14px;
    }
    
    .reel-action-buttons {
        gap: 8px;
    }
    
    .reel-like-btn,
    .reel-comment-btn,
    .reel-share-btn,
    .reel-bookmark-btn {
        width: 36px;
        height: 36px;
        padding: 6px;
    }
}

@media (max-width: 480px) {
    .reel-modal-content {
        padding: 0;
    }
    
    .reel-container {
        width: 100vw;
        height: calc(100vw * 16 / 9);
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    
    /* If calculated height exceeds screen height, use screen height and adjust width */
    @media (max-height: calc(100vw * 16 / 9)) {
        .reel-container {
            width: calc(100vh * 9 / 16);
            height: 100vh;
            max-width: calc(100vh * 9 / 16);
            max-height: 100vh;
        }
    }
    .reel-close-btn {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        padding: 8px;
    }
    
    .reel-info-overlay {
        padding: 32px 12px 12px;
    }
    
    .reel-user-info {
        gap: 10px;
    }
    
    .reel-user-avatar {
        width: 32px;
        height: 32px;
    }
    
    .reel-stats {
        gap: 12px;
    }
    
    .reel-stat-item {
        font-size: 12px;
        gap: 4px;
    }
    
    .play-pause-btn {
        width: 60px;
        height: 60px;
    }
    
    .play-pause-btn svg {
        width: 32px;
        height: 32px;
    }
}

/* Animation keyframes */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}
