/* ===== Дзвінки (mesh) ===== */

/* ── Вхідний виклик ─────────────────────────────────────────────── */

.call-ring-overlay {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: var(--glass-blur);
    padding: 16px;
}

.call-ring-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 340px;
    padding: 32px 24px 24px;
    border-radius: 24px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    text-align: center;
}

.call-ring-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
    font-size: 34px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    animation: call-pulse 1.6s ease-out infinite;
}

@keyframes call-pulse {
    0% { box-shadow: 0 0 0 0 rgba(50, 168, 82, 0.45); }
    70% { box-shadow: 0 0 0 22px rgba(50, 168, 82, 0); }
    100% { box-shadow: 0 0 0 0 rgba(50, 168, 82, 0); }
}

.call-ring-name {
    font-size: 21px;
    font-weight: 600;
    color: var(--text-main);
}

.call-ring-sub {
    margin-top: 6px;
    font-size: 14px;
    color: var(--text-muted);
}

.call-ring-actions {
    display: flex;
    gap: 40px;
    margin-top: 28px;
}

/* ── Вікно дзвінка ──────────────────────────────────────────────── */

/* Дзвінок займає лише колонку чату — список кімнат лишається під рукою.
   left повторює ширину сайдбару (flex 30%, min 300px, max 420px) один в один. */
.call-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: clamp(300px, 30%, 420px);
    z-index: 3900;
    display: flex;
    flex-direction: column;
    background: #0B1220;
    color: #F8FAFC;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.call-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    flex-shrink: 0;
}

.call-topbar-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.call-room-name {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.call-status {
    font-size: 13px;
    color: rgba(248, 250, 252, 0.6);
}

.call-icon-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #F8FAFC;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.call-icon-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.call-error {
    margin: 0 18px 10px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-color);
}

/* ── Сітка учасників ────────────────────────────────────────────── */

/* Рядки саме 1fr: із aspect-ratio плитки виростали за межі сітки
   й затуляли панель керування. Тепер вони завжди діляться наявною висотою. */
.call-grid {
    flex: 1 1 auto;
    display: grid;
    grid-auto-rows: minmax(0, 1fr);
    gap: 10px;
    padding: 0 14px;
    min-height: 0;
    overflow: hidden;
}

.call-tile {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #1E293B;
    min-height: 0;
    min-width: 0;
}

.call-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #1E293B;
}

/* Своє зображення показуємо дзеркально — так звикли всі відеодзвінки */
.call-tile-local video {
    transform: scaleX(-1);
}

.call-tile-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 700;
    color: #fff;
    background: var(--gradient);
}

.call-tile-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
}

.call-tile-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.call-tile-badge {
    font-size: 12px;
    color: rgba(248, 250, 252, 0.75);
    flex-shrink: 0;
}

.call-tile-empty {
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-waiting {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: rgba(248, 250, 252, 0.7);
    font-size: 14px;
}

.call-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(248, 250, 252, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: call-spin 0.9s linear infinite;
}

@keyframes call-spin {
    to { transform: rotate(360deg); }
}

/* ── Керування ──────────────────────────────────────────────────── */

.call-controls {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 22px;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    flex: 0 0 auto;   /* панель керування не стискається і не з'їжджає за екран */
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.call-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.call-control-label {
    font-size: 11px;
    color: rgba(248, 250, 252, 0.6);
    white-space: nowrap;
}

.call-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: transform 0.15s, background 0.2s;
}

.call-btn:hover {
    transform: scale(1.06);
}

.call-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.call-btn-neutral {
    background: rgba(255, 255, 255, 0.14);
}

.call-btn-off {
    background: #F8FAFC;
    color: #0F172A;
}

.call-btn-accept {
    background: var(--primary-color);
}

.call-btn-decline {
    background: #DC2626;
}

/* ── Згорнутий режим ────────────────────────────────────────────────
   Плитки лишаються в DOM: приберемо <video> — і віддалений звук замовкне. */

.call-overlay.minimized {
    top: auto;
    left: auto;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: min(300px, calc(100vw - 32px));
    height: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.call-overlay.minimized .call-controls {
    background: transparent;
    border-top: none;
}

.call-overlay.minimized .call-control-label {
    display: none;
}

.call-overlay.minimized .call-grid {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

.call-overlay.minimized .call-error {
    display: none;
}

.call-overlay.minimized .call-controls {
    gap: 12px;
    padding: 0 14px 14px;
}

.call-overlay.minimized .call-btn {
    width: 44px;
    height: 44px;
}

.call-overlay.minimized .call-btn svg {
    width: 18px;
    height: 18px;
}

/* На телефоні колонки чату як такої немає — дзвінок займає весь екран */
@media (max-width: 768px) {
    .call-overlay {
        left: 0;
        border-left: none;
    }

    .call-overlay.minimized {
        left: auto;
    }
}

@media (max-width: 640px) {
    .call-grid {
        padding: 0 10px;
        gap: 8px;
    }

    .call-btn {
        width: 52px;
        height: 52px;
    }

    .call-controls {
        gap: 16px;
    }

    .call-ring-actions {
        gap: 28px;
    }
}
