/**
 * Nexus Call UI v1.9.2 — Telegram-style
 *
 * Полноэкранный звонок: blur background, крупные аватары с пульсацией,
 * явные состояния (Вызов / Соединение / Подключено), accept/decline в стиле
 * iOS/Telegram, мини-окно с drag-n-drop.
 */

/* ════ Корневой контейнер ════ */
.nx-call-root {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
}
.nx-call-root > * {
    pointer-events: auto;
}

/* ════ Полноэкранный режим (общий для incoming + active) ════ */
.nx-call-fullscreen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #0d1117;
    color: #fff;
    overflow: hidden;
    animation: nx-call-fade-in 0.25s ease;
}
@keyframes nx-call-fade-in {
    from { opacity: 0; transform: scale(1.02); }
    to   { opacity: 1; transform: scale(1); }
}

/* Blur-фон (gradient) — "стерильный" мерцающий синий, как в TG */
.nx-call-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at top, rgba(70, 130, 180, 0.35), transparent 60%),
        radial-gradient(ellipse at bottom, rgba(35, 80, 145, 0.45), transparent 65%),
        linear-gradient(180deg, #1a2332 0%, #0d1117 100%);
    z-index: 0;
}

/* ════ INCOMING экран ════ */
.nx-call-incoming.nx-call-fullscreen {
    z-index: 10000;
}
.nx-call-incoming .nx-call-content {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    padding: 60px 24px 48px;
    text-align: center;
}
.nx-call-status-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
}
.nx-call-type-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: -16px;
}
.nx-call-peer-name-big {
    font-size: 32px;
    font-weight: 600;
    margin-top: -16px;
}

/* Большой аватар с пульсацией */
.nx-avatar-big {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nx-avatar-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(80, 160, 230, 0.25);
    animation: nx-avatar-pulse 2.5s ease-out infinite;
}
.nx-avatar-pulse::after,
.nx-avatar-pulse::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(80, 160, 230, 0.18);
    animation: nx-avatar-pulse 2.5s ease-out infinite;
}
.nx-avatar-pulse::after  { animation-delay: 0.6s; }
.nx-avatar-pulse::before { animation-delay: 1.2s; }
@keyframes nx-avatar-pulse {
    0%   { transform: scale(1);   opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}
.nx-avatar-circle {
    position: relative;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a90e2 0%, #2c5fa0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(74, 144, 226, 0.45);
}
.nx-avatar-letter {
    font-size: 56px;
    font-weight: 600;
    color: #fff;
}

/* Кнопки accept/decline — большие круглые, iOS-style */
.nx-call-incoming-actions {
    display: flex;
    gap: 80px;
    margin-top: 16px;
}
.nx-btn-incoming {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: transform 0.15s, box-shadow 0.2s;
    position: relative;
}
.nx-btn-incoming:active { transform: scale(0.92); }

.nx-btn-reject {
    background: #ef4444;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}
.nx-btn-reject:hover { background: #dc2626; }

.nx-btn-accept {
    background: #22c55e;
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.5);
}
.nx-btn-accept:hover { background: #16a34a; }

/* Пульсирующий ring вокруг accept */
.nx-btn-accept::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 3px solid rgba(34, 197, 94, 0.5);
    animation: nx-accept-pulse 1.6s ease-out infinite;
}
@keyframes nx-accept-pulse {
    0%   { transform: scale(0.85); opacity: 1; }
    100% { transform: scale(1.4);  opacity: 0; }
}

.nx-call-incoming-labels {
    display: flex;
    gap: 80px;
    margin-top: 16px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}
.nx-call-incoming-labels span {
    width: 76px;
    text-align: center;
}

/* ════ ACTIVE звонок (full-screen) ════ */
.nx-call-full.nx-call-fullscreen {
    z-index: 9998;
}

.nx-call-remote {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
}
.nx-remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}
.nx-remote-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    z-index: 2;
}

