/**
 * RMT-Tech Centralized RTC Video Grid Styles
 *
 * Provides a single, responsive, and modern layout solution for
 * both the Nexus and Mesh WebRTC topologies.
 */

/* --- 1. Grid Container --- */
.rtc-video-grid {
    display: flex;
    flex-direction: column;
    /* Mobile-first: default to a list view */
    gap: 8px;
    width: 100%;
    height: 100%;
    padding: 8px;
    box-sizing: border-box;
    background-color: #212529;
    /* Dark background for contrast */
    border-radius: 8px;
}

/* --- 2. Video Wrapper --- */
.rtc-video-wrapper {
    position: relative;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease-in-out;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    aspect-ratio: 16 / 9;
    /* Enforce uniform aspect ratio for all videos */
}

.rtc-video-wrapper.is-speaking {
    border: 2px solid #3b82f6;
    box-shadow: 0 0 12px 4px rgba(59, 130, 246, 0.6);
    /* A blue glow */
}


.rtc-video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Fills the container without distortion */
    display: block;
}

/* --- 3. Overlays (Labels & Controls) --- */
.rtc-video-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background-color: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    z-index: 5;
    transition: opacity 0.2s;
}

.rtc-video-controls {
    position: absolute;
    bottom: 8px;
    right: 8px;
    z-index: 10;
    display: flex;
    gap: 5px;
    opacity: 0;
    /* Hidden by default on desktop */
    pointer-events: none;
    /* Prevent clicking when hidden */
    transition: opacity 0.2s ease-in-out;
}

.rtc-video-wrapper:hover .rtc-video-controls {
    opacity: 1;
    /* Show controls on hover */
    pointer-events: auto;
    /* Enable clicking */
}

/* --- 4. Responsive Grid Layouts (Desktop & Tablet) --- */
@media (min-width: 768px) {
    .rtc-video-grid {
        display: grid;
        /* The grid manager JS will adjust this based on peer count */
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 16px;
        align-content: center;
        grid-auto-rows: 1fr;
    }

    /* Explicitly force side-by-side for 2 peers to avoid stacking */
    .rtc-video-grid[data-peer-count="2"] {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- 5. Mobile Layout (List View) --- */
@media (max-width: 767.98px) {
    .rtc-video-grid {
        height: auto;
        /* Allow scrolling on mobile */
        min-height: 100%;
    }

    .rtc-video-wrapper.local-peer {
        order: -1;
        /* Puts your video at the top of the list */
    }

    .rtc-video-controls {
        opacity: 0.85;
        /* Controls are always visible on mobile */
        pointer-events: auto;
        /* Always clickable on mobile */
    }
}