:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-sidebar: #fafbfc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --success: #22c55e;
    --danger: #ef4444;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

.chat-container { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); }

.logo { display: flex; align-items: center; gap: 10px; }

.logo-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 14px;
}

.logo-text { font-size: 16px; font-weight: 600; }

.sidebar-section { padding: 12px; flex: 1; display: flex; flex-direction: column; min-height: 0; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

.section-title {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted);
}

.btn-icon {
    width: 28px; height: 28px; border-radius: 6px; border: none;
    background: transparent; color: var(--text-secondary);
    font-size: 18px; cursor: pointer;
}
.btn-icon:hover { background: var(--bg-tertiary); color: var(--primary); }

.room-list, .user-list { flex: 1; overflow-y: auto; min-height: 0; }

.room-item {
    display: flex; align-items: center; padding: 10px 12px;
    border-radius: var(--radius); cursor: pointer; gap: 8px; margin-bottom: 2px;
    font-size: 14px;
}
.room-item:hover { background: var(--bg-tertiary); }
.room-item.active { background: var(--primary-light); color: var(--primary); }

.room-hash { color: var(--text-muted); font-weight: 500; width: 18px; flex-shrink: 0; }
.room-name { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-count { font-size: 10px; color: var(--text-muted); background: var(--bg-tertiary); padding: 2px 6px; border-radius: 10px; flex-shrink: 0; }

.user-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius); font-size: 13px; color: var(--text-secondary); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }

.connection-status { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }

.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg-primary); min-width: 0; }

.welcome-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 24px; text-align: center; }
.welcome-icon { width: 64px; height: 64px; background: var(--primary-light); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.welcome-screen h1 { font-size: 22px; font-weight: 600; }
.welcome-screen p { color: var(--text-secondary); font-size: 14px; }

.room-selection-screen { flex: 1; display: flex; flex-direction: column; padding: 24px; }
.room-selection-header { text-align: center; margin-bottom: 20px; }
.room-selection-header h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.room-selection-header p { color: var(--text-secondary); font-size: 14px; }
.room-selection-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.room-selection-item { display: flex; align-items: center; padding: 14px 16px; background: var(--bg-tertiary); border-radius: var(--radius); cursor: pointer; gap: 12px; }
.room-selection-item:hover { background: var(--bg-secondary); }
.room-selection-item .room-name { font-weight: 500; }
.room-selection-item .room-meta { font-size: 12px; color: var(--text-muted); }
.room-selection-actions { margin-top: 16px; }

.join-form { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 260px; }
.join-form input { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 16px; width: 100%; outline: none; -webkit-appearance: none; }
.join-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.btn-primary { padding: 14px 24px; border: none; border-radius: var(--radius); background: var(--primary); color: white; font-weight: 500; font-size: 16px; cursor: pointer; width: 100%; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { padding: 10px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-primary); color: var(--text-primary); font-weight: 500; font-size: 14px; cursor: pointer; }
.btn-danger { padding: 10px 16px; border: none; border-radius: var(--radius); background: var(--danger); color: white; font-weight: 500; font-size: 14px; cursor: pointer; }

.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-header-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.chat-header h2 { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header-meta { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.chat-header-actions { flex-shrink: 0; }

.message-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 4px; min-height: 0; }

.message { max-width: 80%; padding: 10px 14px; border-radius: var(--radius); background: var(--bg-tertiary); font-size: 14px; }
.message.own { align-self: flex-end; background: var(--primary); color: white; }
.message-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.message-header .username { font-weight: 600; font-size: 12px; }
.message-header .timestamp { font-size: 10px; color: var(--text-muted); }
.message.own .message-header .username, .message.own .message-header .timestamp { color: rgba(255,255,255,0.8); }
.message-content { font-size: 14px; line-height: 1.4; word-wrap: break-word; }

.typing-indicator { font-size: 12px; color: var(--text-muted); font-style: italic; padding: 4px 8px; }

.message-input-container { padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.message-input-wrapper { display: flex; align-items: center; gap: 8px; background: var(--bg-tertiary); border-radius: 12px; padding: 8px 8px 8px 12px; border: 1px solid var(--border); }
.message-input-wrapper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.message-input { flex: 1; border: none; background: transparent; font-size: 15px; outline: none; color: var(--text-primary); -webkit-appearance: none; }
.send-btn { width: 36px; height: 36px; border-radius: var(--radius); border: none; background: var(--primary); color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--bg-primary); padding: 24px; border-radius: var(--radius); width: 100%; max-width: 360px; }
.modal h3 { margin-bottom: 16px; font-size: 18px; font-weight: 600; }
.modal input[type="text"] { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 16px; margin-bottom: 14px; outline: none; -webkit-appearance: none; }
.modal input[type="text"]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.modal label { display: flex; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 16px; cursor: pointer; color: var(--text-secondary); }
.modal input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions button { flex: 1; }

.video-section { padding: 8px; background: var(--bg-tertiary); border-bottom: 1px solid var(--border); flex-shrink: 0; max-height: 280px; overflow: hidden; }
.video-grid { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; align-items: flex-start; }
.video-tile { position: relative; width: 240px; height: 180px; background: #1e293b; border-radius: 6px; overflow: hidden; flex-shrink: 0; }
.video-tile video { width: 100%; height: 100%; object-fit: cover; }
.video-tile.local video { transform: scaleX(-1); }
.participant-name { position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,0.7); color: white; padding: 2px 6px; border-radius: 3px; font-size: 11px; }
.video-admin-controls { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; }
.video-admin-controls button { width: 28px; height: 28px; border: none; border-radius: 4px; background: rgba(0,0,0,0.7); color: white; font-size: 12px; cursor: pointer; }
.video-admin-controls button:hover { background: var(--primary); }

@media (max-width: 768px) {
    .video-section { max-height: 200px; }
    .video-tile { width: 140px; height: 105px; }

.chat-header-actions button { font-size: 13px; padding: 8px 12px; }

.mobile-header { display: none; padding: 12px 16px; background: var(--bg-primary); border-bottom: 1px solid var(--border); align-items: center; gap: 12px; }
.mobile-menu-btn { width: 36px; height: 36px; border: none; background: transparent; font-size: 20px; cursor: pointer; }

@media (max-width: 768px) {
    .sidebar { 
        position: fixed; 
        left: 0; 
        top: 0; 
        bottom: 0; 
        z-index: 100; 
        transform: translateX(-100%); 
        transition: transform 0.3s ease;
        width: 85%;
        max-width: 300px;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }
    .sidebar-overlay.open { display: block; }
    
    .mobile-header { display: flex; }
    
    .chat-header { padding: 10px 12px; }
    .message-list { padding: 12px; }
    .message-input-container { padding: 10px 12px; }
    
    .message { max-width: 90%; padding: 8px 12px; }
    .welcome-screen { padding: 20px; }
    .welcome-icon { width: 56px; height: 56px; font-size: 24px; }
    .welcome-screen h1 { font-size: 20px; }
    
    .video-section { padding: 6px; max-height: 160px; }
    .video-tile { width: 120px; height: 90px; }
}
