﻿:root {
    --bg: #0b1220;
    --card: #141d31;
    --card-2: #1a2742;
    --line: #2a3b62;
    --text: #e9f0ff;
    --muted: #9fb2d8;
    --blue: #2f73ff;
    --green: #1f9d55;
    --red: #cc3940;
    --yellow: #d48d00;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at 20% 0%, #1a2a4a, var(--bg) 55%);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, sans-serif;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.wrap {
    width: calc(100vw - 24px);
    margin: 12px auto;
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    gap: 12px;
    height: calc(100vh - 24px);
    min-height: 0;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: linear-gradient(180deg, var(--card), var(--card-2));
}

.panel {
    padding: 12px;
    display: grid;
    gap: 10px;
    align-content: start;
    grid-template-rows: repeat(11, auto) 220px minmax(140px, 190px);
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-color: var(--line) #0b1220;
    scrollbar-width: thin;
}

.panel::-webkit-scrollbar {
    width: 10px;
}

.panel::-webkit-scrollbar-track {
    background: #0b1220;
    border-radius: 10px;
}

.panel::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--line), #3f5f9f);
    border: 2px solid #0b1220;
    border-radius: 10px;
}

.panel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #4f72bb, var(--blue));
}

.stage {
    padding: 0;
    display: grid;
    grid-template-rows: 1fr;
    gap: 0;
    min-height: 0;
    overflow: hidden;
}

h1 {
    margin: 0 0 6px;
    font-size: 20px;
}

.caption {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

label {
    display: grid;
    gap: 4px;
    font-size: 13px;
    color: var(--muted);
}

input,
select,
button,
textarea {
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #0f182d;
    color: var(--text);
    font-size: 14px;
    padding: 8px 10px;
}

select {
    width: 100%;
}

.row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

#profileBlock {
    align-items: end;
}

#profileBlock .profile-name {
    flex: 1;
}

#profileBlock #btnOpenBrowser {
    white-space: nowrap;
}

body:not(.embedded) #btnOpenBrowser {
    display: none;
}

button {
    cursor: pointer;
    background: #20345e;
}

button.primary {
    background: var(--blue);
    border-color: #3f7fff;
}

button.accept {
    background: var(--green);
    border-color: #23b261;
}

button.reject {
    background: var(--red);
    border-color: #dd4c53;
}

button.warn {
    background: var(--yellow);
    border-color: #f0a717;
    color: #2b1f00;
}

button:disabled {
    opacity: 0.55;
    cursor: default;
}

.status {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #0f1a34;
    color: var(--muted);
    font-size: 13px;
    min-height: 36px;
}

.incoming {
    display: none;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #4d6cad;
    background: rgba(47, 115, 255, 0.14);
    font-size: 13px;
}

.videos {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 0;
}

.video-box {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    background: #101b34;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 8px;
    min-height: 0;
    overflow: hidden;
}

.video-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.video-heading {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.video-box h2 {
    margin: 0;
    font-size: 14px;
}

.icon-button {
    width: 26px;
    height: 24px;
    min-width: 26px;
    padding: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: #20345e;
}

.icon-button svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

#localMetrics {
    white-space: pre-line;
    text-align: right;
}

video {
    width: 100%;
    height: 100%;
    min-height: 340px;
    border-radius: 8px;
    background: #04080f;
    object-fit: contain;
}

.mic-meter {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #07101f;
    border: 1px solid var(--line);
}

.mic-meter span {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green), var(--yellow));
    transition: width 80ms linear;
}

.panel .local {
    height: 220px;
    min-height: 0;
    overflow: hidden;
    grid-template-rows: auto auto 1fr;
}

.panel .local video {
    height: 100%;
    min-height: 0;
}

.stage .remote video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
    justify-self: center;
    align-self: center;
    object-fit: contain;
}

.stage .remote.has-remote-video video.video-native-size {
    width: var(--remote-render-width);
    height: var(--remote-render-height);
    max-width: none;
    max-height: none;
    object-fit: none;
    object-position: center center;
}

