/* pass99-minimized-calls-video-upload-mirror
   Active direct calls can be minimized without ending WebRTC.
   The full overlay is restored from the ongoing-call bar or mini video preview. */
:root {
    --ongoing-call-bar-height: 0px;
}

body.has-minimized-call {
    --ongoing-call-bar-height: 52px;
}

.ongoing-call-bar {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    z-index: 1400;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.96), rgba(37, 99, 235, 0.96));
    color: #fff;
    box-shadow: 0 14px 42px rgba(15, 23, 42, 0.34);
    font: 700 0.85rem/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ongoing-call-bar[hidden],
.floating-call-video[hidden] {
    display: none !important;
}

.ongoing-call-bar i {
    flex: 0 0 auto;
}

.ongoing-call-bar strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ongoing-call-bar span {
    opacity: 0.92;
    font-weight: 700;
    white-space: nowrap;
}

.floating-call-video {
    position: fixed;
    z-index: 1390;
    right: max(12px, env(safe-area-inset-right));
    top: calc(50vh - 62px);
    width: 104px;
    height: 146px;
    border-radius: 18px;
    overflow: hidden;
    background: #020617;
    border: 2px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.floating-call-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #020617;
}

.floating-call-video::after {
    content: "LIVE";
    position: absolute;
    left: 7px;
    bottom: 7px;
    padding: 3px 6px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 900;
    letter-spacing: 0.08em;
}

