:root {
    --bg-color: #0f0f0f;
    --sidebar-bg: #1c1c1d;
    --chat-bg: #0e0e0e;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-color: #ffffff;
    --text-muted: #8e8e93;
    --accent-color: #2a52be;
    --accent-hover: #3b66e0;
    --bubble-out: #2b5278;
    --bubble-in: #182533;
    --sidebar-width: 320px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body, html { height: 100%; width: 100%; font-family: 'Roboto', sans-serif; background-color: var(--bg-color); color: var(--text-color); overflow: hidden; }

.tg-layout { display: flex; height: 100vh; width: 100vw; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 10;
}

.sidebar-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
}

.menu-btn { font-size: 20px; cursor: pointer; color: var(--text-muted); }

.search-container { flex: 1; position: relative; }
.search-container input {
    width: 100%;
    background: #242425;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    color: white;
    outline: none;
    font-size: 14px;
}

.contact-list { flex: 1; overflow-y: auto; }

.contact-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.contact-item:hover { background: rgba(255,255,255,0.05); }
.contact-item.active { background: var(--accent-color); }

.avatar {
    width: 48px; height: 48px; border-radius: 50%;
    background: #5085b1; display: flex; align-items: center;
    justify-content: center; font-weight: 700; font-size: 18px;
    text-transform: uppercase;
}

.contact-info { flex: 1; overflow: hidden; }
.contact-info h4 { font-size: 15px; margin-bottom: 2px; }
.contact-info p { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border-color); }
.btn-primary {
    width: 100%; padding: 12px; border: none; border-radius: 8px;
    background-color: var(--accent-color); color: white;
    font-weight: 500; cursor: pointer; transition: background 0.2s;
}
.btn-primary:hover { background-color: var(--accent-hover); }

/* Chat Area */
.chat-area { flex: 1; background-color: var(--chat-bg); position: relative; display: flex; flex-direction: column; }

.welcome-screen {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.welcome-bubble { background: rgba(0,0,0,0.3); padding: 8px 16px; border-radius: 20px; font-size: 14px; color: var(--text-muted); }

.chat-container { display: flex; flex-direction: column; height: 100%; }

.chat-header {
    padding: 8px 16px; 
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 12px;
}

.back-btn { display: none; cursor: pointer; font-size: 20px; }

.user-info { display: flex; align-items: center; gap: 12px; }
.user-info .avatar { width: 36px; height: 36px; font-size: 14px; }
.user-meta h3 { font-size: 15px; }
.status.online { color: #52adff; font-size: 12px; }

.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-image: url('../assets/pattern.png'); /* We can add a pattern later */
    background-attachment: fixed;
}

.bubble {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 15px;
    position: relative;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.msg-in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 4px; }
.msg-out { align-self: flex-end; background: var(--bubble-out); border-bottom-right-radius: 4px; }

.msg-time {
    font-size: 11px;
    opacity: 0.5;
    margin-top: 4px;
    text-align: right;
    display: block;
}

/* Input Area */
.input-area {
    padding: 8px 16px;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    gap: 12px;
}

.input-wrapper {
    flex: 1;
    background: #242425;
    border-radius: 20px;
    display: flex;
    align-items: center;
    padding: 0 12px;
}

.input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    color: white;
    padding: 10px;
    outline: none;
    font-size: 15px;
}

.attach-btn, .emoji-btn { background: none; border: none; cursor: pointer; font-size: 18px; opacity: 0.6; }

.send-btn-circle {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--accent-color);
    color: white; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* Overlays */
.hidden { display: none !important; }

.login-overlay {
    position: fixed; inset: 0; background: var(--bg-color);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.login-card {
    background: var(--sidebar-bg); padding: 32px; border-radius: 16px;
    width: 100%; max-width: 360px; text-align: center;
}
.login-card h2 { margin-bottom: 8px; }
.login-card p { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }
.login-card input {
    width: 100%; padding: 12px; margin-bottom: 12px;
    background: #242425; border: 1px solid var(--border-color);
    border-radius: 8px; color: white; outline: none;
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar { position: absolute; left: 0; top: 0; bottom: 0; width: 100% !important; }
    .sidebar.mobile-hidden { transform: translateX(-100%); }
    .back-btn { display: block; }
}
