/* ============================================
   MedFlux Live Media — Premium Video Call UI
   ============================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-primary: #0a0b1a;
    --bg-secondary: #111227;
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
    --success: #22c55e;
    --success-glow: rgba(34, 197, 94, 0.3);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.3);
    --warning: #f59e0b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(99, 102, 241, 0.15);
    --glass-bg: rgba(15, 17, 40, 0.6);
    --glass-border: rgba(99, 102, 241, 0.12);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius-sm: 0.5rem; --radius-md: 0.75rem; --radius-lg: 1rem; --radius-xl: 1.5rem; --radius-full: 9999px;
    --transition-fast: 150ms ease; --transition-base: 250ms ease; --transition-slow: 400ms ease;
}

html, body { width: 100%; height: 100%; overflow: hidden; font-family: var(--font-family); font-size: 16px; color: var(--text-primary); background: var(--bg-primary); -webkit-font-smoothing: antialiased; }

.bg-animation { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg-orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.4; animation: orbFloat 20s ease-in-out infinite; }
.bg-orb-1 { width: 500px; height: 500px; background: radial-gradient(circle, #6366f1, transparent 70%); top: -10%; right: -10%; }
.bg-orb-2 { width: 400px; height: 400px; background: radial-gradient(circle, #8b5cf6, transparent 70%); bottom: -15%; left: -5%; animation-delay: -7s; }
.bg-orb-3 { width: 300px; height: 300px; background: radial-gradient(circle, #a855f7, transparent 70%); top: 40%; left: 50%; animation-delay: -14s; }
@keyframes orbFloat { 0%, 100% { transform: translate(0,0) scale(1); } 25% { transform: translate(30px,-50px) scale(1.1); } 50% { transform: translate(-20px,20px) scale(0.9); } 75% { transform: translate(10px,40px) scale(1.05); } }

#app { position: relative; z-index: 1; width: 100%; height: 100%; }

.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transform: scale(0.95); transition: opacity var(--transition-slow), transform var(--transition-slow), visibility var(--transition-slow); }
.screen.active { opacity: 1; visibility: visible; transform: scale(1); }

.glass-card { background: var(--glass-bg); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid var(--glass-border); border-radius: var(--radius-xl); box-shadow: var(--glass-shadow); padding: 2rem; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; animation: cardAppear 0.6s ease-out; }
.glass-card::-webkit-scrollbar { width: 4px; }
.glass-card::-webkit-scrollbar-thumb { background: var(--accent-primary); border-radius: var(--radius-full); }
@keyframes cardAppear { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.logo-container { text-align: center; margin-bottom: 2rem; }
.logo-icon { display: inline-flex; align-items: center; justify-content: center; width: 72px; height: 72px; border-radius: var(--radius-lg); background: var(--accent-gradient); margin-bottom: 1rem; box-shadow: 0 4px 20px var(--accent-glow); animation: logoPulse 3s ease-in-out infinite; }
.logo-icon .material-icons-round { font-size: 36px; color: white; }
@keyframes logoPulse { 0%, 100% { box-shadow: 0 4px 20px var(--accent-glow); } 50% { box-shadow: 0 4px 40px var(--accent-glow), 0 0 60px rgba(99,102,241,0.15); } }
.logo-text { font-size: 2rem; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; }
.logo-accent { background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.logo-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-top: 0.25rem; }

.form-group { margin-bottom: 1.5rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.5rem; }
.input-wrapper { position: relative; display: flex; align-items: center; }
.input-icon { position: absolute; left: 14px; color: var(--text-muted); font-size: 20px; pointer-events: none; transition: color var(--transition-fast); }
.form-input { width: 100%; padding: 14px 16px 14px 48px; background: rgba(15,17,40,0.5); border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text-primary); font-size: 1rem; font-family: var(--font-family); outline: none; transition: all var(--transition-fast); }
.form-input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input::placeholder { color: var(--text-muted); }
.form-select { padding: 8px 12px; background: rgba(15,17,40,0.5); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.875rem; font-family: var(--font-family); outline: none; cursor: pointer; }
.form-select:disabled { opacity: 0.5; cursor: not-allowed; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 12px 24px; border: none; border-radius: var(--radius-md); font-size: 1rem; font-weight: 600; font-family: var(--font-family); cursor: pointer; transition: all var(--transition-base); position: relative; overflow: hidden; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent-gradient); color: white; box-shadow: 0 4px 15px var(--accent-glow); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 25px var(--accent-glow); }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 8px; }
.btn-ghost:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.btn-icon { padding: 10px; border-radius: var(--radius-md); }
.btn-sm { padding: 6px; }
.btn-sm .material-icons-round { font-size: 18px; }

.server-status { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 1.5rem; font-size: 0.875rem; color: var(--text-muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); animation: dotPulse 2s ease-in-out infinite; }
.status-dot.connected { background: var(--success); }
.status-dot.error { background: var(--danger); animation: none; }
@keyframes dotPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.codec-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem; margin-top: 1.5rem; }
.codec-badge { padding: 4px 10px; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 600; background: rgba(99,102,241,0.1); color: var(--accent-secondary); border: 1px solid var(--border); }
.lyra-badge { background: rgba(168,85,247,0.15); color: #c084fc; border-color: rgba(168,85,247,0.3); }

.registered-card { max-width: 500px; }
.user-badge { display: flex; align-items: center; gap: 1rem; padding: 1rem; background: rgba(34,197,94,0.08); border-radius: var(--radius-md); border: 1px solid rgba(34,197,94,0.2); }
.user-avatar { width: 44px; height: 44px; border-radius: var(--radius-md); background: var(--accent-gradient); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-avatar .material-icons-round { color: white; font-size: 24px; }
.user-info { flex: 1; min-width: 0; }
.user-label { display: block; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.user-name { display: block; font-size: 1.125rem; font-weight: 700; color: var(--success); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }
.section-title { display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 1rem; }
.section-title .material-icons-round { color: var(--accent-secondary); font-size: 20px; }

.users-list { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.25rem; }
.users-empty { text-align: center; padding: 1.5rem; color: var(--text-muted); font-size: 0.875rem; }
.user-item { display: flex; align-items: center; gap: 0.5rem; padding: 10px 14px; border-radius: var(--radius-sm); background: rgba(255,255,255,0.03); cursor: pointer; transition: all var(--transition-fast); }
.user-item:hover { background: rgba(99,102,241,0.1); }
.user-item-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.user-item-name { flex: 1; font-size: 0.875rem; font-weight: 500; }
.user-item-call { opacity: 0; transition: opacity var(--transition-fast); }
.user-item:hover .user-item-call { opacity: 1; }
.user-item-call .material-icons-round { font-size: 18px; color: var(--success); }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 10px 0; }
.setting-row + .setting-row { border-top: 1px solid rgba(255,255,255,0.04); }
.setting-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--text-secondary); }
.setting-label .material-icons-round { font-size: 18px; color: var(--accent-secondary); }

.toggle { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: rgba(255,255,255,0.1); border-radius: var(--radius-full); transition: var(--transition-base); }
.toggle-slider::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: var(--transition-base); }
.toggle input:checked + .toggle-slider { background: var(--accent-gradient); box-shadow: 0 0 12px var(--accent-glow); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }

.incoming-card { text-align: center; max-width: 400px; }
.incoming-animation { position: relative; width: 140px; height: 140px; margin: 0 auto 2rem; }
.ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--success); opacity: 0; animation: ringPulse 2s ease-out infinite; }
.ring-2 { animation-delay: 0.4s; } .ring-3 { animation-delay: 0.8s; }
@keyframes ringPulse { 0% { transform: scale(0.5); opacity: 0.8; } 100% { transform: scale(1.4); opacity: 0; } }
.caller-avatar { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 80px; height: 80px; border-radius: 50%; background: var(--accent-gradient); display: flex; align-items: center; justify-content: center; animation: callerBounce 1s ease-in-out infinite; }
.caller-avatar .material-icons-round { font-size: 40px; color: white; }
@keyframes callerBounce { 0%, 100% { transform: translate(-50%,-50%) scale(1); } 50% { transform: translate(-50%,-50%) scale(1.05); } }
.incoming-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
.incoming-caller { font-size: 1.5rem; font-weight: 700; color: var(--accent-secondary); margin-bottom: 3rem; }
.incoming-actions { display: flex; justify-content: center; gap: 3rem; }
.btn-call-accept, .btn-call-decline { width: 64px; height: 64px; border-radius: 50%; padding: 0; }
.btn-call-accept { background: var(--success); color: white; box-shadow: 0 4px 20px var(--success-glow); animation: acceptPulse 1.5s ease-in-out infinite; }
.btn-call-decline { background: var(--danger); color: white; box-shadow: 0 4px 20px var(--danger-glow); }
.btn-call-accept .material-icons-round, .btn-call-decline .material-icons-round { font-size: 28px; }
@keyframes acceptPulse { 0%, 100% { box-shadow: 0 4px 20px var(--success-glow); } 50% { box-shadow: 0 4px 35px var(--success-glow), 0 0 50px rgba(34,197,94,0.15); } }

.call-container { position: relative; width: 100%; height: 100%; background: #000; overflow: hidden; }
.remote-video-wrapper { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
#remote-video { width: 100%; height: 100%; object-fit: cover; }
.remote-overlay { position: absolute; top: 0; left: 0; right: 0; padding: 1.5rem 2rem; display: flex; justify-content: space-between; align-items: center; background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent); pointer-events: none; }
.remote-name { font-size: 1.125rem; font-weight: 600; }
.call-timer { font-size: 1.125rem; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.codec-indicator { position: absolute; top: 60px; left: 2rem; display: flex; gap: 0.5rem; pointer-events: none; }
.codec-info { padding: 3px 8px; border-radius: var(--radius-sm); font-size: 0.75rem; font-weight: 600; background: rgba(0,0,0,0.5); backdrop-filter: blur(8px); color: var(--accent-secondary); }

.local-video-wrapper { position: absolute; bottom: 100px; right: 2rem; width: 200px; height: 150px; border-radius: var(--radius-md); overflow: hidden; border: 2px solid rgba(255,255,255,0.2); box-shadow: 0 4px 20px rgba(0,0,0,0.5); cursor: grab; transition: transform var(--transition-fast); z-index: 10; }
.local-video-wrapper:hover { transform: scale(1.05); }
#local-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

.call-controls { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: 1rem; padding: 2rem; background: linear-gradient(to top, rgba(0,0,0,0.7), transparent); z-index: 20; }
.btn-control { width: 52px; height: 52px; border-radius: 50%; padding: 0; background: rgba(255,255,255,0.12); backdrop-filter: blur(8px); color: white; border: 1px solid rgba(255,255,255,0.15); position: relative; }
.btn-control:hover { background: rgba(255,255,255,0.2); }
.btn-control .icon-off { display: none; }
.btn-control.muted .icon-on { display: none; }
.btn-control.muted .icon-off { display: block; }
.btn-control.muted { background: rgba(239,68,68,0.3); border-color: rgba(239,68,68,0.5); }
.btn-hangup { width: 60px; height: 60px; border-radius: 50%; padding: 0; background: var(--danger); color: white; box-shadow: 0 4px 20px var(--danger-glow); }
.btn-hangup:hover { background: #dc2626; transform: scale(1.1); }
.btn-hangup .material-icons-round { font-size: 28px; }
.chat-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: white; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

.bandwidth-panel { position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--glass-bg); backdrop-filter: blur(24px); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); padding: 1rem 1.5rem; z-index: 30; animation: panelSlideUp 0.3s ease-out; }
.bandwidth-panel h3 { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0.5rem; text-align: center; }
.bw-options { display: flex; flex-wrap: wrap; gap: 0.25rem; justify-content: center; }
.bw-option { padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font-size: 0.75rem; font-family: var(--font-family); cursor: pointer; transition: all var(--transition-fast); }
.bw-option:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.bw-option.active { background: var(--accent-primary); border-color: var(--accent-primary); color: white; }
@keyframes panelSlideUp { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.chat-panel { position: absolute; top: 0; right: 0; width: 360px; height: 100%; background: var(--glass-bg); backdrop-filter: blur(24px); border-left: 1px solid var(--glass-border); display: flex; flex-direction: column; z-index: 30; animation: chatSlideIn 0.3s ease-out; }
@keyframes chatSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.chat-header h3 { font-size: 1rem; font-weight: 600; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.chat-message { max-width: 80%; padding: 10px 14px; border-radius: var(--radius-md); font-size: 0.875rem; word-break: break-word; animation: msgAppear 0.2s ease-out; }
@keyframes msgAppear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-message.sent { align-self: flex-end; background: var(--accent-primary); color: white; border-bottom-right-radius: 4px; }
.chat-message.received { align-self: flex-start; background: rgba(255,255,255,0.08); color: var(--text-primary); border-bottom-left-radius: 4px; }
.chat-message .msg-time { display: block; font-size: 10px; margin-top: 4px; opacity: 0.6; }
.chat-input-wrapper { display: flex; gap: 0.5rem; padding: 1rem; border-top: 1px solid var(--border); }
.chat-input-wrapper .form-input { padding-left: 14px; }

.toast-container { position: fixed; top: 2rem; right: 2rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 9999; pointer-events: none; }
.toast { padding: 14px 20px; border-radius: var(--radius-md); background: var(--glass-bg); backdrop-filter: blur(16px); border: 1px solid var(--glass-border); color: var(--text-primary); font-size: 0.875rem; pointer-events: auto; animation: toastIn 0.3s ease-out; display: flex; align-items: center; gap: 0.5rem; max-width: 400px; }
.toast.info .material-icons-round { color: var(--accent-secondary); }
.toast.success .material-icons-round { color: var(--success); }
.toast.error .material-icons-round { color: var(--danger); }
.toast.warning .material-icons-round { color: var(--warning); }
.toast.leaving { animation: toastOut 0.3s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(30px); } }

@media (max-width: 600px) {
    .glass-card { margin: 1rem; padding: 1.5rem; max-height: calc(100vh - 32px); }
    .local-video-wrapper { width: 120px; height: 90px; bottom: 90px; right: 1rem; }
    .chat-panel { width: 100%; }
    .call-controls { gap: 0.5rem; padding: 1rem; }
    .btn-control { width: 46px; height: 46px; }
    .btn-hangup { width: 54px; height: 54px; }
}
