: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;
    height: 100%;
    overflow: hidden;
}

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

.panel,
.stage {
    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;
}

.stage {
    padding: 10px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 10px;
    min-height: 0;
}

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;
}

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 {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #4d6cad;
    background: rgba(47, 115, 255, 0.14);
    font-size: 13px;
}

.stage-controls {
    justify-content: flex-start;
}

.videos {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 10px;
    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;
}

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

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

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

video.video-fill {
    object-fit: cover;
}

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

.log {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #0f182d;
    padding: 8px;
    height: 220px;
    overflow: auto;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    color: #c6d7ff;
    white-space: pre-wrap;
}

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

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

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

body.embedded .wrap {
    width: calc(100vw - 12px);
    margin: 6px;
}

body.embedded #introBlock,
body.embedded #serverBlock,
body.embedded #identityBlock,
body.embedded #connectionButtons {
    display: none;
}

/* Режим просмотра: только видео собеседника */
body.video-focus .wrap {
    grid-template-columns: 1fr;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    margin: 0;
}

body.video-focus .panel,
body.video-focus .stage-controls #btnFitMode,
body.video-focus .stage-controls #btnFullscreen,
body.video-focus .video-title,
body.video-focus .log,
body.video-focus .local {
    display: none;
}

body.video-focus .stage-controls {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
}

body.video-focus .stage {
    min-height: 100vh;
    padding: 0;
    border: 0;
    border-radius: 0;
    grid-template-rows: 1fr;
    background: #000;
}

body.video-focus .videos {
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 100vh;
}

body.video-focus .remote {
    padding: 0;
    border: 0;
    border-radius: 0;
    min-height: 100vh;
    background: #000;
}

body.video-focus #remoteVideo {
    width: 100vw;
    height: 100vh;
    min-height: 0;
    border-radius: 0;
}

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 .stage-controls,
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 {
    display: block;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #000;
}

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

body.video-fullscreen #remoteVideo.video-fill {
    object-fit: cover;
}

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

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