/* ══════ LiveKit room page ══════ */
.lk-loading {
    text-align: center;
    padding: 48px;
}

.lk-toolbar {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    align-items: center;
    flex-wrap: wrap;
    color: var(--mud-palette-text-primary);
}

.lk-tool-btn {
    transition: background-color 0.15s, color 0.15s;
}

.lk-tool-btn:hover {
    background: var(--mud-palette-action-default-hover) !important;
    color: var(--mud-palette-primary) !important;
}

.lk-tool-divider {
    width: 1px;
    height: 24px;
    background: var(--mud-palette-lines-default);
    margin: 0 6px;
}

.lk-participant-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    color: var(--mud-palette-text-secondary);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
    .lk-participant-count__label {
        display: none;
    }

    .lk-tool-desktop {
        display: none !important;
    }
}

.lk-tool-btn--danger {
    color: var(--mud-palette-error) !important;
}

.lk-tool-btn--danger:hover {
    background: rgba(var(--mud-palette-error-rgb), 0.12) !important;
}

.lk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 12px;
    background: var(--mud-palette-background);
}

.lk-grid:fullscreen {
    padding: 12px;
    align-content: center;
}

.lk-participant {
    position: relative;
    background: var(--mud-palette-surface);
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16/9;
}

.lk-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.lk-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 48px;
    font-weight: 600;
    letter-spacing: 2px;
    user-select: none;
}

.lk-participant:hover {
    cursor: pointer;
}

.lk-participant:fullscreen {
    aspect-ratio: auto;
    border-radius: 0;
    background: #000;
}

.lk-participant:fullscreen .lk-video {
    border-radius: 0;
    object-fit: contain;
}

.lk-name-tag {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 13px;
}

.lk-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: stretch;
}

.lk-layout--chat {
    grid-template-columns: minmax(0, 1fr) 360px;
    height: 70vh;
    min-height: 420px;
}

.lk-layout--chat .lk-grid {
    height: 100%;
}

.lk-layout--chat .lk-participant {
    aspect-ratio: auto;
    height: 100%;
}

.lk-layout--chat .room-chat-panel {
    height: auto;
    min-height: 0;
}

@media (max-width: 768px) {
    .lk-layout--chat {
        grid-template-columns: 1fr;
        height: auto;
    }

    .lk-layout--chat .lk-participant {
        aspect-ratio: 16/9;
        height: auto;
    }

    .lk-layout--chat .room-chat-panel {
        height: 70vh;
        min-height: 420px;
    }
}

.room-chat-panel {
    display: flex;
    flex-direction: column;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 12px;
    overflow: hidden;
    height: 70vh;
    min-height: 420px;
}

.room-chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 8px 16px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    font-weight: 600;
}

.room-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}

/* ══════ Mini-PiP виджет (свернутая комната) ══════ */
/* От 600px — окно с видео в углу (d-none d-sm-flex), на телефоне вместо него полоса .lk-callbar под шапкой. */
.lk-pip {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 320px;
    height: 220px;
    z-index: calc(var(--mud-zindex-popover) - 1);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    background: #000;
    display: flex;
    flex-direction: column;
}

.lk-pip__video {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    cursor: pointer;
}

/* В окне одна плитка — та, что livekit-room.js пометил главной (кто говорит); остальные, в том числе своя, скрыты. */
.lk-pip__video .lk-participant {
    display: none;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
}

.lk-pip__video .lk-participant--featured {
    display: block;
}

/* Счётчик участников поверх видео; сосед контейнера, а не потомок — attach() очищает контейнер. */
.lk-pip__count {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px 2px 6px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.95);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

.lk-pip__video .lk-participant:hover {
    outline: none;
}

.lk-pip__video .lk-placeholder {
    font-size: 28px;
    letter-spacing: 1px;
}

.lk-pip__video .lk-name-tag {
    font-size: 11px;
    bottom: 4px;
    left: 4px;
    padding: 1px 6px;
}

.lk-pip__bar {
    display: flex;
    gap: 2px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
}

.lk-pip__bar .mud-icon-button,
.lk-pip__bar .mud-icon-button .mud-icon-root,
.lk-pip__bar .mud-icon-button svg {
    color: #fff !important;
    fill: currentColor;
}

.lk-pip__bar .mud-icon-button.mud-error-text,
.lk-pip__bar .mud-icon-button.mud-error-text .mud-icon-root,
.lk-pip__bar .mud-icon-button.mud-error-text svg {
    color: var(--mud-palette-error) !important;
}

/* ══════ Полоса свёрнутого звонка на телефоне (до 600px, d-flex d-sm-none) ══════ */
/* Стоит в потоке сразу под шапкой и едет вместе с ней; меню по кнопке (z-index 99) её перекрывает. */
.lk-callbar {
    position: sticky;
    top: var(--header-h);
    z-index: 98;
    min-height: 44px;
    padding: 0 var(--page-gutter);
    background: rgba(var(--mud-palette-success-rgb), 0.12);
    border-bottom: 1px solid var(--mud-palette-success);
    color: var(--mud-palette-text-primary);
    font-size: 14px;
}

/* Страницы во весь экран (чат) вычитают высоту полосы из своей; на компьютере полосы нет — переменная пуста. */
@media (max-width: 599.98px) {
    body:has(.lk-callbar) {
        --lk-callbar-h: 44px;
    }
}

.lk-callbar__icon {
    color: var(--mud-palette-success);
}

.lk-callbar__text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
