/* ═══ calls.css — UI звонков ═══ */

/* ── Кнопка звонка в хедере чата ── */
.call-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: color .2s, background .2s;
}
.call-btn:hover {
    color: var(--accent);
    background: var(--bg-hover);
}
.call-btn:active {
    transform: scale(.92);
}

/* ── Полноэкранный overlay звонка ── */
.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
}
.call-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Верхний блок: имя + статус */
.call-info {
    text-align: center;
    margin-bottom: 24px;
}
.call-peer-name {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.call-status-text {
    color: rgba(255,255,255,.6);
    font-size: .85rem;
}
.call-timer {
    color: rgba(255,255,255,.8);
    font-size: 1.1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-top: 4px;
}

/* Аватар */
.call-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 2.5rem;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.call-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Пульсация при звонке (ringing) */
.call-avatar.ringing::before,
.call-avatar.ringing::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.25);
    animation: call-pulse 1.8s ease-out infinite;
}
.call-avatar.ringing::after {
    animation-delay: .6s;
}
@keyframes call-pulse {
    0%   { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Панель кнопок */
.call-controls {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-top: 40px;
}
.call-ctrl-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    transition: transform .15s, background .2s;
    color: #fff;
}
.call-ctrl-btn:active {
    transform: scale(.9);
}

.call-ctrl-btn.mute     { background: rgba(255,255,255,.15); }
.call-ctrl-btn.mute.on  { background: #e45e5e; }
.call-ctrl-btn.video    { background: rgba(255,255,255,.15); }
.call-ctrl-btn.video.on { background: #e45e5e; }
.call-ctrl-btn.speaker  { background: rgba(255,255,255,.15); }
.call-ctrl-btn.speaker.on { background: var(--accent); }
.call-ctrl-btn.screen   { background: rgba(255,255,255,.15); }
.call-ctrl-btn.screen.on { background: #166534; }
.call-ctrl-btn.settings { background: rgba(255,255,255,.15); }
.call-ctrl-btn.settings.on { background: rgba(255,255,255,.3); }
.call-ctrl-btn.add-person { background: rgba(74,222,128,.2); }

/* Flip camera button — поверх локального видео */
.call-local-wrap {
    position: absolute;
    bottom: 140px;
    right: 16px;
    width: 120px;
    height: 160px;
    z-index: 2;
}
.call-local-wrap .call-video-local {
    position: static;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    object-fit: cover;
    background: #222;
    border: 2px solid rgba(255,255,255,.2);
}
.call-flip-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.45);
    color: #fff;
    font-size: .85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: background .15s, transform .3s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.call-flip-btn:hover {
    background: rgba(0,0,0,.65);
}
.call-flip-btn:active {
    transform: scale(.85);
}
.call-flip-btn.flipping {
    animation: flipSpin .4s ease;
}
@keyframes flipSpin {
    0% { transform: rotateY(0); }
    100% { transform: rotateY(180deg); }
}
/* Групповой звонок — flip в ячейке */
.gcall-cell .call-flip-btn {
    top: 6px;
    right: 6px;
}
@media (max-width: 768px) {
    .call-local-wrap {
        width: 90px;
        height: 120px;
        bottom: 120px;
        right: 12px;
    }
    .call-flip-btn {
        width: 28px;
        height: 28px;
        font-size: .75rem;
        top: 4px;
        right: 4px;
    }
}

/* Settings panel */
.call-settings-panel {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(22,33,62,.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 16px;
    padding: 16px 20px;
    min-width: 300px;
    max-width: 400px;
    z-index: 10001;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}
.call-settings-panel.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}
.call-settings-title {
    font-size: .75rem;
    font-weight: 700;
    color: rgba(255,255,255,.5);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 12px;
}
.call-settings-row {
    margin-bottom: 10px;
}
.call-settings-row:last-child { margin-bottom: 0; }
.call-settings-label {
    display: block;
    font-size: .7rem;
    color: rgba(255,255,255,.5);
    margin-bottom: 4px;
}
.call-settings-select {
    width: 100%;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.08);
    color: #fff;
    font-size: .8rem;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    transition: border-color .15s;
}
.call-settings-select:focus {
    border-color: rgba(94,181,247,.6);
}
.call-settings-select option {
    background: #1a1a2e;
    color: #fff;
}
@media (max-width: 768px) {
    .call-settings-panel {
        min-width: 260px;
        max-width: calc(100vw - 32px);
        bottom: 100px;
    }
}
.call-ctrl-btn.hangup   { background: #e45e5e; width: 70px; height: 70px; font-size: 1.5rem; }
.call-ctrl-btn.accept   { background: #16a34a; width: 70px; height: 70px; font-size: 1.5rem; }
.call-ctrl-btn.accept-audio { background: #3b82f6; width: 60px; height: 60px; font-size: 1.2rem; }

.call-ctrl-label {
    font-size: .6rem;
    color: rgba(255,255,255,.5);
    text-align: center;
    margin-top: 4px;
}

/* Входящий звонок: две кнопки (отклонить / принять) */
.call-incoming-btns {
    display: flex;
    gap: 50px;
    align-items: center;
    margin-top: 40px;
}
.call-incoming-btns .call-ctrl-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Видео контейнеры */
.call-video-wrap {
    position: absolute;
    inset: 0;
    display: none;
}
.call-overlay.video-active .call-video-wrap {
    display: block;
}
.call-video-remote {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}
/* call-video-local теперь внутри .call-local-wrap, стили там */
.call-video-local {
    cursor: grab;
}
.call-overlay.video-active .call-info {
    position: absolute;
    top: 40px;
    left: 0;
    right: 0;
    z-index: 2;
    text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.call-overlay.video-active .call-avatar {
    display: none;
}
.call-overlay.video-active .call-controls {
    position: absolute;
    bottom: 40px;
    left: 0;
    right: 0;
    justify-content: center;
    z-index: 2;
}

/* Адаптив для мобильных */
@media (max-width: 768px) {
    .call-avatar {
        width: 100px;
        height: 100px;
        font-size: 2rem;
    }
    .call-peer-name {
        font-size: 1.2rem;
    }
    .call-ctrl-btn {
        width: 54px;
        height: 54px;
        font-size: 1.1rem;
    }
    .call-ctrl-btn.hangup,
    .call-ctrl-btn.accept {
        width: 62px;
        height: 62px;
    }
    /* call-video-local стили теперь в .call-local-wrap media query */
}

/* Звуковая индикация (визуальная) */
.call-audio-indicator {
    display: flex;
    gap: 3px;
    align-items: center;
    justify-content: center;
    height: 24px;
    margin-top: 8px;
}
.call-audio-bar {
    width: 3px;
    background: #4ade80;
    border-radius: 2px;
    animation: call-audio-bounce 1s ease-in-out infinite;
}
.call-audio-bar:nth-child(1) { height: 8px;  animation-delay: 0s; }
.call-audio-bar:nth-child(2) { height: 14px; animation-delay: .15s; }
.call-audio-bar:nth-child(3) { height: 10px; animation-delay: .3s; }
.call-audio-bar:nth-child(4) { height: 16px; animation-delay: .45s; }
.call-audio-bar:nth-child(5) { height: 8px;  animation-delay: .6s; }

@keyframes call-audio-bounce {
    0%, 100% { transform: scaleY(1); }
    50%      { transform: scaleY(1.8); }
}

/* Плавный toast */
.call-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    background: rgba(0,0,0,.85);
    color: #fff;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: .8rem;
    font-weight: 600;
    z-index: 10001;
    transition: transform .3s ease;
    pointer-events: none;
}
.call-toast.visible {
    transform: translateX(-50%) translateY(0);
}

/* ── Системное сообщение о звонке в чате ── */
.msg-call-system {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 12px;
    background: var(--bg-bubble, rgba(255,255,255,.06));
    max-width: 260px;
    cursor: default;
}
.msg-row.out .msg-call-system {
    margin-left: auto;
}
.msg-row.in .msg-call-system {
    margin-right: auto;
}
.msg-call-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: rgba(255,255,255,.08);
    flex-shrink: 0;
}
[data-theme='light'] .msg-call-icon {
    background: rgba(0,0,0,.06);
}
.msg-call-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.msg-call-label {
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
}
.msg-call-time {
    font-size: .65rem;
    color: var(--text-muted, rgba(255,255,255,.4));
}

/* ═══════════════════════════════════════
   GROUP CALLS UI
   ═══════════════════════════════════════ */

.gcall-overlay {
    position:fixed; inset:0; z-index:10000;
    background:linear-gradient(135deg,#1a1a2e 0%,#16213e 50%,#0f3460 100%);
    display:flex; flex-direction:column;
    opacity:0; pointer-events:none; transition:opacity .3s;
}
.gcall-overlay.visible { opacity:1; pointer-events:auto; }

.gcall-header {
    display:flex; align-items:center; justify-content:space-between;
    padding:16px 20px; flex-shrink:0;
}
.gcall-title { color:#fff; font-size:1.1rem; font-weight:700; }
.gcall-subtitle { color:rgba(255,255,255,.5); font-size:.75rem; margin-top:2px; }
.gcall-timer {
    color:rgba(255,255,255,.7); font-size:1rem; font-weight:600;
    font-variant-numeric:tabular-nums;
    background:rgba(255,255,255,.1); padding:4px 14px; border-radius:20px;
}

/* Grid layout */
.gcall-grid {
    flex:1; display:grid; gap:6px; padding:6px; overflow:hidden;
    align-content:center;
}
.gcall-grid-1 { grid-template-columns:1fr; }
.gcall-grid-2 { grid-template-columns:1fr 1fr; }
.gcall-grid-3 { grid-template-columns:1fr 1fr; }
.gcall-grid-4 { grid-template-columns:1fr 1fr; grid-template-rows:1fr 1fr; }
.gcall-grid-5,.gcall-grid-6 { grid-template-columns:1fr 1fr 1fr; grid-template-rows:1fr 1fr; }
.gcall-grid-7,.gcall-grid-8,.gcall-grid-9 { grid-template-columns:1fr 1fr 1fr; grid-template-rows:1fr 1fr 1fr; }

.gcall-cell {
    position:relative; border-radius:16px; overflow:hidden;
    background:rgba(255,255,255,.06);
    display:flex; align-items:center; justify-content:center;
    min-height:100px;
}
.gcall-cell video {
    width:100%; height:100%; object-fit:cover;
    position:absolute; inset:0;
}
.gcall-cell-ava {
    display:flex; align-items:center; justify-content:center;
    z-index:1;
}
.gcall-ava {
    width:72px; height:72px; border-radius:50%;
    display:flex; align-items:center; justify-content:center;
    color:#fff; font-weight:700; font-size:1.5rem;
    overflow:hidden;
}
.gcall-ava img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.gcall-cell-name {
    position:absolute; bottom:8px; left:10px; right:10px;
    color:#fff; font-size:.7rem; font-weight:600;
    text-shadow:0 1px 4px rgba(0,0,0,.7);
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
    z-index:2;
}

.gcall-controls {
    display:flex; gap:20px; align-items:center; justify-content:center;
    padding:20px; flex-shrink:0;
}

/* Join banner */
.gcall-join-banner {
    display:flex; align-items:center; justify-content:space-between;
    padding:10px 16px; background:rgba(74,222,128,.12);
    border-bottom:1px solid rgba(74,222,128,.2);
    animation:gcallBannerIn .3s ease;
}
@keyframes gcallBannerIn { from{opacity:0;transform:translateY(-10px)} to{opacity:1;transform:translateY(0)} }
.gcall-join-info { font-size:.8rem; color:var(--text); font-weight:600; }
.gcall-join-btn {
    background:#16a34a; color:#fff; border:none;
    padding:6px 18px; border-radius:10px; font-size:.78rem; font-weight:700;
    cursor:pointer; transition:background .15s;
}
.gcall-join-btn:hover { background:#15803d; }

@media (max-width:768px) {
    .gcall-ava { width:56px; height:56px; font-size:1.2rem; }
    .gcall-cell { min-height:80px; border-radius:12px; }
    .gcall-header { padding:12px 14px; }
}

/* ═══════════════════════════════════════
   ADD PERSON TO CALL — modal
   ═══════════════════════════════════════ */
.call-add-modal {
    position:absolute; bottom:0; left:0; right:0;
    max-height:70vh; z-index:10002;
    background:rgba(22,33,62,.97);
    backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px);
    border-top:1px solid rgba(255,255,255,.1);
    border-radius:20px 20px 0 0;
    display:flex; flex-direction:column;
    transform:translateY(100%);
    transition:transform .3s ease;
    overflow:hidden;
}
.call-add-modal.visible {
    transform:translateY(0);
}
.call-add-header {
    display:flex; align-items:center; justify-content:space-between;
    padding:16px 20px 8px; flex-shrink:0;
}
.call-add-header span {
    font-size:.95rem; font-weight:700; color:#fff;
}
.call-add-header button {
    background:rgba(255,255,255,.1); border:none; color:#fff;
    width:32px; height:32px; border-radius:50%; cursor:pointer;
    display:flex; align-items:center; justify-content:center;
    font-size:.85rem; transition:background .15s;
}
.call-add-header button:hover { background:rgba(255,255,255,.2); }

.call-add-search {
    padding:0 16px 10px; position:relative;
}
.call-add-search i {
    position:absolute; left:28px; top:50%; transform:translateY(-50%);
    color:rgba(255,255,255,.3); font-size:.75rem; pointer-events:none;
    margin-top:-5px;
}
.call-add-search input {
    width:100%; padding:10px 12px 10px 36px;
    border-radius:12px; border:1px solid rgba(255,255,255,.12);
    background:rgba(255,255,255,.06); color:#fff;
    font-size:.85rem; outline:none;
    transition:border-color .15s;
}
.call-add-search input:focus { border-color:rgba(94,181,247,.5); }
.call-add-search input::placeholder { color:rgba(255,255,255,.3); }

.call-add-selected {
    padding:0 16px; display:flex; flex-wrap:wrap; gap:4px;
    min-height:0;
}
.call-add-tag {
    display:inline-flex; align-items:center; gap:4px;
    background:rgba(94,181,247,.2); color:var(--accent,#5eb5f7);
    padding:4px 10px; border-radius:8px; font-size:.72rem; font-weight:600;
}
.call-add-tag button {
    background:none; border:none; color:rgba(94,181,247,.6);
    cursor:pointer; font-size:.85rem; padding:0 0 0 2px; line-height:1;
}

.call-add-list {
    flex:1; overflow-y:auto; padding:6px 8px; min-height:100px;
}
.call-add-item {
    display:flex; align-items:center; gap:12px;
    padding:10px 12px; border-radius:12px; cursor:pointer;
    transition:background .12s;
}
.call-add-item:hover { background:rgba(255,255,255,.06); }
.call-add-item.selected { background:rgba(94,181,247,.1); }
.call-add-ava {
    width:40px; height:40px; border-radius:50%; flex-shrink:0;
    display:flex; align-items:center; justify-content:center;
    color:#fff; font-weight:700; font-size:.75rem; overflow:hidden;
}
.call-add-ava img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.call-add-info { flex:1; min-width:0; }
.call-add-name { font-size:.85rem; font-weight:600; color:#fff; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.call-add-sub { font-size:.68rem; color:rgba(255,255,255,.4); }
.call-add-check {
    width:24px; height:24px; border-radius:50%; flex-shrink:0;
    border:2px solid rgba(255,255,255,.15);
    display:flex; align-items:center; justify-content:center;
    font-size:.65rem; color:transparent; transition:all .15s;
}
.call-add-item.selected .call-add-check {
    background:var(--accent,#5eb5f7); border-color:var(--accent,#5eb5f7); color:#fff;
}

.call-add-go {
    margin:10px 16px 16px; padding:12px;
    border-radius:14px; border:none;
    background:#16a34a; color:#fff;
    font-size:.88rem; font-weight:700;
    cursor:pointer; transition:background .15s, opacity .15s;
}
.call-add-go:disabled { opacity:.4; cursor:default; }
.call-add-go:not(:disabled):hover { background:#15803d; }
