/* Call Modal & Overlay */
.call-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.call-modal.show {
    display: flex;
    animation: fadeIn 0.3s;
}

/* Minimized State (PIP) */
.call-modal.minimized {
    width: 160px;
    /* Much smaller */
    height: 220px;
    top: auto;
    left: auto;
    bottom: 20px;
    right: 20px;
    background: transparent;
    backdrop-filter: none;
    pointer-events: none;
}

.call-modal.minimized .call-card {
    pointer-events: auto;
    width: 100%;
    height: 100%;
    /* Stronger shadow and border for visibility */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
    padding: 0;
    overflow: hidden;
    border-radius: 12px;
    cursor: grab;
    border: 3px solid rgba(255, 255, 255, 0.8);
    /* Thicker, brighter border */
    background: #000;
    touch-action: none;
    /* Crucial for reliable touch dragging */
}

.call-modal.minimized .call-card:active {
    cursor: grabbing;
}

/* Hide most elements in minimized mode except video */
.call-modal.minimized .call-name,
.call-modal.minimized .call-status,
.call-modal.minimized .call-top-controls {
    display: none;
}

/* Maximize Button - Only visible in minimized mode */
/* Maximize Button - Only visible in minimized mode */
.call-modal.minimized .maximize-btn {
    display: flex;
    position: absolute;
    top: -10px;
    /* Slight overlap */
    left: -10px;
    width: 36px;
    height: 36px;
    background: rgba(0, 136, 204, 0.8);
    /* Brighter blue base */
    backdrop-filter: blur(10px);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    z-index: 20;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 16px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    transition: all 0.2s;
}

.call-modal.minimized .maximize-btn:hover {
    transform: scale(1.1);
    background: var(--telegram-blue-light);
    box-shadow: 0 0 15px rgba(0, 136, 204, 0.6);
}

.maximize-btn {
    display: none;
    /* Hidden by default */
}

.call-modal.minimized .call-card {
    pointer-events: auto;
    width: 100%;
    height: 100%;
    /* Stronger shadow and border for visibility */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
    padding: 0;
    overflow: hidden;
    border-radius: 12px;
    cursor: grab;
    border: 3px solid rgba(255, 255, 255, 0.8);
    /* Thicker, brighter border */
    background: #000;
    /* Ensure background is dark if no video */
}

/* Show avatar if no video */
.call-modal.minimized .call-avatar {
    width: 60px;
    height: 60px;
    margin-top: 0;
    border-width: 2px;
}

/* Compact Actions */
.call-modal.minimized .call-actions {
    position: absolute;
    bottom: 10px;
    left: 0;
    width: 100%;
    transform: scale(0.6);
    opacity: 0;
    transition: opacity 0.3s;
    justify-content: center;
    gap: 10px;
}

.call-modal.minimized .call-card:hover .call-actions {
    opacity: 1;
}

.call-card {
    background: rgba(14, 22, 33, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 30px;
    text-align: center;
    color: white;
    width: 100%;
    height: 100%;
    box-shadow: none;
    position: relative;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0;
}

/* On Desktop, maybe limit it slightly or keep full screen? 
   User said "full screen as per mobile and desktop". 
   So we stick to 100% but maybe add a max-width for audio mode aesthetics?
   actually, let's keep it full screen as requested.
*/

/* Adjust avatar for full screen */
.call-avatar {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: #333;
    margin-bottom: 40px;
    overflow: hidden;
    border: 4px solid var(--telegram-blue);
    position: relative;
    z-index: 1;
    transition: all 0.3s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.call-name {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 10px;
    z-index: 1;
}

.call-status {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 60px;
    z-index: 1;
}

.call-actions {
    display: flex;
    justify-content: center;
    gap: 30px;
    z-index: 2;
    padding-bottom: 50px;
    /* shift up a bit */
}

.call-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: transform 0.2s, background 0.2s;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    color: white;
}

/* Video Container */
.video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: none;
    /* Hidden by default (audio call) */
    background: #000;
}

.video-container.active {
    display: block;
}

#remoteVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#localVideo {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 100px;
    height: 140px;
    background: #333;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    object-fit: cover;
    z-index: 2;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

/* Hide local video in audio mode or if camera off */
#localVideo.hidden {
    display: none;
}

/* Avatar - sits on top of video if no video stream, or standard view */
.call-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: #333;
    margin-bottom: 20px;
    overflow: hidden;
    border: 4px solid var(--telegram-blue);
    position: relative;
    z-index: 1;
    transition: all 0.3s;
}

/* Hide avatar when video is active */
.video-active .call-avatar {
    opacity: 0;
    transform: scale(0.5);
    position: absolute;
    /* Take out of flow */
}

/* Hide status/name when video is active (optional, or overlay them) */
.video-active .call-name,
.video-active .call-status {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    position: relative;
    z-index: 1;
}

.call-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.call-avatar.pulse {
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 136, 204, 0.7);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(0, 136, 204, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 136, 204, 0);
    }
}

.call-name {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 5px;
    z-index: 1;
}

.call-status {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 30px;
    z-index: 1;
}

.call-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    /* Reduced gap to fit more buttons */
    z-index: 2;
    /* Above video */
}

.call-btn {
    width: 50px;
    /* Slightly smaller */
    height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: transform 0.2s, background 0.2s;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    color: white;
}

.call-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.2);
}

.call-btn.accept {
    background: #00cc66;
    animation: bounce 1.2s infinite;
}

.call-btn.reject {
    background: #ff4444;
}

.call-btn.active {
    background: white;
    color: #333;
}

/* Top Right Controls (Minimize) */
.call-top-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    display: flex;
    gap: 10px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}