/**
 * Carousel Layout - Legacy Structure Replicated
 * Simple flex column layout with proper vertical space allocation
 */

/* Main carousel container - full viewport height */
.layout-carousel {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.5vw;  /* var(--streamblock-gap) from legacy */
    background-color: var(--bg-primary);
}

/* Scroll container - takes remaining flex space */
.carousel-scroll-container {
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 1.5vw;  /* var(--streamblock-gap) from legacy */
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: auto;
    padding: 0 0.8vw;  /* var(--monitor-gap) from legacy */
    margin-bottom: 4vh;  /* Exact legacy spacing before carousel */
    
    /* Standard properties - Firefox and modern browsers */
    scrollbar-color: var(--primary-color) rgba(0, 0, 0, 0.1);
    scrollbar-width: thin;
}

/* WebKit browsers - Chrome, Safari, Edge */
.carousel-scroll-container::-webkit-scrollbar { 
    height: 0.6vh; 
}

.carousel-scroll-container::-webkit-scrollbar-track { 
    background: rgba(0, 0, 0, 0.1); 
    border-radius: 0.3vh;
    margin: 0 0.8vw;  /* var(--monitor-gap) */
}

.carousel-scroll-container::-webkit-scrollbar-thumb { 
    background: var(--primary-color); 
    border-radius: 0.3vh;
}

/* Stream blocks in scroll container */
.carousel-scroll-container > .stream-block,
.carousel-scroll-container > .carousel-streamblock {
    flex-shrink: 0;
    height: 100%;  /* Take full height of scroll container */
}

/* Controls container - fixed height, takes real space */
.carousel-controls {
    height: 12vh;  /* var(--carousel-height) from legacy */
    position: relative;  /* For absolute positioning of arrows */
    display: flex;
    align-items: center;
    justify-content: center;  /* Center the indicators */
    padding: 1.5vh 0;
    flex-shrink: 0;  /* Don't shrink */
}

/* Navigation arrows - positioned at opposite corners like legacy */
.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);  /* Center vertically */
    background: var(--primary-color);
    color: white;
    border: none;
    width: 5vh;
    height: 5vh;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5vh;
    transition: opacity 0.3s;
}

.carousel-arrow-prev {
    left: 1.5vh;  /* Bottom left corner */
}

.carousel-arrow-next {
    right: 1.5vh;  /* Bottom right corner */
}

.carousel-arrow:hover { 
    opacity: 0.8; 
}

.carousel-arrow:disabled { 
    opacity: 0.3; 
    cursor: not-allowed; 
}

/* Arrow icon fix */
.carousel-arrow i {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 2.5vh;
    color: white;
}

/* Fallback arrow characters */
.carousel-arrow-prev::after {
    content: '◀';
    position: absolute;
    font-size: 2.5vh;
}

.carousel-arrow-next::after {
    content: '▶';
    position: absolute;
    font-size: 2.5vh;
}

/* Hide fallback if icon loads */
.carousel-arrow:has(i.bi)::after {
    display: none;
}

/* Carousel indicators container - centered between arrows */
.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 1.5vh;
    /* Remove flex: 1 since we're using absolute positioning for arrows */
}

/* Individual carousel indicator - exact legacy styling */
.carousel-indicator {
    width: 14vh;
    height: 9vh;
    border: 0.3vh solid var(--primary-color);
    border-radius: 0.8vh;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(50, 50, 50, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8vh;
    font-weight: 600;
    color: white;
}

.carousel-indicator.active { 
    background: var(--primary-color); 
    color: white;
}


/* Empty state - centered in scroll container */
.carousel-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.carousel-empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
    color: var(--primary-color);
}

.carousel-empty-state h3 {
    font-size: 1.5rem;
    margin: 0 0 0.5rem 0;
    font-weight: 500;
}

.carousel-empty-state p {
    font-size: 1rem;
    margin: 0;
    opacity: 0.7;
    max-width: 500px;
}

