/* Custom CSS Variables */
:root {
    --bg-dark: #0a0b10;
    --card-bg: rgba(255, 255, 255, 0.03);
    --border-color: rgba(255, 255, 255, 0.07);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --primary-gradient: linear-gradient(135deg, #8b5cf6, #3b82f6);
    --primary-color: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.3);
    --danger-color: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.4);
    --success-color: #10b981;
    --success-glow: rgba(16, 185, 129, 0.3);
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Animated Background Glow Orbs */
.bg-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.15;
    z-index: -1;
    pointer-events: none;
    animation: floatGlow 15s ease-in-out infinite alternate;
}

.bg-glow-1 {
    background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
    top: -10%;
    left: -10%;
}

.bg-glow-2 {
    background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
    bottom: -10%;
    right: -10%;
    animation-delay: -7s;
}

@keyframes floatGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(100px, 50px) scale(1.1);
    }
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    padding: 24px;
    z-index: 10;
}

/* Glassmorphism utility */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Panels */
.panel {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    transition: all 0.3s ease;
}

.panel.active {
    display: flex;
}

/* 1. Lobby Panel Style */
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 48px;
    height: 48px;
    background: var(--primary-gradient);
    border-radius: 12px;
    color: white;
}

.logo-icon svg {
    width: 24px;
    height: 24px;
}

.logo h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff, #9ca3af);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 40px;
    text-align: center;
    font-weight: 300;
}

#lobby-panel .card {
    width: 100%;
    max-width: 460px;
    border-radius: 24px;
    padding: 32px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.input-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-wrapper {
    display: flex;
    gap: 8px;
}

.input-wrapper input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 18px;
    font-family: var(--font-sans);
    font-size: 16px;
    color: white;
    outline: none;
    transition: all 0.3s ease;
}

.input-wrapper input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 12px var(--primary-glow);
    background: rgba(255, 255, 255, 0.08);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 12px;
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    padding: 14px 28px;
    box-shadow: 0 4px 20px var(--primary-glow);
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(139, 92, 246, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: white;
    width: 48px;
    height: 48px;
    padding: 0;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-secondary svg.icon {
    width: 20px;
    height: 20px;
    transition: transform 0.4s ease;
}

.btn-secondary:hover svg.icon {
    transform: rotate(180deg);
}

.icon-right {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
}

.btn-primary:hover .icon-right {
    transform: translateX(4px);
}

.footer-tips {
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}

/* 2. Call Panel Style */
#call-panel {
    width: 100%;
    height: calc(100vh - 48px);
    max-height: 850px;
    display: none;
    position: relative;
}

#call-panel.active {
    display: flex;
}

.call-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    z-index: 20;
    gap: 12px;
}

.room-info-badge, .room-id-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--danger-color);
}

.status-dot.connected {
    background-color: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

.pulse-animation {
    animation: statusPulse 1.5s infinite alternate;
}

@keyframes statusPulse {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

.room-id-badge {
    cursor: pointer;
    transition: all 0.2s ease;
}

.room-id-badge:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.room-id-badge .label {
    color: var(--text-secondary);
}

.icon-copy {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    margin-left: 4px;
}

.room-id-badge:hover .icon-copy {
    color: white;
}

/* Video Grid layout */
.video-grid {
    flex: 1;
    width: 100%;
    position: relative;
    border-radius: 28px;
    overflow: hidden;
    background: #0f1016;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 40px rgba(0,0,0,0.5);
    margin-bottom: 20px;
}

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

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 28px;
}

/* Local Video Picture in Picture (Floating) */
.local-video-pip {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 160px;
    height: 240px;
    border-radius: 20px;
    z-index: 10;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.local-video-pip:hover {
    transform: scale(1.05);
    border-color: var(--primary-color);
    box-shadow: 0 12px 36px rgba(139, 92, 246, 0.3);
}

.local-video-pip video {
    border-radius: 18px;
}

/* Placeholders when streams are inactive/muted */
.video-placeholder {
    position: absolute;
    inset: 0;
    background: #11121a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    z-index: 2;
}

.avatar-pulse {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
    position: relative;
}

.avatar-pulse::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 1px solid var(--primary-glow);
    animation: avatarPulse 2s infinite ease-out;
}

@keyframes avatarPulse {
    0% { transform: scale(0.9); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}

.avatar-pulse svg {
    width: 32px;
    height: 32px;
}

.local-video-pip .avatar-pulse {
    width: 50px;
    height: 50px;
}

.local-video-pip .avatar-pulse::after {
    display: none;
}

.local-video-pip .avatar-pulse svg {
    width: 20px;
    height: 20px;
}

/* User name tags */
.user-label {
    position: absolute;
    bottom: 16px;
    left: 16px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    z-index: 5;
    pointer-events: none;
}

/* Controls Bar */
.controls-wrapper {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
}

.controls-bar {
    display: flex;
    gap: 20px;
    padding: 14px 28px;
    border-radius: 100px;
}

.ctrl-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ctrl-btn:hover {
    transform: translateY(-3px) scale(1.08);
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 15px rgba(255,255,255,0.05);
}

.ctrl-btn svg {
    width: 22px;
    height: 22px;
}

.ctrl-btn.active {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger-color);
}

.ctrl-btn.active:hover {
    background: rgba(239, 68, 68, 0.25);
    box-shadow: 0 4px 15px var(--danger-glow);
}

.ctrl-btn-danger {
    background: var(--danger-color);
    border: none;
    box-shadow: 0 4px 15px var(--danger-glow);
}

.ctrl-btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 6px 20px var(--danger-glow);
}

/* Toast alert */
.toast {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 24px;
    border-radius: 100px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 40;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Responsive adjustment for Mobile Phones */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    #call-panel {
        height: calc(100vh - 32px);
    }

    /* Stack on mobile */
    .local-video-pip {
        width: 110px;
        height: 165px;
        bottom: 16px;
        right: 16px;
        border-radius: 14px;
        border-width: 1.5px;
    }

    .local-video-pip video {
        border-radius: 12px;
    }

    .controls-bar {
        padding: 10px 20px;
        gap: 16px;
    }

    .ctrl-btn {
        width: 46px;
        height: 46px;
    }

    .ctrl-btn svg {
        width: 18px;
        height: 18px;
    }
}
