:root {
    --bg-image: url('https://images.unsplash.com/photo-1579546929518-9e396f3cc809?ixlib=rb-1.2.1&auto=format&fit=crop&w=1950&q=80');
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.3);
    --text-color: #333;
    --accent-color: #007bff;
    --msg-sent-bg: #007bff;
    --msg-sent-text: #fff;
    --msg-recv-bg: rgba(255, 255, 255, 0.6);
    --sidebar-w: 280px;
}

[data-theme="dark"] {
    --glass-bg: rgba(0, 0, 0, 0.5);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-color: #eee;
    --accent-color: #4a90e2;
    --msg-recv-bg: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: sans-serif; color: var(--text-color); }

.bg-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-image: var(--bg-image);
    background-size: cover; background-position: center;
    z-index: -1;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Auth */
.center-panel {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90%; max-width: 400px;
    padding: 30px; text-align: center;
}

.input-group { margin-bottom: 15px; position: relative; }
input, select {
    width: 100%; padding: 10px;
    border: none; border-radius: 8px;
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-color);
}
.primary-btn {
    width: 100%; padding: 10px; border: none; border-radius: 8px;
    background: var(--accent-color); color: white; cursor: pointer;
}
.danger-btn { background: #ff4757; color: white; border:none; padding:8px 16px; border-radius:4px; cursor:pointer;}
.secondary-btn { background: #747d8c; color: white; border:none; padding:8px 16px; border-radius:4px; cursor:pointer;}

/* Main Layout */
.main-layout {
    width: 90%; height: 90vh;
    margin: 5vh auto;
    display: flex; overflow: hidden;
}

.sidebar {
    width: var(--sidebar-w); border-right: 1px solid var(--glass-border);
    display: flex; flex-direction: column;
}

.my-profile { padding: 15px; display: flex; align-items: center; border-bottom: 1px solid var(--glass-border); }
.avatar { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; margin-right: 10px; }
.avatar-sm { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; margin-right: 10px; }
.info { flex: 1; display: flex; flex-direction: column; }
.uid-tag { font-size: 0.8em; opacity: 0.7; }

.nav-tabs { display: flex; }
.tab-btn { flex: 1; background: transparent; border: none; padding: 10px; cursor: pointer; color: var(--text-color); border-bottom: 2px solid transparent;}
.tab-btn.active { border-bottom-color: var(--accent-color); }

.list-container { flex: 1; overflow-y: auto; }
.list-item { padding: 10px; display: flex; align-items: center; cursor: pointer; }
.list-item:hover { background: rgba(255,255,255,0.1); }
.item-info { display: flex; flex-direction: column; }
.preview { font-size: 0.8em; opacity: 0.7; }

.bottom-actions { padding: 10px; border-top: 1px solid var(--glass-border); }
.action-btn { width: 100%; padding: 8px; background: rgba(255,255,255,0.3); border: none; border-radius: 4px; cursor:pointer;}

.chat-area { flex: 1; display: flex; flex-direction: column; background: rgba(0,0,0,0.02); }
.chat-header { padding: 15px; border-bottom: 1px solid var(--glass-border); font-weight: bold; }
.messages-container { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 10px; }

.message { max-width: 70%; padding: 10px; border-radius: 10px; word-wrap: break-word; position: relative;}
.message.sent { align-self: flex-end; background: var(--msg-sent-bg); color: var(--msg-sent-text); border-bottom-right-radius: 2px; }
.message.recv { align-self: flex-start; background: var(--msg-recv-bg); border-bottom-left-radius: 2px; }
.message img { max-width: 100%; border-radius: 5px; }

.input-area { padding: 10px; border-top: 1px solid var(--glass-border); }
.toolbar { display: flex; gap: 10px; margin-bottom: 5px; position: relative;}
.toolbar button { background: none; border: none; font-size: 1.2em; cursor: pointer; }
textarea { width: 100%; height: 50px; resize: none; border: none; background: transparent; outline: none; color: var(--text-color); }

/* Modal */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 100; display: flex; justify-content: center; align-items: center; }
.modal-content { width: 90%; max-width: 400px; padding: 20px; }
.form-group { margin-bottom: 10px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 0.9em; }
.modal-actions { margin-top: 20px; display: flex; justify-content: space-between; }

/* Emoji Picker */
.emoji-picker { position: absolute; bottom: 40px; left: 0; background: white; border: 1px solid #ccc; padding: 5px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; border-radius: 8px; width: 200px; height: 150px; overflow-y: auto; z-index: 10; }
.emoji-picker span { cursor: pointer; padding: 5px; text-align: center;}
.emoji-picker span:hover { background: #eee; }

/* Responsive */
@media (max-width: 768px) {
    .main-layout { width: 100%; height: 100vh; margin: 0; border-radius: 0; flex-direction: column; }
    .sidebar { width: 100%; height: 100%; display: flex; } /* Mobile View Toggles */
    .sidebar.hidden { display: none; }
    .chat-area { width: 100%; height: 100%; display: none; }
    .chat-area.active { display: flex; }
    
    /* Back button for mobile */
    .chat-header::before { content: '←'; margin-right: 10px; cursor: pointer; }
}