/* Локальное видео в правом нижнем углу (picture-in-picture) */
.nx-call-local {
    position: absolute;
    bottom: 140px;
    right: 16px;
    width: 110px;
    height: 156px;
    border-radius: 12px;
    overflow: hidden;
    z-index: 3;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: #1a1a20;
}
.nx-local-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* mirror as in TG/IG */
}
.nx-call-local-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4a90e2 0%, #2c5fa0 100%);
    color: #fff;
    font-size: 38px;
    font-weight: 600;
}

/* Header — кнопка back + имя + статус */
.nx-call-header {
    position: relative;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, transparent 100%);
}
.nx-call-back {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 0;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.nx-call-back:hover { background: rgba(255, 255, 255, 0.2); }
.nx-call-header-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}
.nx-call-full .nx-call-peer-name {
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nx-call-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    font-variant-numeric: tabular-nums;
}
.nx-call-header-spacer {
    width: 38px; /* симметрия с back */
}

/* Бейдж длительности по центру сверху */
.nx-call-duration-badge {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border-radius: 14px;
    padding: 4px 12px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.95);
    pointer-events: none;
}

/* Bottom controls */
.nx-call-controls {
    position: absolute;
    bottom: 60px;
    left: 0;
    right: 0;
    z-index: 4;
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 0 16px;
}
.nx-ctl {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 0;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}
.nx-ctl:hover  { background: rgba(255, 255, 255, 0.22); }
.nx-ctl:active { transform: scale(0.92); }
.nx-ctl.off {
    background: #fff;
    color: #1a1a20;
}
.nx-ctl.off:hover { background: rgba(255, 255, 255, 0.9); }

.nx-ctl-hangup {
    background: #ef4444 !important;
    color: #fff !important;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}
.nx-ctl-hangup:hover { background: #dc2626 !important; }

.nx-call-control-labels {
    position: absolute;
    bottom: 28px;
    left: 0;
    right: 0;
    z-index: 4;
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 0 16px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
}
.nx-call-control-labels span {
    width: 60px;
    text-align: center;
}

/* ════ MINI floating widget ════ */
.nx-call-mini {
    position: fixed;
    top: 18px;
    right: 18px;
    width: 240px;
    height: 80px;
    background: #1c1c1e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    color: #fff;
    cursor: grab;
    z-index: 9999;
    user-select: none;
}
.nx-call-mini:active { cursor: grabbing; }
.nx-mini-video {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    background: #000;
    flex-shrink: 0;
    display: none; /* по умолчанию скрыто, показывается если есть локальный поток */
}
.nx-mini-video[srcobject], .nx-mini-video.has-stream { display: block; }
.nx-mini-overlay {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    overflow: hidden;
}
.nx-mini-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a90e2 0%, #2c5fa0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    flex-shrink: 0;
}
.nx-mini-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
.nx-mini-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nx-mini-duration {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.65);
    font-variant-numeric: tabular-nums;
}
.nx-mini-expand,
.nx-mini-hangup {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 0;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.nx-mini-expand:hover { background: rgba(255, 255, 255, 0.18); }
.nx-mini-hangup {
    background: rgba(239, 68, 68, 0.25);
    color: #ff6b6b;
}
.nx-mini-hangup:hover {
    background: #ef4444;
    color: #fff;
}

/* ════ Toast ════ */
.nx-call-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(8px);
    color: #fff;
    padding: 10px 18px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s;
    z-index: 10001;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.nx-call-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ════ Mobile ════ */
@media (max-width: 640px) {
    .nx-call-incoming-actions { gap: 56px; }
    .nx-call-incoming-labels { gap: 56px; }
    .nx-btn-incoming { width: 68px; height: 68px; }
    .nx-avatar-circle { width: 110px; height: 110px; }
    .nx-avatar-letter { font-size: 46px; }
    .nx-call-peer-name-big { font-size: 26px; }
    .nx-call-local { width: 88px; height: 124px; bottom: 130px; right: 12px; }
    .nx-ctl { width: 54px; height: 54px; }
    .nx-call-controls { gap: 12px; }
    .nx-call-control-labels { gap: 12px; }
    .nx-call-control-labels span { width: 54px; }
    .nx-call-mini { width: 200px; }
}
