/* ═══ نظام الاتصال — WebRTC Call UI ═══ */

#taCallOverlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0,0,0,.85);
    backdrop-filter: blur(12px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.ta-call-box {
    width: 100%;
    max-width: 480px;
    min-height: 320px;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
    border-radius: 24px;
    border: 1px solid rgba(168,85,247,.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 0 80px rgba(168,85,247,.1);
}

.ta-call-box.video-mode {
    max-width: 90vw;
    max-height: 85vh;
    min-height: 60vh;
    padding: 0;
}

/* فيديو بعيد (ملء الشاشة) */
.ta-call-box #taCallRemoteVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    inset: 0;
    border-radius: 24px;
}

/* فيديو محلي (زاوية صغيرة) */
.ta-call-box #taCallLocalVideo {
    position: absolute;
    bottom: 90px;
    left: 16px;
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid rgba(168,85,247,.5);
    z-index: 5;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
}

/* مشاركة الشاشة */
#taCallScreenView {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: #000;
    border-radius: 24px;
    display: none;
}

#taCallScreenVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 24px;
}

/* معلومات المكالمة */
.ta-call-info {
    position: relative;
    z-index: 6;
    text-align: center;
    margin-bottom: 24px;
}

.ta-call-status {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,.5);
}

.ta-call-duration {
    font-size: 32px;
    font-weight: 900;
    color: var(--purple-l, #a855f7);
    font-family: 'IBM Plex Mono', monospace;
    margin-top: 8px;
    text-shadow: 0 0 20px rgba(168,85,247,.4);
}

/* أزرار التحكم */
.ta-call-controls {
    position: relative;
    z-index: 6;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 16px;
}

.video-mode .ta-call-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 12px 20px;
}

.ta-call-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.1);
    color: #fff;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s;
    backdrop-filter: blur(6px);
}

.ta-call-btn:hover {
    background: rgba(255,255,255,.2);
    transform: scale(1.08);
}

.ta-call-btn.active {
    background: rgba(239,68,68,.3);
    border-color: rgba(239,68,68,.5);
}

.ta-call-btn.end {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border-color: #dc2626;
    width: 60px;
    height: 60px;
    font-size: 26px;
    box-shadow: 0 4px 20px rgba(220,38,38,.4);
}

.ta-call-btn.end:hover {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    transform: scale(1.1);
}

.ta-call-btn.answer {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: #22c55e;
    width: 60px;
    height: 60px;
    font-size: 26px;
    box-shadow: 0 4px 20px rgba(34,197,94,.4);
}

.ta-call-btn.answer:hover {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    transform: scale(1.1);
}

/* ═══ مكالمة واردة ═══ */

#taIncomingCallModal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn .3s ease;
}

.ta-incoming-box {
    background: linear-gradient(135deg, #1a1a2e 0%, #0d1117 100%);
    border: 2px solid rgba(34,197,94,.4);
    border-radius: 24px;
    padding: 40px 30px;
    text-align: center;
    max-width: 340px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 0 60px rgba(34,197,94,.15);
}

.ta-incoming-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(34,197,94,.15);
    animation: callPulse 1.5s ease-in-out infinite;
    z-index: 0;
}

.ta-incoming-icon {
    font-size: 56px;
    position: relative;
    z-index: 1;
    animation: callBounce 1s ease-in-out infinite;
}

.ta-incoming-title {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    margin-top: 16px;
}

.ta-incoming-caller {
    font-size: 14px;
    color: var(--text2, #9ca3af);
    margin-top: 6px;
}

.ta-incoming-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 28px;
}

/* ═══ سجل المكالمة بالشات ═══ */
.msg.sys .call-log-msg {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(168,85,247,.08);
    border: 1px solid rgba(168,85,247,.2);
    border-radius: 10px;
    font-size: 12px;
}

/* ═══ أزرار الاتصال بهيدر الشات ═══ */
.chat-call-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.chat-call-btns button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border, rgba(255,255,255,.1));
    background: rgba(168,85,247,.1);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    padding: 0;
}

.chat-call-btns button:hover {
    background: rgba(168,85,247,.25);
    transform: scale(1.1);
}

/* ═══ حركات ═══ */
@keyframes callPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: .4; }
    50% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

@keyframes callBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ═══ موبايل ═══ */
@media (max-width: 600px) {
    .ta-call-box {
        border-radius: 0;
        min-height: 100vh;
        max-width: 100%;
    }
    .ta-call-box.video-mode {
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
    .ta-call-btn { width: 48px; height: 48px; font-size: 20px; }
    .ta-call-btn.end, .ta-call-btn.answer { width: 56px; height: 56px; font-size: 24px; }
    .ta-call-box #taCallLocalVideo { width: 90px; height: 68px; bottom: 100px; }
}
