/* /home/siisi/vertex/media_app/static/css/media-detail.css */

/* ============================================= */
/* 1. COMMENTS SECTION SCROLLBAR & STYLING       */
/* ============================================= */

/* Beautiful Colored Scrollbar for Comments */
.comments-list {
    max-height: 500px;
    overflow-y: auto;
    padding-right: 8px;
}

/* Webkit browsers (Chrome, Safari, Edge) */
.comments-list::-webkit-scrollbar {
    width: 12px;
}

.comments-list::-webkit-scrollbar-track {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    border: 2px solid #f8f9fa;
}

.comments-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--bs-primary) 0%, #0d6efd 100%);
    border-radius: 10px;
    border: 2px solid #f8f9fa;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.comments-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #0b5ed7 0%, #0a58ca 100%);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.comments-list::-webkit-scrollbar-thumb:active {
    background: linear-gradient(180deg, #0a58ca 0%, #0a53be 100%);
}

.comments-list::-webkit-scrollbar-corner {
    background: #f8f9fa;
}

/* Firefox */
.comments-list {
    scrollbar-width: thin;
    scrollbar-color: var(--bs-primary) #f8f9fa;
}

/* Smooth scrolling */
.comments-list {
    scroll-behavior: smooth;
}

/* Comment item animations */
.comment-item {
    transition: all 0.3s ease;
    border-left: 3px solid transparent !important;
}

.comment-item:hover {
    border-left-color: var(--bs-primary) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateX(2px);
}

/* Delete button animation */
.delete-comment-btn {
    transition: all 0.2s ease;
    opacity: 0.7;
}

