:root {
    --bg-color: #0f1115;
    --card-bg: #1e2128;
    --accent: #4a90e2;
    --accent-hover: #357abd;
    --danger: #ff4757;
    --text: #ffffff;
    --text-muted: #a0a0a0;
    --sidebar-width: 320px;
    --control-bar-height: 70px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex: 1;
    height: calc(100vh - var(--control-bar-height));
    position: relative;
}

/* Video Grid - Smart Layout */
.video-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    grid-auto-rows: minmax(200px, 1fr);
    gap: 1.5rem;
    padding: 1.5rem;
    align-content: center;
    max-width: 1600px;
    margin: 0 auto;
}

/* Video Cards */
.video-card {
    background-color: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    aspect-ratio: 16/9;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s;
}

.video-card:hover {
    transform: scale(1.01);
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror effect for self */
}

/* Remote videos should generally NOT be mirrored, but let's keep consistency for now */
.remote-user video {
    transform: scaleX(1);
}

.name-tag {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    pointer-events: none;
}

/* AI Persona Specifics */
.ai-persona {
    border: 1px solid var(--accent);
    background: radial-gradient(circle at center, #1a2a3a 0%, #000 100%);
}

.ai-status {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
}

#aiVisualizer {
    width: 100%;
    height: 100%;
    opacity: 0.8;
}

.pulsing-dot {
    width: 8px;
    height: 8px;
    background-color: #444;
    border-radius: 50%;
    transition: background-color 0.3s;
}

/* AI Stats Overlay */
.ai-stats {
    position: absolute;
    top: 12px;
    left: 12px;
    right: auto;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    padding: 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.5;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Chat Sidebar */
.chat-sidebar {
    width: var(--sidebar-width);
    background-color: var(--card-bg);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.chat-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-msg {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 14px;
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    font-size: 0.9rem;
    line-height: 1.4;
    max-width: 85%;
}

.chat-msg strong {
    display: block;
    color: var(--accent);
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.chat-msg.self {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-radius: 12px;
    border-bottom-right-radius: 2px;
}

.chat-msg.self strong {
    color: rgba(255, 255, 255, 0.8);
}

#chat-form {
    padding: 1.5rem;
    display: flex;
    gap: 10px;
    background: rgba(0,0,0,0.2);
}

#chat-form input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    outline: none;
    transition: border-color 0.2s;
}

#chat-form input:focus {
    border-color: var(--accent);
}

#chat-form button {
    padding: 0 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

#chat-form button:hover {
    background: var(--accent-hover);
}

/* Floating Controls Bar */
.controls-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 33, 40, 0.85);
    backdrop-filter: blur(12px);
    padding: 12px 24px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
}

.control-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.control-btn.active {
    background: var(--accent);
    color: white;
}

.control-btn.danger {
    background: rgba(255, 71, 87, 0.2);
    color: var(--danger);
}

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

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: 100vh;
    }

    .chat-sidebar {
        display: none; /* Hide chat on mobile for simplicity in this demo */
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 80%;
    }

    .video-grid {
        grid-template-columns: 1fr;
        padding: 1rem;
        padding-bottom: 100px; /* Space for controls */
    }

    .controls-bar {
        width: 90%;
        bottom: 20px;
        overflow-x: auto;
        justify-content: flex-start;
        padding: 12px;
    }
}
/* ... Existing styles ... */

/* WAITING ROOM OVERLAY */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.overlay-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.overlay-content h2 {
    margin-top: 0;
    color: var(--accent);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    margin: 20px auto 0;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* HOST NOTIFICATIONS (TOASTS) */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 90%;
    max-width: 400px;
}

.toast {
    background: #1e2128;
    color: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.3s ease-out;
}

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

.toast-message {
    font-size: 0.9rem;
    font-weight: 500;
}

.toast-actions {
    display: flex;
    gap: 8px;
}

.toast-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
}

.toast-btn.accept {
    background: var(--accent);
    color: white;
}

.toast-btn.deny {
    background: rgba(255, 71, 87, 0.2);
    color: var(--danger);
}

.toast-btn:hover {
    filter: brightness(1.1);
}
