:root {
    --bg-color: #0f1115;
    --card-bg: #181b21;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --success: #10b981;
    --border: #2d3748;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.user-corner {
    position: fixed;
    top: 20px;
    right: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--card-bg);
    transition: 0.2s;
    z-index: 1000;
}
.user-corner:hover { border-color: #666; color: #fff; }

.container {
    width: 100%;
    max-width: 480px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    position: relative;
}

header { text-align: center; margin-bottom: 25px; }
h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 5px; }
.subtitle { color: var(--text-secondary); font-size: 0.9rem; }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 10px;
}
.status-badge.offline { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.dot { height: 8px; width: 8px; border-radius: 50%; background: currentColor; animation: pulse 2s infinite; }

.room-list { display: flex; flex-direction: column; gap: 15px; margin: 25px 0; }

.room-card {
    background: #22262e;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s;
    overflow: hidden;
    position: relative;
}
.room-card:hover { border-color: var(--accent); }

.room-info { 
    flex: 1; 
    min-width: 0; /* Necessary for flexbox text truncation/scrolling to work */
    margin-right: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden; /* Ensure text doesn't bleed out of this container */
}

/* --- FINAL SCROLLING LOGIC --- */
.scrolling-wrapper {
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    /* Fade on the right side only */
    mask-image: linear-gradient(90deg, #000 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent 100%);
}

.scrolling-text {
    display: inline-block;
    font-size: 1rem; 
    font-weight: 600; 
    margin-bottom: 4px;
    /* padding-right adds a buffer so when it scrolls out, there's a gap before snap back */
    padding-right: 50px; 
    transform: translateX(0); /* Default start position (Left) */
}

/* 0% - 15%: Stay at start (Readability Pause)
   15% - 85%: Scroll completely to the left (-100%)
   85% - 85.1%: Instant Snap back to 0 (while invisible)
   85.1% - 100%: Stay at start (Pause before restart)
*/
@keyframes scroll-left {
    0%, 15% { transform: translateX(0); }
    85% { transform: translateX(-100%); }
    85.1% { transform: translateX(0); }
    100% { transform: translateX(0); }
}

.scroll-active {
    animation: scroll-left 12s linear infinite;
}

.room-meta { font-size: 0.8rem; color: var(--text-secondary); display: flex; align-items: center; gap: 5px; }

.btn-join {
    background: var(--accent);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}
.btn-join:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-create {
    display: block;
    width: 100%;
    background: #2d3748;
    color: white;
    text-align: center;
    padding: 14px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    margin-top: 10px;
    transition: background 0.2s;
}
.btn-create:hover { background: #4a5568; }

.btn-create.btn-accent {
    background: var(--accent);
}
.btn-create.btn-accent:hover {
    background: var(--accent-hover);
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}
.modal {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 350px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.modal h2 { margin-bottom: 20px; font-size: 1.2rem; }
.input-group { margin-bottom: 15px; text-align: left; }
.input-group label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 5px; }
.input-group input { 
    width: 100%; padding: 10px; 
    border-radius: 8px; border: 1px solid var(--border); 
    background: #111; color: white; 
}
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-cancel { background: transparent; border: 1px solid var(--border); color: #ccc; }

.footer-stats {
    display: flex;
    justify-content: center;
    border-top: 1px solid var(--border);
    padding-top: 20px;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.stat-item { display: flex; align-items: center; gap: 8px; }

.icon { width: 16px; height: 16px; fill: currentColor; }
.icon-lock { fill: #ef4444; width: 14px; height: 14px; margin-left: 5px; display: inline-block; vertical-align: -0.1em; }

#jitsi-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-color);
    z-index: 4000;
}
