:root {
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --accent-blue: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2828;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden; /* No scrolling */
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

/* LOGIN BOX */
#login-box {
    width: 100%;
    max-width: 380px;
    padding: 25px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

input, select {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 15px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.6);
    color: white;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
}
input:focus, select:focus {
    border-color: var(--accent-blue);
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: inherit;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-blue {
    background: var(--accent-blue);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
}
.btn-blue:hover { background: var(--accent-hover); }

.btn-small { padding: 4px 10px; font-size: 0.75rem; border-radius: 6px; }

.btn-danger { background: var(--danger) !important; color: white !important; }
.btn-danger:hover { background: var(--danger-hover) !important; }

/* APP CONTAINER */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    flex-direction: row;
}

/* MAIN STAGE (VIDEO AREA) */
.main-stage {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    overflow: hidden;
}

.video-placeholder {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    z-index: 1;
    text-align: center;
}

.video-grid {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    padding: 20px;
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    align-content: center;
    justify-content: center;
}

/* VIDEO ELEMENTS */
.video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 200px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Like Zoom */
}

.video-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: white;
    backdrop-filter: blur(4px);
    z-index: 10;
}

/* Local PiP (Picture in Picture) */
.local-pip {
    position: absolute !important;
    bottom: 100px !important;
    right: 20px !important;
    width: 220px !important;
    height: 150px !important;
    z-index: 50 !important;
    border: 2px solid rgba(255,255,255,0.1);
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
}
.local-pip video {
    object-fit: cover;
}

/* FLOATING TOOLBAR */
.floating-toolbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(20px);
    border-radius: 50px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    z-index: 100;
}

.tool-btn {
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}
.tool-btn:hover { background: rgba(255, 255, 255, 0.2); transform: translateY(-2px); }
.tool-btn i { font-size: 20px; }

/* SIDEBAR */
.sidebar {
    width: 320px;
    height: 100%;
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.status-indicator {
    width: 10px; height: 10px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 10px #10b981;
}

.peer-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}
.peer-list::-webkit-scrollbar { width: 6px; }
.peer-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin: 15px 0 10px 0;
    letter-spacing: 1px;
}

ul { list-style: none; }
li {
    background: rgba(0,0,0,0.2);
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
    transition: border 0.2s;
}
li:hover { border-color: rgba(255,255,255,0.1); }

.actions button {
    background: rgba(255,255,255,0.1);
    color: white;
    padding: 6px;
    border-radius: 6px;
    margin-left: 5px;
}
.actions button:hover { background: rgba(255,255,255,0.2); }
.actions .btn-danger { background: var(--danger); }

/* MOBILE RESPONSIVE */
.mobile-only { display: none; }

@media (max-width: 768px) {
    .app-container { 
        flex-direction: column; 
        padding-top: 60px; /* Space for Mobile AppBar */
    }
    
    .mobile-appbar {
        position: fixed;
        top: 0; left: 0; width: 100%;
        height: 60px;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--glass-border);
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 15px;
        z-index: 90;
    }
    .mobile-appbar .tool-btn {
        background: transparent;
        box-shadow: none;
    }
    
    .sidebar {
          position: fixed;
          top: 0;
          left: 0;
          width: 80%;
          max-width: 320px;
          height: 100%;
          max-height: none;
          background: rgba(15, 23, 42, 0.98);
          backdrop-filter: blur(20px);
          border-right: 1px solid var(--glass-border);
          transform: translateX(-100%);
          transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
          z-index: 999;
      }
      .sidebar.open {
          transform: translateX(0);
      }
      .mobile-only { display: flex !important; }
      
      .floating-toolbar {
        width: 95%;
        bottom: 15px;
        justify-content: space-around;
        padding: 8px 15px;
        border-radius: 20px;
    }
    .tool-btn { width: 40px; height: 40px; }
    
    .video-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        padding-bottom: 80px; /* Space for toolbar */
    }
    
    .local-pip {
        width: 120px !important;
        height: 160px !important;
        bottom: 80px !important;
        right: 15px !important;
    }
}
/* CHAT PANEL */
.chat-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 320px;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-left: 1px solid var(--glass-border);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.chat-panel.open { transform: translateX(0); }
.chat-header {
    padding: 12px 15px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    font-weight: 600;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-input-area {
    padding: 12px 15px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 10px;
}
.chat-input {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    outline: none;
    font-size: 0.85rem;
}
.msg-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 0.85rem;
    color: white;
    word-break: break-word;
}
.msg-bubble.sent {
    background: var(--accent-blue);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.msg-bubble.received {
    background: rgba(255,255,255,0.1);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.msg-sender { font-size: 0.65rem; color: var(--text-muted); margin-bottom: 3px; }
/* LOG MODAL */
.log-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}
.log-modal.active { display: flex; }
.log-box {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}
.log-header {
    padding: 15px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    font-weight: 600;
}
.log-body {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.log-item {
    background: rgba(255,255,255,0.05);
    padding: 10px;
    border-radius: 8px;
    color: white;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.log-item.active-log { border-left: 3px solid var(--accent-blue); }
.log-item.ended-log { border-left: 3px solid #64748b; opacity: 0.7; }
.log-time { color: var(--text-muted); font-size: 0.7rem; }
.log-duration { font-family: monospace; font-size: 0.85rem; font-weight: 600; }
