/* Make #table a positioning context for absolute children */
#table {
    position: relative;
}

/* Video PIP - positioned in top-right of #table card area */
#video-join-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

#video-pip {
    position: fixed;
    top: 8px;
    right: 8px;
    width: 320px;
    height: 240px;
    min-width: 160px;
    min-height: 120px;
    background: #000;
    border-radius: 4px;
    overflow: auto;
    resize: both;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
}

#video-pip.visible {
    display: flex;
}

#video-pip .pip-display {
    background: #1a1a1a;
    position: relative;
    overflow: hidden;
    flex: 1;
}

#video-pip .pip-display.grid-mode {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 1px;
}

#video-pip .pip-display.speaker-mode {
    display: flex;
    align-items: center;
    justify-content: center;
}

#video-pip .pip-display video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Grid tile */
.pip-tile {
    position: relative;
    overflow: hidden;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pip-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pip-tile-name {
    position: absolute;
    bottom: 2px;
    left: 3px;
    font-size: 9px;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 0 3px;
    border-radius: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 6px);
}

.pip-tile.speaking {
    border: 2px solid #28a745;
}

.pip-tile-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    color: #fff;
}

#video-pip .pip-speaker {
    position: absolute;
    bottom: 4px;
    left: 6px;
    font-size: 10px;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 1px 5px;
    border-radius: 2px;
}

#video-pip .pip-speaking-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #28a745;
    margin-right: 3px;
    animation: pip-pulse 1.2s infinite;
}

@keyframes pip-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

#video-pip .pip-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
}

#video-pip .pip-controls {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 3px 4px;
    background: rgba(0, 0, 0, 0.8);
    cursor: grab;
}

#video-pip .pip-controls.dragging {
    cursor: grabbing;
}

#video-pip .pip-controls button {
    border: none;
    border-radius: 3px;
    font-size: 10px;
    padding: 2px 6px;
    cursor: pointer;
    color: #fff;
}

#video-pip .pip-btn-on {
    background: #28a745;
}

#video-pip .pip-btn-off {
    background: #dc3545;
}

#video-pip .pip-btn-close {
    background: #6c757d;
}

#video-pip .pip-status {
    font-size: 10px;
    color: #aaa;
    text-align: center;
    padding: 2px;
}

#video-pip .pip-btn-view {
    background: #17a2b8;
}
