:root {
    --bg-dark: #0f172a;
    --bg-sidebar: #1e293b99; /* Transparent for blur */
    --primary: #6366f1;
    --primary-glow: #6366f166;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.1);
    --glass: rgba(30, 41, 59, 0.7);
    --danger: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Plus Jakarta Sans', sans-serif; }

body { 
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
    color: var(--text-main); height: 100vh; overflow: hidden; 
}

/* Utilities */
.hidden { display: none !important; }
button { cursor: pointer; border: none; outline: none; transition: 0.2s; }

/* Auth Screen */
#auth-screen { display: flex; align-items: center; justify-content: center; height: 100vh; backdrop-filter: blur(10px); }
.auth-card { background: var(--glass); padding: 2.5rem; border-radius: 24px; width: 380px; border: 1px solid var(--border); box-shadow: 0 20px 40px rgba(0,0,0,0.3); }
.brand { text-align: center; font-size: 1.8rem; font-weight: 700; color: white; margin-bottom: 20px; }
.brand i { color: var(--primary); }
.tabs { display: flex; background: rgba(0,0,0,0.2); border-radius: 12px; padding: 4px; margin-bottom: 20px; }
.tabs button { flex: 1; padding: 10px; border-radius: 8px; background: transparent; color: var(--text-muted); font-weight: 600; }
.tabs button.active { background: var(--primary); color: white; box-shadow: 0 4px 12px var(--primary-glow); }

.input-group { position: relative; margin-bottom: 15px; }
.input-group i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-group input { width: 100%; padding: 12px 12px 12px 40px; border-radius: 12px; border: 1px solid var(--border); background: rgba(0,0,0,0.2); color: white; font-size: 0.95rem; }
.input-group input:focus { border-color: var(--primary); }
#auth-btn { width: 100%; padding: 12px; border-radius: 12px; background: var(--primary); color: white; font-weight: 600; font-size: 1rem; margin-top: 10px; }
#auth-error { color: var(--danger); text-align: center; margin-top: 15px; font-size: 0.9rem; }

/* App Layout */
#app-ui { display: flex; height: 100vh; backdrop-filter: blur(5px); }

/* Sidebar */
.sidebar { width: 280px; background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; backdrop-filter: blur(20px); }
.user-profile { padding: 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.user-profile img { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--primary); }
.user-info { display: flex; flex-direction: column; }
.user-info .status { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; background: #22c55e; border-radius: 50%; display: inline-block; }

.menu { flex: 1; padding: 20px; overflow-y: auto; }
.section-label { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); margin: 20px 0 10px; font-weight: 700; letter-spacing: 0.5px; display: flex; justify-content: space-between; align-items: center; }
.section-label i { cursor: pointer; padding: 5px; border-radius: 4px; }
.section-label i:hover { color: var(--primary); background: rgba(255,255,255,0.05); }

.menu ul li { list-style: none; padding: 10px 12px; margin-bottom: 4px; border-radius: 10px; cursor: pointer; color: var(--text-muted); display: flex; align-items: center; justify-content: space-between; transition: 0.2s; font-weight: 500; }
.menu ul li:hover { background: rgba(255,255,255,0.05); color: white; }
.menu ul li.active { background: var(--primary); color: white; box-shadow: 0 4px 15px var(--primary-glow); }

/* --- Notification Badge --- */
.badge { background: var(--danger); color: white; font-size: 0.7rem; padding: 2px 6px; border-radius: 10px; font-weight: bold; min-width: 18px; text-align: center; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popIn { from { transform: scale(0); } to { transform: scale(1); } }

/* Chat Area */
.chat-container { flex: 1; display: flex; flex-direction: column; position: relative; }
.chat-header { padding: 15px 25px; border-bottom: 1px solid var(--border); background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(10px); display: flex; justify-content: space-between; align-items: center; z-index: 10; }
.chat-header h3 { font-size: 1.1rem; }
.member-count { font-size: 0.8rem; color: #22c55e; background: rgba(34, 197, 94, 0.1); padding: 4px 8px; border-radius: 6px; }

#messages-area { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth; }
.empty-state { text-align: center; color: var(--text-muted); margin-top: 20%; font-style: italic; }

/* Messages */
.message { display: flex; gap: 14px; max-width: 70%; animation: slideUp 0.3s ease-out; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.message.self { margin-left: auto; flex-direction: row-reverse; }
.message img.avatar { width: 38px; height: 38px; border-radius: 12px; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.msg-content { display: flex; flex-direction: column; }
.msg-bubble { background: #334155; padding: 12px 16px; border-radius: 0 16px 16px 16px; color: #e2e8f0; font-size: 0.95rem; line-height: 1.5; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.self .msg-bubble { background: var(--primary); color: white; border-radius: 16px 0 16px 16px; box-shadow: 0 4px 15px var(--primary-glow); }
.msg-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 5px; margin-left: 2px; }
.self .msg-meta { text-align: right; margin-right: 2px; }
.msg-image { max-width: 280px; border-radius: 12px; margin-bottom: 8px; border: 1px solid var(--border); }

/* Input Area */
.chat-input-area { padding: 20px; background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(10px); border-top: 1px solid var(--border); }
.input-wrapper { background: rgba(255,255,255,0.05); border-radius: 16px; padding: 8px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); }
.input-wrapper:focus-within { border-color: var(--primary); background: rgba(255,255,255,0.08); }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; background: transparent; color: var(--text-muted); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.icon-btn:hover { background: rgba(255,255,255,0.1); color: var(--primary); }
#msg-input { flex: 1; background: transparent; border: none; color: white; font-size: 1rem; padding: 0 5px; }
.send-btn { width: 40px; height: 40px; border-radius: 10px; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; }
.send-btn:hover { background: #4f46e5; transform: scale(1.05); }

/* Toast Notification */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: rgba(30, 41, 59, 0.9); backdrop-filter: blur(10px); color: white; padding: 15px 20px; border-radius: 12px; border-left: 4px solid var(--primary); box-shadow: 0 10px 30px rgba(0,0,0,0.5); display: flex; align-items: center; gap: 12px; min-width: 250px; animation: slideInRight 0.3s ease-out; }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast i { color: var(--primary); font-size: 1.2rem; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal-card { background: #1e293b; width: 400px; border-radius: 20px; border: 1px solid var(--border); overflow: hidden; animation: popIn 0.3s ease; }
.modal-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header i { cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 15px; }
.modal-footer { padding: 20px; background: rgba(0,0,0,0.2); text-align: right; }
.primary-btn { padding: 10px 20px; background: var(--primary); color: white; border-radius: 8px; font-weight: 600; }