.delete-comment-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Empty state styling */
.comments-list .text-muted {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.comments-list .text-muted:hover {
    opacity: 1;
}

/* Style for comments that media owner can delete */
.media-owner-comment {
    border-left: 4px solid #ffc107 !important;
    background-color: rgba(255, 193, 7, 0.05);
}

/* Different button styling for media owner deletion */
.btn-outline-warning.delete-comment-btn:hover {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #000;
}


/* ============================================= */
/* 2. DYNAMIC ASPECT RATIO VIDEO HANDLING        */
/* ============================================= */

/* Base image wrapper for all media */
.image-wrapper {
    background: #f8f9fa !important;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Video wrapper - Base Styles */
.image-wrapper.video-wrapper {
    width: 100%;
    /* Default min-height ensures visibility */
    min-height: 400px;
    background: #f8f9fa !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

/* Adaptive video element */
.adaptive-video {
    width: 100%;
    height: 100%;
    display: block;
    background: #f8f9fa !important;
}

/* Video player container */
.video-player-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #f8f9fa !important;
}

/* --- LANDSCAPE (16:9, 4:3) --- */
.image-wrapper.video-wrapper.landscape-video {
    aspect-ratio: 16 / 9;
    max-height: 70vh;
}

.image-wrapper.video-wrapper.landscape-video .adaptive-video {
    object-fit: contain;
}

/* --- PORTRAIT (9:16, TikTok style) --- */
.image-wrapper.video-wrapper.portrait-video {
    /* Force a taller container for portrait videos so they don't look tiny */
    height: 85vh;
    min-height: 600px;
}

.image-wrapper.video-wrapper.portrait-video .adaptive-video {
    /* Contain ensures we see the whole video (head to toe) */
    object-fit: contain;
    width: 100%;
    height: 100%;
    /* Optional: Add a subtle shadow to separate video from black bg */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* --- SQUARE (1:1) --- */
.image-wrapper.video-wrapper.square-video {
    aspect-ratio: 1 / 1;
    max-height: 70vh;
}

/* Default Fallback (if JS hasn't run yet) */
.image-wrapper.video-wrapper:not(.landscape-video):not(.portrait-video):not(.square-video) .adaptive-video {
    object-fit: contain;
    aspect-ratio: 16/9;
}


/* ============================================= */
/* 3. IMAGE DISPLAY HANDLING                     */
/* ============================================= */

/* Images: Keep object-fit: contain for proper display */
.image-wrapper:not(.video-wrapper) {
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa !important;
}

.image-wrapper:not(.video-wrapper) img {
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Image display container */
.image-display-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: #f8f9fa !important;
}

.media-image {
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
    object-fit: contain;
}


/* ============================================= */
/* 4. MISC UI ELEMENTS                           */
/* ============================================= */

/* Ensure the media card doesn't have any content that overlaps */
.media-display-card .card-body {
    display: none;
}

/* Badge for media owner indicator */
.badge.bg-warning {
    font-size: 0.7em;
    padding: 0.25em 0.5em;
}

/* Social overlay adjustments */
.image-wrapper .social-overlay {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 50%, rgba(0, 0, 0, 0) 100%);
    padding: 1rem;
    z-index: 2;
}

/* Ensure social overlay text is visible on all backgrounds */
.social-overlay .text-white {
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Video duration badge positioning */
.video-player-container .position-absolute.bottom-0.end-0.m-3 {
    z-index: 3;
}

/* Aspect ratio indicator */
.aspect-ratio-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
}

/* Video loading state */
.video-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    z-index: 1;
}

.video-loading .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* ============================================= */
/* 5. RESPONSIVE ADJUSTMENTS                     */
/* ============================================= */
@media (min-width: 1200px) {
    .media-image {
        max-height: 520px;
    }
}

@media (max-width: 768px) {

    /* Image Adjustments */
    .image-wrapper:not(.video-wrapper) {
        min-height: 60vh !important;
    }

    .image-wrapper:not(.video-wrapper) img {
        max-height: 60vh !important;
        object-fit: contain !important;
    }

    /* Standard Video Adjustments */
    .image-wrapper.video-wrapper {
        min-height: 60vh !important;
        max-height: 60vh !important;
    }

    /* Apply object-fit: contain to all videos on mobile */
    .adaptive-video {
        object-fit: contain !important;
    }

    /* PORTRAIT Mobile specific override */
    .image-wrapper.video-wrapper.portrait-video {
        /* On mobile, allow it to take up a lot of space, but fit within viewport */
        height: 80vh !important;
        min-height: auto;
        max-width: none;
    }

    .image-wrapper.video-wrapper.portrait-video .adaptive-video {
        max-height: 80vh !important;
        object-fit: contain !important;
    }
}

@media (max-width: 576px) {

    /* Make media even taller on very small screens */
    .image-wrapper:not(.video-wrapper) {
        min-height: 70vh !important;
    }

    .image-wrapper:not(.video-wrapper) img {
        max-height: 70vh !important;
        object-fit: contain !important;
    }

    .image-wrapper.video-wrapper {
        min-height: 70vh !important;
        max-height: 70vh !important;
    }

    .adaptive-video {
        object-fit: contain !important;
    }

    .image-wrapper.video-wrapper.portrait-video {
        height: 85vh !important;
        max-width: none;
    }

    .image-wrapper.video-wrapper.portrait-video .adaptive-video {
        max-height: 85vh !important;
        object-fit: contain !important;
    }
}

/* ============================================= */
/* 6. RESPONSIVE VIDEO ADJUSTMENTS */
/* ============================================= */

/* ---------- TABLET (768px to 991px) ---------- */
/* Make portrait videos smaller on tablets */
@media (min-width: 768px) and (max-width: 991px) {
    .image-wrapper.video-wrapper.portrait-video {
        /* Smaller than mobile but not as small as desktop */
        height: 60vh !important;
        min-height: 400px !important;
        max-height: 65vh !important;
        width: auto !important;
        max-width: 60% !important;
        /* Narrower than mobile */
        margin: 0 auto !important;
        /* Center it */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .image-wrapper.video-wrapper.portrait-video .adaptive-video {
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
        border-radius: 6px;
    }
}

/* ---------- DESKTOP (992px to 1199px) ---------- */
@media (min-width: 992px) and (max-width: 1199px) {
    .image-wrapper.video-wrapper.portrait-video {
        /* Centered and properly sized for desktop */
        height: 70vh !important;
        min-height: 450px !important;
        max-height: 75vh !important;
        width: auto !important;
        max-width: 50% !important;
        margin: 0 auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: relative !important;
        left: 0 !important;
        right: 0 !important;
    }

    .image-wrapper.video-wrapper.portrait-video .adaptive-video {
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
        margin: 0 auto !important;
        display: block !important;
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
        border-radius: 8px;
        background: #000 !important;
    }

    /* Centering helper */
    .image-wrapper.video-wrapper.portrait-video::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 100%;
        height: 100%;
        pointer-events: none;
        z-index: -1;
    }
}

/* ---------- LARGE DESKTOP (1200px to 1399px) ---------- */
@media (min-width: 1200px) and (max-width: 1399px) {
    .image-wrapper.video-wrapper.portrait-video {
        height: 65vh !important;
        min-height: 400px !important;
        max-height: 70vh !important;
        max-width: 40% !important;
        margin: 0 auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .image-wrapper.video-wrapper.portrait-video .adaptive-video {
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
        box-shadow: 0 15px 45px rgba(0, 0, 0, 0.6);
        border-radius: 10px;
    }
}

/* ---------- EXTRA LARGE DESKTOP (1400px and up) ---------- */
@media (min-width: 1400px) {
    .image-wrapper.video-wrapper.portrait-video {
        /* Centered and proportional for ultra-wide screens */
        height: 60vh !important;
        min-height: 350px !important;
        max-height: 65vh !important;
        max-width: 35% !important;
        margin: 0 auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: relative !important;
    }

    .image-wrapper.video-wrapper.portrait-video .adaptive-video {
        max-width: 95% !important;
        /* Keep it narrow on ultra wide screens */
        max-height: 100% !important;
        object-fit: contain !important;
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
        border-radius: 12px;
        background: #000 !important;
    }
}

/* ---------- LANDSCAPE TABLETS (768px to 991px) ---------- */
@media (min-width: 768px) and (max-width: 991px) and (orientation: landscape) {
    .image-wrapper.video-wrapper.portrait-video {
        height: 80vh !important;
        /* Taller in landscape */
        min-height: 300px !important;
        max-width: 40% !important;
        /* Narrower */
    }
}

/* ---------- COMMON FIXES FOR ALL SCREENS ---------- */

/* Ensure all portrait videos use flex centering */
.image-wrapper.video-wrapper.portrait-video {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Ensure all videos maintain aspect ratio */
.image-wrapper.video-wrapper.portrait-video .adaptive-video {
    object-fit: contain !important;
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
}

/* Center the parent container if needed */
.media-content-wrapper,
.video-player-container {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
}

/* Smooth transitions */
.image-wrapper.video-wrapper.portrait-video,
.image-wrapper.video-wrapper.portrait-video .adaptive-video {
    transition: all 0.3s ease-in-out !important;
}

/* ---------- OTHER VIDEO TYPES FOR CONSISTENCY ---------- */
@media (min-width: 992px) {

    /* Landscape videos */
    .image-wrapper.video-wrapper.landscape-video {
        max-height: 70vh !important;
        margin: 0 auto !important;
    }

    /* Square videos */
    .image-wrapper.video-wrapper.square-video {
        max-height: 65vh !important;
        max-width: 65vh !important;
        margin: 0 auto !important;
    }

    /* Images */
    .media-image {
        max-height: 70vh !important;
        margin: 0 auto !important;
        display: block !important;
    }
}

/* ---------- FIX FOR HEIGHT-LIMITED SCREENS ---------- */
@media (max-height: 700px) and (min-width: 768px) {
    .image-wrapper.video-wrapper.portrait-video {
        height: 75vh !important;
        min-height: 250px !important;
    }
}
