/* Video Call Styles */
.video-call-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    padding: 0.75rem 2rem;
    font-weight: 600;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transition: all 0.3s ease;
}

.video-call-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

/* Video Call Modal - Full Screen */
#video-call-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1a1a;
    z-index: 10000;
}

#video-call-modal.active {
    display: flex;
}

.video-grid {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Remote Video (Large) */
#remote-player {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    transition: opacity 0.5s ease;
    opacity: 1 !important; /* Force visibility */
    z-index: 1;
}

/* Local Video (Small - Picture in Picture) */
#local-player {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 300px;
    height: 225px;
    border-radius: 12px;
    object-fit: cover;
    background: #333;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    border: 2px solid #10b981;
    z-index: 10;
}

/* Video Controls */
.video-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    border-radius: 50px;
    z-index: 20;
}

/* Remote party playback volume (does not affect what they hear from you) */
.video-remote-volume {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    color: #e5e7eb;
    min-width: 72px;
}

.video-remote-volume>i {
    font-size: 0.85rem;
    opacity: 0.9;
}

.video-remote-volume input[type="range"] {
    width: 88px;
    height: 6px;
    cursor: pointer;
    accent-color: #10b981;
}

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    transform: scale(1.1);
}

#toggle-mic {
    background: #10b981;
    color: white;
}

#toggle-mic.muted {
    background: #ef4444;
}

#toggle-camera {
    background: #10b981;
    color: white;
}

#toggle-camera.off {
    background: #ef4444;
}

#end-call-btn {
    background: #ef4444;
    color: white;
}

#end-call-btn:hover {
    background: #dc2626;
}

/* Connection Status */
.connection-status {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    z-index: 10;
}

.connection-status.connecting {
    background: rgba(251, 191, 36, 0.9);
}

.connection-status.waiting {
    background: rgba(5, 150, 105, 0.92);
    animation: pulse-waiting 2s infinite;
}

.connection-status.connected {
    background: rgba(16, 185, 129, 0.9);
}

.connection-status.failed {
    background: rgba(239, 68, 68, 0.9);
}

/* ========================================
   VIRTUAL WAITING ROOM STYLES 
   ======================================== */

.waiting-room-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg,
            rgba(6, 78, 59, 0.97) 0%,
            rgba(15, 23, 42, 0.98) 45%,
            rgba(6, 78, 59, 0.97) 100%);
    backdrop-filter: blur(20px);
    z-index: 100;
    /* Changed for scrollability */
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 2rem 1rem;
    animation: fadeIn 0.5s ease;
    transition: opacity 0.5s ease;
}

.waiting-room-content {
    text-align: center;
    color: white;
    max-width: 600px;
    padding: 2rem;
    position: relative;
    margin: auto;
    /* Centers vertically and horizontally, allows scroll */
}

/* ... Existing styles ... */

/* Local Video Container in Waiting Room */
#waiting-room-video-container {
    width: 300px;
    height: 225px;
    background: #000;
    border-radius: 12px;
    margin: 1.5rem auto 0;
    border: 2px solid rgba(16, 185, 129, 0.45);
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    position: relative;
}

#waiting-room-video-container div {
    border-radius: 12px !important;
}

#waiting-room-video-container video {
    object-fit: cover !important;
    border-radius: 12px !important;
}


/* Animated Pulse Ring */
.waiting-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.12) 0%, transparent 70%);
    animation: pulse-ring 3s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* Doctor Icon */
.waiting-icon {
    width: 120px;
    height: 120px;
    margin: 0 auto 2rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    color: white;
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.35);
    animation: float 3s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

/* Title */
.waiting-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Message */
.waiting-message {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.waiting-message strong {
    color: #6ee7b7;
    font-weight: 600;
}

/* Appointment Time */
.waiting-time {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 1.5rem;
}

.waiting-time strong {
    color: #10b981;
    font-weight: 600;
}

/* Countdown Timer */
.waiting-timer {
    display: inline-block;
    background: rgba(16, 185, 129, 0.15);
    border: 2px solid rgba(16, 185, 129, 0.45);
    border-radius: 12px;
    padding: 1rem 2rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #6ee7b7;
    margin-bottom: 2rem;
    animation: glow 2s ease-in-out infinite;
}

/* Tips Section */
.waiting-tips {
    margin-top: 2.5rem;
    text-align: left;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.waiting-tips p {
    margin: 0.75rem 0;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.waiting-tips i {
    color: #10b981;
    font-size: 1.1rem;
}

/* ========================================
   ANIMATIONS 
   ======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse-ring {

    0%,
    100% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scale(1.5);
    }
}

/* Leave Lobby Button */
.leave-lobby-btn {
    margin-top: 1.5rem;
    background: rgba(239, 68, 68, 0.15);
    /* Red tint */
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(5px);
}

.leave-lobby-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.2);
}

.leave-lobby-btn i {
    font-size: 1.1rem;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-15px);
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
    }

    50% {
        box-shadow: 0 0 25px rgba(16, 185, 129, 0.55),
            0 0 40px rgba(16, 185, 129, 0.3);
    }
}

@keyframes pulse-waiting {

    0%,
    100% {
        opacity: 0.9;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    #local-player {
        width: 150px;
        height: 112px;
        top: 10px;
        right: 10px;
    }

    .video-controls {
        bottom: 15px;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .waiting-room-content {
        padding: 2rem 1.5rem;
    }

    .waiting-pulse {
        width: 200px;
        height: 200px;
    }

    .waiting-icon {
        width: 90px;
        height: 90px;
        font-size: 2.5rem;
    }

    .waiting-title {
        font-size: 1.5rem;
    }

    .waiting-message {
        font-size: 1.1rem;
    }

    .waiting-timer {
        font-size: 1.1rem;
        padding: 0.75rem 1.5rem;
    }

    .waiting-tips {
        padding: 1rem;
    }

    .waiting-tips p {
        font-size: 0.9rem;
    }
}

/* ========================================
   CUSTOM ERROR MODAL UI
   ======================================== */

.video-error-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeInError 0.3s ease-out;
}

.video-error-content {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 24px;
    padding: 2.5rem;
    max-width: 480px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    animation: slideUpError 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Red glow effect */
.video-error-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.video-error-icon {
    width: 80px;
    height: 80px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: #ef4444;
    font-size: 2.5rem;
    animation: pulseError 2s infinite;
}

.video-error-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fca5a5;
    margin-bottom: 1rem;
}

.video-error-message {
    font-size: 1.1rem;
    color: #e2e8f0;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.video-error-details {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #94a3b8;
    text-align: left;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    max-height: 150px;
    overflow-y: auto;
}

.video-error-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    padding: 1rem 3rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.2);
}

.video-error-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(239, 68, 68, 0.3);
}

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

@keyframes slideUpError {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pulseError {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}