/* Layout styles - Main structural elements */

/* =================================================================
   THEATER CONTAINER - Main layout wrapper
   ================================================================= */

.theater {
    display: flex;
    height: 100vh;
    position: relative;
    transition: all var(--transition-slow);
}

/* Tablet-specific theater layout */
@media (min-width: var(--breakpoint-md)) and (max-width: calc(var(--breakpoint-lg) - 1px)) {
    .theater {
        flex-direction: row;
        /* Optimized for tablet: more balanced split */
    }
}

/* Mobile-first responsive layout */
@media (max-width: calc(var(--breakpoint-md) - 1px)) {
    .theater {
        flex-direction: column;
    }

    /* On mobile, theater layout stacks vertically */
    .theater__video-section {
        height: 100vh;
        order: 1;
    }

    .theater__chat-section {
        display: none; /* Hidden by default on mobile, shown when toggled */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: var(--z-modal, 1000);
        order: 2;
        transform: translateY(100%); /* Start below screen */
        transition: transform var(--transition-base);
    }

    .theater__chat-section.mobile-visible {
        display: flex;
        transform: translateY(0);
    }
}

/* =================================================================
   VIDEO SECTION - Left side containing video player
   ================================================================= */

.theater__video-section {
    flex: 1;
    background: #000;
    position: relative;
    display: flex;
    flex-direction: column;
    transition: all var(--transition-slow);
}

.theater__video-section.expanded {
    flex: 1;
    width: 100%;
}

/* Tablet-specific video section adjustments */
@media (min-width: var(--breakpoint-md)) and (max-width: calc(var(--breakpoint-lg) - 1px)) {
    .theater__video-section {
        flex-basis: 0; /* Allow flex-grow to control sizing */
        flex-grow: 1;
        min-width: 0; /* Prevent flex item from exceeding container */
    }

    .theater__video-section.expanded {
        flex-grow: 2; /* When chat is collapsed, video takes more space */
    }
}

/* =================================================================
   VIDEO WRAPPER - Contains the video element
   ================================================================= */

.video-wrapper {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
}

/* =================================================================
   CHAT SECTION - Right side chat panel
   ================================================================= */

.theater__chat-section {
    width: 350px;
    background: var(--bg-dark);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-dodgers-lg);
    transition: transform var(--transition-slow);
    position: relative;
    border-left: 1px solid var(--border-color);
}

.theater__chat-section.collapsed {
    transform: translateX(100%);
    position: absolute;
    right: 0;
    height: 100%;
}

/* Desktop responsive adjustments */
@media (min-width: var(--breakpoint-lg)) {
    .theater__chat-section {
        width: 400px;
    }
}

/* Tablet adjustments */
@media (min-width: calc(var(--breakpoint-md))) and (max-width: calc(var(--breakpoint-lg) - 1px)) {
    .theater__chat-section {
        width: 320px;
    }
}

/* =================================================================
   DASHBOARD SECTION - Left sidebar for desktop enhancements
   ================================================================= */

.theater__dashboard-section {
    width: 280px;
    background: var(--color-surface);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow-dodgers-lg);
    transition: transform var(--transition-slow);
    position: relative;
}

.theater__dashboard-section.collapsed {
    transform: translateX(-100%);
    position: absolute;
    left: 0;
    height: 100%;
}

/* Desktop dashboard visibility */
@media (min-width: var(--breakpoint-2xl)) {
    .theater__dashboard-section {
        display: flex;
    }
}

/* Hide dashboard on smaller screens */
@media (max-width: calc(var(--breakpoint-2xl) - 1px)) {
    .theater__dashboard-section {
        display: none;
    }
}

/* =================================================================
   DASHBOARD TOGGLE CONTROLS
   ================================================================= */

.dashboard-toggle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--color-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 0 var(--border-radius-lg) var(--border-radius-lg) 0;
    width: 40px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--elevation-3);
    z-index: 5;
}

.dashboard-toggle.right {
    right: -40px;
    border-radius: var(--border-radius-lg) 0 0 var(--border-radius-lg);
    border-left: none;
}

.dashboard-toggle.left {
    left: -40px;
    border-radius: 0 var(--border-radius-lg) var(--border-radius-lg) 0;
    border-right: none;
}

/* =================================================================
   RESIZE HANDLES
   ================================================================= */

.resize-handle {
    position: absolute;
    width: 4px;
    background: var(--color-outline);
    cursor: col-resize;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: 10;
}

.resize-handle:hover,
.resize-handle.active {
    opacity: 1;
    background: var(--color-primary);
}

/* Video/Dashboard resize handle */
.theater__dashboard-section + .resize-handle {
    right: -2px;
    top: 0;
    bottom: 0;
    width: 4px;
}

/* Video/Chat resize handle */
.theater__video-section + .resize-handle {
    right: -2px;
    top: 0;
    bottom: 0;
    width: 4px;
}

/* =================================================================
   DASHBOARD LAYOUT MODES
   ================================================================= */

/* Dashboard enabled - 3-column layout */
.theater.dashboard-enabled {
    display: grid;
    grid-template-columns: 280px 1fr 350px;
    grid-template-areas: "dashboard video chat";
}

.theater.dashboard-enabled .theater__dashboard-section {
    grid-area: dashboard;
}

.theater.dashboard-enabled .theater__video-section {
    grid-area: video;
}

.theater.dashboard-enabled .theater__chat-section {
    grid-area: chat;
}

/* Dashboard disabled - Standard 2-column layout */
.theater:not(.dashboard-enabled) .theater__dashboard-section {
    display: none;
}

/* Responsive dashboard behavior */
@media (min-width: var(--breakpoint-2xl)) {
    .theater.dashboard-enabled {
        grid-template-columns: auto 1fr 350px;
    }
}

@media (min-width: var(--breakpoint-lg)) and (max-width: calc(var(--breakpoint-2xl) - 1px)) {
    .theater.dashboard-enabled {
        grid-template-columns: 250px 1fr 350px;
    }
}
