/* ===================================================================
   ESTILOS DE VOZ, VÍDEO & COMPARTILHAMENTO DE TELA (WebRTC)
   =================================================================== */

.webrtc-workspace {
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.webrtc-header {
    height: 48px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.room-status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 700;
}

.live-dot {
    width: 10px;
    height: 10px;
    background-color: var(--online-green);
    border-radius: var(--radius-full);
    animation: livePulse 1.8s infinite;
}

.pill-badge {
    background: var(--accent-pink-soft);
    color: var(--accent-pink);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-full);
}

/* Grid de Vídeos e Participantes */
.video-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-auto-rows: max-content;
    gap: 16px;
    padding: 20px 20px 110px 20px;
    overflow-y: auto;
    align-content: start;
    align-items: stretch;
    justify-content: center;
}

.video-grid.multi-screen {
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
}

/* Card do Participante */
.participant-tile {
    position: relative;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    aspect-ratio: 16 / 9;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Indicador de Fala (Glow Verde) */
.participant-tile.speaking {
    border-color: var(--online-green) !important;
    box-shadow: 0 0 16px rgba(46, 204, 113, 0.45) !important;
}

/* Elemento <video> (Câmera ou Compartilhamento de Tela) */
.participant-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000000;
}

.participant-video.screen-share {
    object-fit: contain;
}

/* Se não estiver com vídeo/tela: exibe avatar central */
.participant-avatar-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.participant-avatar-view img {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    border: 3px solid var(--border-color);
    object-fit: cover;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.participant-tile.speaking .participant-avatar-view img {
    border-color: var(--online-green);
    transform: scale(1.08);
}

/* Informações do Participante (Barra inferior no tile) */
.participant-overlay {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
}

.participant-tag {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    color: #ffffff;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
}

.participant-icons {
    display: flex;
    gap: 4px;
}

.state-pill {
    background: rgba(0, 0, 0, 0.65);
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

/* Tile de Tela Cheia / Destaque (quando apenas 1 tela está sendo compartilhada) */
.participant-tile.featured-screen {
    grid-column: 1 / -1;
    aspect-ratio: auto;
    height: min(56vh, 520px);
    min-height: 260px;
}

/* Quando 2 ou mais telas estão sendo compartilhadas, ficam lado a lado sem sobreposição */
.video-grid.multi-screen .participant-tile.featured-screen {
    grid-column: auto;
    aspect-ratio: 16 / 9;
    height: auto;
    min-height: 240px;
    max-height: 460px;
}

/* Transmissão priorizada / fixada: fica maior no topo, mesmo com várias telas abertas */
.participant-tile.pinned-screen,
.video-grid.multi-screen .participant-tile.pinned-screen {
    grid-column: 1 / -1;
    order: -1;
    aspect-ratio: auto;
    height: min(64vh, 600px);
    min-height: 300px;
    max-height: none;
    border-color: var(--accent-pink);
}

/* Modo Tela Cheia (Fullscreen) da transmissão */
.participant-tile:fullscreen,
.participant-tile:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border: none;
    border-radius: 0;
    background: #000000;
}

.participant-tile:fullscreen .participant-video,
.participant-tile:-webkit-full-screen .participant-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.participant-tag.clickable-user {
    pointer-events: auto;
    cursor: pointer;
}

.participant-tag.clickable-user:hover {
    background: rgba(0, 0, 0, 0.85);
    text-decoration: underline;
}

.tile-action-btn.pinned-active {
    background: var(--accent-pink);
    border-color: var(--accent-pink);
    color: #ffffff;
}

/* Barra superior de controles por participante (Volume / Fechar Tela / Fechar Câmera) */
.tile-top-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 15;
}

.tile-action-btn {
    background: rgba(15, 15, 20, 0.78);
    backdrop-filter: blur(6px);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, transform 0.12s ease;
}

.tile-action-btn:hover {
    background: rgba(30, 30, 40, 0.95);
    transform: translateY(-1px);
}

.tile-action-btn.danger-action {
    background: rgba(231, 76, 60, 0.85);
    border-color: rgba(255, 255, 255, 0.2);
}

.tile-action-btn.danger-action:hover {
    background: rgba(192, 57, 43, 0.95);
}

/* Popover de Volume Individual (Voz + Transmissão) */
.tile-volume-popover {
    position: absolute;
    top: 42px;
    right: 10px;
    width: 220px;
    background: rgba(18, 18, 24, 0.94);
    backdrop-filter: blur(8px);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    z-index: 25;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    display: none;
    flex-direction: column;
    gap: 10px;
}

.tile-volume-popover.open {
    display: flex;
}

.volume-control-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.volume-control-row label {
    display: flex;
    justify-content: space-between;
    font-size: 0.74rem;
    font-weight: 600;
    color: #f1f5f9;
}

.volume-slider {
    width: 100%;
    accent-color: var(--accent-pink);
    cursor: pointer;
}

/* Barra Flutuante de Controles WebRTC */
.webrtc-control-bar {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    padding: 10px 18px;
    border-radius: var(--radius-full);
    z-index: 100;
}

.webrtc-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.webrtc-btn .icon {
    font-size: 1.25rem;
}

.webrtc-btn .btn-label {
    font-size: 0.7rem;
    font-weight: 700;
}

.webrtc-btn:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.webrtc-btn.active {
    background: var(--accent-pink-soft);
    border-color: var(--accent-pink);
    color: var(--accent-pink);
}

.webrtc-btn.danger {
    background: #ff4757;
    border-color: #ff4757;
    color: #ffffff;
}

.webrtc-btn.danger:hover {
    background: #e84118;
}

.webrtc-btn.highlight-screen {
    background: var(--accent-gradient);
    color: #ffffff;
    border: none;
}

@keyframes livePulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}
