.remote-video-container {
    display: grid;
    gap: 0.5rem;
    width: 100%;
    height: 100%;
    padding: 0.5rem;
}

.remote-video {
    position: relative;
    aspect-ratio: 8/5;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 8px;
    background: var(--mud-palette-surface);
}

.remote-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.participant-initials {
    position: absolute;
    inset: 0;
    font-size: 3rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.participant-name {
    position: absolute;
    bottom: 8px;
    left: 8px;
    padding: 4px 8px;
    background: rgba(0,0,0,0.7);
    color: white;
    border-radius: 4px;
    font-size: 0.875rem;
    z-index: 2;
}

.participant-muted {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    background: rgba(220, 38, 38, 0.9);
    color: white;
    border-radius: 4px;
    font-size: 1.25rem;
    z-index: 2;
}

/* 1 item - full screen */
.remote-video-container:has(.remote-video:nth-child(1):last-child) {
    grid-template-columns: 1fr;
}

/* 2 items - side by side on desktop, stacked on mobile */
.remote-video-container:has(.remote-video:nth-child(2):last-child) {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .remote-video-container:has(.remote-video:nth-child(2):last-child) {
        grid-template-columns: 1fr 1fr;
    }
}

/* 3 items - 2 top, 1 bottom centered on desktop */
.remote-video-container:has(.remote-video:nth-child(3):last-child) {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .remote-video-container:has(.remote-video:nth-child(3):last-child) {
        grid-template-columns: 1fr 1fr;
    }

        .remote-video-container:has(.remote-video:nth-child(3):last-child) .remote-video:nth-child(3) {
            grid-column: 1 / -1;
            max-width: 50%;
            margin: 0 auto;
        }
}

/* 4 items - 1 column on mobile, 2x2 grid on tablet+ */
.remote-video-container:has(.remote-video:nth-child(4):last-child) {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .remote-video-container:has(.remote-video:nth-child(4):last-child) {
        grid-template-columns: 1fr 1fr;
    }
}

/* 5+ items - 3 columns on desktop, 2 on tablet, 1 on mobile */
.remote-video-container:has(.remote-video:nth-child(n+5)) {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .remote-video-container:has(.remote-video:nth-child(n+5)) {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1024px) {
    .remote-video-container:has(.remote-video:nth-child(n+5)) {
        grid-template-columns: 1fr 1fr 1fr;
    }
}


/* Main layout container - switches between grid and focus mode */
.video-call-layout {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 0.5rem;
    padding: 0.5rem;
}

/* Main content area - shows screen share */
.video-call-layout .main-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
}

/* Participants sidebar - vertical filmstrip */
.video-call-layout .participants-sidebar {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sidebar participant thumbnail */
.sidebar-participant {
    position: relative;
    aspect-ratio: 16/9;
    width: 100%;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 6px;
    background: var(--mud-palette-surface);
}

.sidebar-participant video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-participant .participant-initials {
    font-size: 1.5rem;
}

.sidebar-participant .participant-name {
    font-size: 0.75rem;
    padding: 2px 6px;
    bottom: 4px;
    left: 4px;
}

.sidebar-participant .participant-muted {
    font-size: 0.875rem;
    padding: 2px 4px;
    top: 4px;
    right: 4px;
}

/* Local video in sidebar */
.sidebar-participant.local-participant {
    border: 2px solid var(--mud-palette-primary);
}

/* Screen share in main content (focus mode) */
.main-content .screen-share-video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: auto;
    border: none;
    border-radius: 8px;
}

.main-content .screen-share-video video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Screen share paused overlay */
.screen-share-paused {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 5;
}

.screen-share-paused-content {
    text-align: center;
    color: white;
}

.screen-share-paused-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.screen-share-paused-text {
    font-size: 1rem;
    opacity: 0.9;
}

/* Responsive: sidebar becomes bottom bar on mobile */
@media (max-width: 768px) {
    .video-call-layout {
        flex-direction: column;
    }

    .video-call-layout .main-content {
        flex: 1;
        min-height: 0;
    }

    .video-call-layout .participants-sidebar {
        width: 100%;
        height: 100px;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .sidebar-participant {
        width: 120px;
        height: 100%;
        aspect-ratio: auto;
        flex-shrink: 0;
    }
}

/* Screen share styles (grid mode - legacy, kept for fallback) */
.screen-share-video {
    position: relative;
    aspect-ratio: 16/9;
    width: 100%;
    height: auto;
    min-height: 200px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--mud-palette-background);
    border: 2px solid var(--mud-palette-success);
    grid-column: 1 / -1;
}

.screen-share-video video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.screen-share-name {
    position: absolute;
    bottom: 8px;
    left: 8px;
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 4px;
    font-size: 0.875rem;
    z-index: 2;
    display: flex;
    align-items: center;
}

/* Local video - responsive positioning and sizing */
#local-video {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 240px;
    max-width: 30%;
    min-width: 100px;
    z-index: 10;
    border-radius: 8px;
    overflow: hidden;
}

#local-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    /* Local video - smaller on mobile */
    #local-video {
        width: 120px;
        max-width: 25%;
        bottom: 8px;
        right: 8px;
    }

    /* Participant initials - smaller on mobile */
    .participant-initials {
        font-size: 2rem;
    }

    /* Participant name badge - smaller on mobile */
    .participant-name {
        font-size: 0.75rem;
        padding: 2px 6px;
        bottom: 4px;
        left: 4px;
    }

    /* Muted indicator - smaller on mobile */
    .participant-muted {
        font-size: 1rem;
        padding: 2px 4px;
        top: 4px;
        right: 4px;
    }

    /* Screen share - reduced min-height on mobile */
    .screen-share-video {
        min-height: 120px;
    }

    /* Remote video container - tighter spacing */
    .remote-video-container {
        gap: 0.25rem;
        padding: 0.25rem;
    }

    /* Remote video - smaller border radius */
    .remote-video {
        border-radius: 6px;
    }
}

/* Touch device specific - ensure tap targets are minimum 44x44px */
@media (hover: none) and (pointer: coarse) {
    .participant-name,
    .participant-muted {
        min-height: 24px;
        display: flex;
        align-items: center;
    }
}