#remoteVideo:fullscreen,
#remoteVideo:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    min-height: 0;
    border-radius: 0;
    background: #000;
    object-fit: scale-down;
}

.log {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #0f182d;
    padding: 8px;
    height: 190px;
    min-height: 0;
    max-height: 190px;
    overflow-y: scroll;
    overflow-x: hidden;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    color: #c6d7ff;
    white-space: pre-wrap;
    scrollbar-color: var(--line) #0b1220;
    scrollbar-width: thin;
}

.log::-webkit-scrollbar {
    width: 10px;
}

.log::-webkit-scrollbar-track {
    background: #0b1220;
    border-radius: 10px;
}

.log::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--line), #3f5f9f);
    border: 2px solid #0b1220;
    border-radius: 10px;
}

.log::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #4f72bb, var(--blue));
}

.inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
}

.quality-panel {
    margin: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    display: grid;
    gap: 8px;
    min-width: 0;
}

.quality-panel summary {
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    user-select: none;
}

.quality-panel[open] summary {
    margin-bottom: 8px;
}

.quality-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.quality-panel #btnApplyQuality {
    margin-top: 6px;
}

.incoming-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    background: rgba(4, 8, 15, 0.55);
    backdrop-filter: blur(4px);
}

.incoming-overlay[hidden] {
    display: none;
}

.incoming-card {
    width: min(420px, calc(100vw - 32px));
    padding: 22px;
    border: 1px solid #4d6cad;
    border-radius: 18px;
    background: linear-gradient(180deg, #18294b, #101b34);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    display: grid;
    gap: 18px;
    text-align: center;
}

.incoming-title {
    font-size: 20px;
    font-weight: 700;
}

.incoming-actions {
    justify-content: center;
}

.incoming-actions button {
    min-width: 140px;
}

/* Встроенный режим внутри Avalonia: убираем дублирующий блок подключения сверху */
body.embedded {
    background: #0b1220;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body.embedded .wrap {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

body.embedded .stage {
    min-height: 0;
}

body.embedded .videos,
body.embedded .remote {
    height: 100%;
    min-height: 0;
}

body.embedded .video-box {
    padding: 10px;
    gap: 10px;
}

#introBlock,
#serverBlock,
#roomBlock,
#connectionButtons {
    display: none;
}

body.video-fullscreen {
    background: #000;
}

body.video-fullscreen .wrap {
    display: block;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    margin: 0;
}

body.video-fullscreen .panel,
body.video-fullscreen .video-title,
body.video-fullscreen .local,
body.video-fullscreen .log {
    display: none;
}

body.video-fullscreen .stage {
    display: block;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #000;
}

body.video-fullscreen .videos,
body.video-fullscreen .remote {
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #000;
}

body.video-fullscreen .videos {
    display: block;
}

body.video-fullscreen .remote {
    display: flex;
    align-items: center;
    justify-content: center;
}

body.video-fullscreen #remoteVideo {
    display: block;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    min-height: 0;
    border-radius: 0;
    background: #000;
    object-fit: contain;
}

body.video-fullscreen #remoteVideo.video-native-size {
    width: var(--remote-render-width);
    height: var(--remote-render-height);
    max-width: none;
    max-height: none;
    object-fit: none;
    object-position: center center;
}

.audio-signal-toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 10000;
    max-width: min(520px, calc(100vw - 48px));
    padding: 14px 18px;
    border-radius: 14px;
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.45);
}

.audio-signal-toast.danger {
    background: linear-gradient(135deg, #dc2626, #991b1b);
}

.audio-signal-toast.success {
    background: linear-gradient(135deg, #16a34a, #166534);
}

.audio-signal-toast[hidden] {
    display: none;
}

@media (max-width: 1200px) {
    .wrap {
        grid-template-columns: 1fr;
    }

    .videos {
        grid-template-columns: 1fr;
    }
}

@media (max-height: 820px) {
    .panel {
        grid-template-rows: repeat(11, auto) 180px 170px;
        align-content: start;
    }

    .panel .local {
        height: 180px;
    }

    .log {
        height: 170px;
        max-height: 170px;
    }
}