/* Focus styles for accessibility */
.carousel-arrow:focus,
.carousel-indicator:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .layout-carousel {
        padding: 1vw;
    }
    
    .carousel-controls {
        height: 10vh;
        gap: 1vh;
        padding: 1vh 0;
    }
    
    .carousel-arrow {
        width: 4vh;
        height: 4vh;
        font-size: 2vh;
    }
    
    .carousel-indicator {
        width: 12vh;
        height: 7vh;
        font-size: 1.5vh;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .carousel-indicator {
        border-width: 2px;
    }
    
    .carousel-arrow {
        border: 2px solid white;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .carousel-scroll-container {
        scroll-behavior: auto;
    }
    
    .carousel-arrow,
    .carousel-indicator {
        transition: none;
    }
}

/* ========================================
 * CAROUSEL COMPONENT STYLES 
 * Stream blocks, monitors, videos, labels
 * ======================================== */

/* CRITICAL: Ensure box-sizing matches legacy */
.carousel-streamblock,
.carousel-streamblock * {
    box-sizing: border-box;
}

/* Carousel-specific stream block */
.carousel-streamblock {
    flex-shrink: 0;
    display: grid;
    grid-template-rows: 1fr 3fr 1fr;  /* Back to grid for exact proportions */
    gap: var(--monitor-gap, 0.8vw);  /* Gap between rows */
    height: var(--streamblock-height);  /* Exact height from JS */
    width: var(--streamblock-width);  /* Exact width from JS */
    background: black;
    border: 0.3vh solid var(--center-color, var(--primary-color));
    border-radius: 0.6vh;
    overflow: hidden;
    position: relative;  /* CRITICAL: Create positioning context for labels */
}

/* Monitor rows */
.carousel-monitor-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--monitor-gap, 0.8vw);  /* Match legacy monitor gap */
}

/* Individual scoring monitor */
.carousel-scoring-monitor {
    background: black;
    border: 0.3vh solid var(--center-color, var(--primary-color));
    border-radius: 0.6vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;  /* Explicit aspect ratio like legacy */
}

/* Lane monitor image container in carousel context */
.carousel-scoring-monitor .lane-monitor-image-container {
    flex: 1; /* Take remaining space after label */
    aspect-ratio: unset; /* Let flex handle sizing in carousel */
}

/* Monitor images in carousel */
.carousel-scoring-monitor .lane-image {
    object-fit: fill;  /* Fill to eliminate any black bars on images */
}

/* Lane labels - simple colored badges like prototype */
.carousel-lane-label {
    position: absolute;
    top: 0.5vh;
    left: 0.5vh;
    background: var(--center-color, var(--primary-color));
    color: white;
    padding: 0.2vh 0.4vh;
    border-radius: 0.3vh;
    font-size: 0.8em;
    font-weight: bold;
    z-index: 2;
}

/* Video container - center section gets 3x space */
.carousel-stream-monitor {
    position: relative;
    background: black;
    border-radius: 0.4vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Grid will handle the height */
}

/* Video wrapper for exact 16:9 */
.carousel-video-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    /* Let grid handle the sizing exactly */
}

/* Video player - simple and clean */
.carousel-video-wrapper video,
.carousel-video-wrapper .video-js {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0;
    left: 0;
    object-fit: fill !important; /* Fill completely to eliminate black bars */
}

/* VideoJS control bar - normal hover behavior, hide all volume controls */
.carousel-stream-monitor .vjs-control-bar {
    /* Remove forced visibility - let VideoJS handle show/hide normally */
}

/* Completely hide all volume-related controls */
.carousel-stream-monitor .vjs-volume-panel,
.carousel-stream-monitor .vjs-mute-control,
.carousel-stream-monitor .vjs-volume-control,
.carousel-stream-monitor .vjs-volume-bar,
.carousel-stream-monitor .vjs-volume-level {
    display: none !important;
}

/* Stream label */
.carousel-stream-label {
    position: absolute;
    bottom: 0.5vh;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.2vh 0.6vh;
    border-radius: 0.3vh;
    font-size: 0.9em;
    white-space: nowrap;
    z-index: 10;
}

/* Use existing lane monitor loading animation - no code duplication */

/* Error state for monitors */
.carousel-scoring-monitor.error {
    background: #2a2a2a;
    color: #666;
}

.carousel-scoring-monitor.error::after {
    content: '⚠';
    font-size: 2em;
    color: #666;
}

/* Remove any hover effects for carousel context */
.carousel-scoring-monitor {
    transform: none !important;
    transition: none !important;
}

.carousel-scoring-monitor:hover {
    transform: none !important;
}

/* Video error state */
.video-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #666;
}

.video-error i {
    font-size: 2em;
    margin-bottom: 0.5em;
    display: block;
}