body[data-stellar-theme^="terminal-"] .ongoing-call-bar,
html[data-stellar-theme^="terminal-"] .ongoing-call-bar {
    border-radius: 0 !important;
    border: 1px solid var(--terminal-fg, #00ff66) !important;
    background: var(--terminal-bg, #000) !important;
    color: var(--terminal-fg, #00ff66) !important;
    box-shadow: none !important;
    font-family: "Courier New", "Liberation Mono", monospace !important;
}

body[data-stellar-theme^="terminal-"] .floating-call-video,
html[data-stellar-theme^="terminal-"] .floating-call-video {
    border-radius: 0 !important;
    border: 1px solid var(--terminal-fg, #00ff66) !important;
    box-shadow: none !important;
    background: var(--terminal-bg, #000) !important;
}

body[data-stellar-theme^="terminal-"] .floating-call-video::after,
html[data-stellar-theme^="terminal-"] .floating-call-video::after {
    border-radius: 0 !important;
    background: var(--terminal-bg, #000) !important;
    color: var(--terminal-fg, #00ff66) !important;
    border: 1px solid var(--terminal-fg, #00ff66) !important;
}

/* Terminal fast-mode had broad transform resets. Local self preview must stay mirrored, including rear camera per current product requirement. */
body[data-stellar-theme^="terminal-"] [data-call-local-video],
html[data-stellar-theme^="terminal-"] [data-call-local-video],
[data-call-local-video][data-mirror="1"] {
    transform: scaleX(-1) !important;
    transform-origin: center center !important;
}

/* pass103-global-back-to-chat-button: fixed global call minimize control, outside overlay/card so video-call CSS cannot swallow it. */
.call-global-back-to-chat-button {
    position: fixed !important;
    top: max(12px, env(safe-area-inset-top)) !important;
    left: max(12px, env(safe-area-inset-left)) !important;
    z-index: 2147483000 !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    min-height: 44px !important;
    padding: 0 16px !important;
    border: 1px solid rgba(255, 255, 255, 0.34) !important;
    border-radius: 999px !important;
    background: rgba(2, 6, 23, 0.92) !important;
    color: #ffffff !important;
    font: 800 0.92rem/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: transparent !important;
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.42) !important;
}

.call-global-back-to-chat-button.is-visible:not([hidden]) {
    display: inline-flex !important;
}

.call-global-back-to-chat-button[hidden] {
    display: none !important;
}

.call-global-back-to-chat-button i {
    font-size: 0.9rem !important;
}

[data-theme="terminal-dark"] .call-global-back-to-chat-button,
[data-theme="terminal-light"] .call-global-back-to-chat-button,
body.theme-terminal-dark .call-global-back-to-chat-button,
body.theme-terminal-light .call-global-back-to-chat-button,
html[data-stellar-theme^="terminal-"] .call-global-back-to-chat-button,
body[data-stellar-theme^="terminal-"] .call-global-back-to-chat-button {
    border-radius: 0 !important;
    background: var(--terminal-bg, #000000) !important;
    color: var(--terminal-fg, #00ff66) !important;
    border: 1px solid var(--terminal-border, #00ff66) !important;
    box-shadow: none !important;
    text-shadow: none !important;
    backdrop-filter: none !important;
    font-family: "Courier New", "Liberation Mono", monospace !important;
}

/* pass104-call-bar-local-time: full-call Back to chat button is hidden once the call is minimized into the chat bar. */
body.has-minimized-call #callBackToChatGlobalButton,
body.has-minimized-call .call-global-back-to-chat-button,
.call-global-back-to-chat-button[data-call-button-state="hidden"] {
    display: none !important;
    pointer-events: none !important;
}

/* The minimized top bar returns to the call; it is not another Back to chat button. */
#ongoingCallBar.ongoing-call-bar {
    cursor: pointer;
}

/* pass106-call-bar-reserved-space
   The minimized call bar is app chrome: it stays visible, but the app content is
   pushed down so headers/back/media controls are not covered. This deliberately
   overrides earlier fixed/relative experiments. */
body.has-minimized-call {
    --ongoing-call-bar-height: 52px !important;
}

body.has-minimized-call #ongoingCallBar.ongoing-call-bar,
body.has-minimized-call #appShell > #ongoingCallBar.ongoing-call-bar,
body.has-minimized-call #appShell > .ongoing-call-bar.is-integrated {
    position: fixed !important;
    top: max(8px, env(safe-area-inset-top)) !important;
    left: max(10px, env(safe-area-inset-left)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    width: auto !important;
    min-height: 42px !important;
    margin: 0 !important;
    z-index: 820 !important;
    transform: none !important;
}

/* Reserve real space for the fixed bar so it stops sitting on top of chat headers. */
body.has-minimized-call #appShell {
    padding-top: calc(var(--mobile-top-gap, 0px) + var(--ongoing-call-bar-height) + max(8px, env(safe-area-inset-top))) !important;
}

body.has-minimized-call:not(.call-overlay-restored) #appShell > .app-screen,
body.has-minimized-call:not(.call-overlay-restored) .app-screen.is-active {
    height: calc(100dvh - var(--mobile-top-gap, 0px) - var(--ongoing-call-bar-height) - max(8px, env(safe-area-inset-top))) !important;
}

body.has-minimized-call #appShell > .app-screen {
    padding-top: 12px !important;
}

/* In a chat thread, keep the header and its back/call/menu buttons touchable below the call bar. */
body.has-minimized-call #chatThreadView.chat-thread {
    height: calc(100dvh - var(--nav-height, 84px) - var(--ongoing-call-bar-height) - 36px) !important;
}

/* Full-screen viewers and modals must beat the minimized call bar. */
.chat-media-viewer,
.media-viewer,
.image-viewer,
.lightbox,
[data-media-viewer],
[data-image-viewer] {
    z-index: 2147482000 !important;
}

/* The floating video preview is still allowed to float, but it must not outrank real media viewers. */
body.has-minimized-call .floating-call-video {
    z-index: 780 !important;
}

/* If the full call overlay is visible again, the minimized bar must never reserve space. */
body:not(.has-minimized-call) {
    --ongoing-call-bar-height: 0px !important;
}


/* pass107-stable-callbar-disable-old-reserved-space */
/* pass107 moved the stable call-bar overrides to message-edit.css loaded last. */
