* { margin: 0; padding: 0; box-sizing: border-box; direction: rtl; }
body { font-family: 'Segoe UI', Tahoma, Arial, sans-serif; background: #0d1117; color: #c9d1d9; min-height: 100vh; }

/* ===== AUTH ===== */
#authPage { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px;
    background: radial-gradient(ellipse at 50% 0%, #161b22 0%, #0d1117 70%); }
.auth-box { background: #161b22; border: 1px solid #30363d; border-radius: 14px; padding: 28px 24px; width: 100%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,.4); }
.auth-box h2 { text-align: center; color: #58a6ff; margin-bottom: 24px; font-size: clamp(18px, 5vw, 24px); font-weight: 700; letter-spacing: .5px; }
.tabs { display: flex; margin-bottom: 20px; }
.tab { flex: 1; padding: 10px 8px; border: none; background: #21262d; color: #8b949e; cursor: pointer; font-size: 13px; transition: background .2s, color .2s; }
.tab:first-child { border-radius: 8px 0 0 8px; }
.tab:last-child { border-radius: 0 8px 8px 0; }
.tab.active { background: #238636; color: #fff; }
.auth-box input[type="text"], .auth-box input[type="password"] {
    width: 100%; padding: 12px 14px; margin-bottom: 12px; border: 1px solid #30363d;
    border-radius: 8px; background: #0d1117; color: #c9d1d9; font-size: 14px; outline: none;
    transition: border-color .15s;
}
.auth-box input[type="text"]:focus, .auth-box input[type="password"]:focus { border-color: #58a6ff; }
.auth-box button[type="submit"] {
    width: 100%; padding: 12px; border: none; border-radius: 8px; background: #238636;
    color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.auth-box button[type="submit"]:hover { background: #2ea043; }
.avatar-upload { margin-bottom: 12px; }
.avatar-label { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px dashed #30363d; border-radius: 8px; cursor: pointer; font-size: 13px; color: #8b949e; transition: border-color .15s; }
.avatar-label:hover { border-color: #58a6ff; }
#avatarPreview { width: 100%; max-height: 120px; object-fit: cover; border-radius: 8px; margin-top: 8px; }
.error { color: #f85149; font-size: 12px; margin-top: 8px; text-align: center; min-height: 1em; }

/* ===== DASHBOARD ===== */
#dashboard { min-height: 100vh; background: #0d1117; }
.dash-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; background: #161b22; border-bottom: 1px solid #30363d;
    position: sticky; top: 0; z-index: 10;
}
.dash-user { display: flex; align-items: center; gap: 10px; }
.dash-user img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid #30363d; }
.dash-user span { font-size: 16px; font-weight: 700; }
#logoutBtn { padding: 8px 18px; border: none; border-radius: 8px; background: #21262d; color: #f85149; cursor: pointer; font-size: 13px; transition: background .15s; }
#logoutBtn:hover { background: #30363d; }
.dash-body { max-width: 600px; margin: 0 auto; padding: 20px 16px; }
.dash-body h3 { font-size: 15px; color: #8b949e; margin: 24px 0 12px; font-weight: 600; letter-spacing: .3px; }

/* ===== USER LIST ===== */
#userList { display: flex; flex-direction: column; gap: 6px; }
.user-card {
    display: flex; align-items: center; gap: 10px;
    background: #161b22; border: 1px solid #30363d; border-radius: 10px; padding: 10px 14px;
    transition: border-color .15s;
}
.user-card:hover { border-color: #58a6ff; }
.user-card .avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.user-card .info { flex: 1; min-width: 0; }
.user-card .name { font-size: 14px; font-weight: 600; }
.user-card .status { font-size: 11px; margin-top: 2px; }
.user-card .status.online { color: #3fb950; }
.user-card .status.offline { color: #8b949e; }
.call-btn { padding: 8px 16px; border: none; border-radius: 8px; background: #1f6feb; color: #fff; cursor: pointer; font-size: 13px; font-weight: 600; transition: background .15s; white-space: nowrap; }
.call-btn:hover { background: #388bfd; }

/* ===== BROADCAST ===== */
.dash-body > h3:first-of-type { margin-top: 0; }
#startBroadcastBtn {
    display: block; width: 100%; padding: 14px; margin: 10px 0 16px;
    border: none; border-radius: 10px;
    background: linear-gradient(135deg, #da3633, #f85149);
    color: #fff; font-size: 15px; font-weight: bold; cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    box-shadow: 0 0 14px rgba(248,81,73,.3);
}
#startBroadcastBtn:hover { transform: scale(1.02); box-shadow: 0 0 24px rgba(248,81,73,.45); }
#startBroadcastBtn:active { transform: scale(.98); }
#broadcastList { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.broadcast-card {
    display: flex; align-items: center; justify-content: space-between;
    background: #161b22; border: 1px solid #30363d; border-radius: 10px; padding: 12px 14px;
    transition: border-color .15s;
}
.broadcast-card:hover { border-color: #f85149; }
.broadcast-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.live-badge {
    display: inline-flex; align-items: center; gap: 4px;
    background: #f85149; color: #fff; font-size: 11px; font-weight: bold;
    padding: 2px 8px; border-radius: 4px; white-space: nowrap;
}
.live-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse-dot 1.2s infinite; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.broadcast-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.broadcast-viewers { font-size: 11px; color: #8b949e; white-space: nowrap; }
.watch-btn {
    padding: 7px 16px; border: none; border-radius: 6px; background: #1f6feb;
    color: #fff; cursor: pointer; font-size: 12px; font-weight: 600;
    transition: background .15s; white-space: nowrap;
}
.watch-btn:hover { background: #388bfd; }

/* ===== ROOM ===== */
#room { display: flex; flex-direction: column; height: 100vh; background: #0d1117; }
#header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; background: #161b22; border-bottom: 1px solid #30363d;
    flex-shrink: 0;
}
#roomInfo { font-size: 14px; font-weight: 600; }
#broadcastStatus { color: #f85149; font-size: 13px; font-weight: bold; }
#viewerCount { margin: 0 10px; color: #8b949e; font-size: 12px; }
#leaveBtn { padding: 7px 16px; border: none; border-radius: 8px; background: #da3633; color: #fff; cursor: pointer; font-size: 13px; font-weight: 600; transition: background .15s; }
#leaveBtn:hover { background: #f85149; }
#broadcastControls { text-align: center; padding: 6px 0; flex-shrink: 0; }
#stopBroadcastBtn {
    padding: 8px 24px; border: none; border-radius: 8px; background: #da3633;
    color: #fff; cursor: pointer; font-size: 13px; font-weight: bold;
    transition: background .15s;
}
#stopBroadcastBtn:hover { background: #f85149; }

/* ===== VIDEOS ===== */
#videos {
    display: flex; gap: 10px; padding: 10px 16px;
    flex: 1; overflow: hidden;
}
.video-container { position: relative; flex: 1; min-width: 0; border-radius: 12px; overflow: hidden; background: #0d1117; border: 1px solid #30363d; }
.video-container video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.video-container .label { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,.65); padding: 3px 10px; border-radius: 6px; font-size: 11px; color: #c9d1d9; backdrop-filter: blur(4px); }
#remoteVideoContainer { display: none; } /* hidden by default, shown when a peer connects */

/* ===== CONTROLS ===== */
#controls {
    display: flex; justify-content: center; gap: 12px; padding: 10px 16px;
    flex-shrink: 0;
}
.control-btn {
    width: 48px; height: 48px; border: none; border-radius: 50%;
    font-size: 20px; cursor: pointer; transition: background .15s, transform .1s;
    display: flex; align-items: center; justify-content: center;
}
.control-btn.active { background: #21262d; color: #c9d1d9; }
.control-btn.inactive { background: #da3633; color: #fff; }
.control-btn:active { transform: scale(.9); }

/* ===== CHAT ===== */
#chatArea { display: flex; flex-direction: column; flex-shrink: 0; border-top: 1px solid #30363d; background: #161b22; }
#messages { height: 150px; overflow-y: auto; padding: 10px 16px; display: flex; flex-direction: column; gap: 4px; }
.msg-system { text-align: center; font-size: 12px; color: #8b949e; padding: 2px 0; }
.msg-name { font-weight: 600; font-size: 13px; color: #58a6ff; }
.msg-text { font-size: 13px; word-break: break-word; }
.chat-image { max-width: 180px; max-height: 180px; border-radius: 8px; cursor: pointer; display: block; margin-top: 4px; transition: filter .2s; }
.chat-image.blurred { filter: blur(20px); }
.nsfw-badge { font-size: 10px; color: #f85149; font-weight: bold; display: inline-block; margin-top: 2px; }
#chatInputRow { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid #21262d; }
#chatInput { flex: 1; padding: 10px 14px; border: 1px solid #30363d; border-radius: 8px; background: #0d1117; color: #c9d1d9; font-size: 13px; outline: none; transition: border-color .15s; }
#chatInput:focus { border-color: #58a6ff; }
.upload-btn { display: flex; align-items: center; padding: 0 10px; font-size: 20px; cursor: pointer; transition: transform .1s; }
.upload-btn:hover { transform: scale(1.1); }
#sendBtn { padding: 10px 20px; border: none; border-radius: 8px; background: #238636; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s; }
#sendBtn:hover { background: #2ea043; }

/* ===== CALL NOTIFICATION ===== */
.call-notification {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    background: #161b22; border: 1px solid #58a6ff; border-radius: 12px;
    padding: 16px 24px; box-shadow: 0 8px 32px rgba(0,0,0,.5);
    z-index: 100; display: flex; align-items: center; gap: 16px;
}
.call-notification p { font-size: 14px; }
.caller-name { color: #58a6ff; font-weight: bold; }
.accept-btn, .reject-btn { padding: 8px 18px; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s; }
.accept-btn { background: #238636; color: #fff; }
.accept-btn:hover { background: #2ea043; }
.reject-btn { background: #da3633; color: #fff; }
.reject-btn:hover { background: #f85149; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    #videos { flex-direction: column; }
    .dash-body { padding: 16px 12px; }
    .call-notification { left: 8px; right: 8px; transform: none; flex-wrap: wrap; justify-content: center; }
    #messages { height: 120px; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0d1117; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }