:root {
    --primary-color: #00a884;
    --primary-dark: #008f6f;
    --bg-main: #efeae2;
    --bg-panel: #f0f2f5;
    --bg-chat: #efeae2;
    --text-main: #111b21;
    --text-muted: #667781;
    --border-color: #d1d7db;
    --message-out: #d9fdd3;
    --message-in: #ffffff;
    --app-bg: #d1d7db;
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif; }

body {
    background-color: var(--app-bg);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    width: 100%;
    height: 127px;
    background-color: var(--primary-color);
    z-index: -1;
}

/* Modern Glass Login Page */
.login-bg { 
    background: linear-gradient(-45deg, #00a884, #005d4b, #25d366, #128c7e);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}
.login-bg::before { display: none; }

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.login-container { width: 100%; max-width: 420px; margin: 0 auto; padding: 20px; }

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    text-align: center;
    color: white;
}

.glass h1 { margin-bottom: 10px; font-weight: 500; }
.glass .subtitle { color: #f0f0f0; margin-bottom: 30px; font-size: 15px; }

.input-group { position: relative; margin-bottom: 20px; display: flex; align-items: center; }
.input-group .icon { position: absolute; left: 15px; color: #54656f; z-index: 10; }
.input-group input {
    width: 100%;
    padding: 14px 15px 14px 45px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    background: rgba(255, 255, 255, 0.9);
    transition: transform 0.2s, background 0.2s;
}
.input-group input:focus { transform: scale(1.02); background: white; }

.btn-primary {
    width: 100%;
    padding: 14px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0, 168, 132, 0.4);
}
.btn-primary:hover { background-color: var(--primary-dark); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 168, 132, 0.6); }

.toggle-links { margin-top: 25px; display: flex; flex-direction: column; gap: 10px; }
.toggle-links a { color: #fff; text-decoration: none; font-weight: 600; letter-spacing: 0.5px; text-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.toggle-links a:hover { text-decoration: underline; }
.error-msg { margin-top: 15px; font-size: 14px; height: 20px; font-weight: 500; }

/* Main App */
.app-container {
    display: flex;
    width: 100%;
    max-width: 1600px;
    height: calc(100vh - 40px);
    background: #fff;
    box-shadow: 0 6px 18px rgba(11,20,26,.05);
    overflow: hidden;
    position: relative;
}

.sidebar { width: 30%; min-width: 320px; background: #fff; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; }
.sidebar-header, .chat-header { height: 60px; background-color: var(--bg-panel); display: flex; align-items: center; padding: 10px 16px; justify-content: space-between; }
.user-profile, .chat-header-info { display: flex; align-items: center; gap: 15px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; cursor: pointer; }
.username { font-weight: 500; color: var(--text-main); }
.sidebar-actions button, .chat-actions button { background: none; border: none; color: #54656f; font-size: 20px; cursor: pointer; padding: 8px; border-radius: 50%; }

.search-bar { background-color: #fff; padding: 8px 12px; border-bottom: 1px solid var(--border-color); }
.search-input-container { background-color: var(--bg-panel); border-radius: 8px; display: flex; align-items: center; padding: 0 15px; height: 35px; }
.search-input-container i { color: #54656f; font-size: 14px; }
.search-input-container input { border: none; background: transparent; width: 100%; padding: 8px 15px; outline: none; font-size: 15px; }

.contact-list { flex: 1; overflow-y: auto; }
.contact-item { display: flex; align-items: center; padding: 12px 15px; cursor: pointer; transition: background-color 0.2s; }
.contact-item:hover, .contact-item.active { background-color: var(--bg-panel); }
.contact-info { margin-left: 15px; flex: 1; border-bottom: 1px solid var(--bg-panel); padding-bottom: 12px; }
.contact-item:hover .contact-info { border-bottom-color: transparent; }
.contact-name { font-size: 17px; color: var(--text-main); }

.main-chat { flex: 1; display: flex; flex-direction: column; background-color: var(--bg-chat); position: relative; }
.welcome-screen { height: 100%; display: flex; align-items: center; justify-content: center; background-color: var(--bg-panel); border-bottom: 6px solid var(--primary-color); }
.welcome-content { text-align: center; color: var(--text-muted); }
.welcome-content h1 { font-weight: 300; margin-bottom: 15px; color: #41525d; }

.chat-body {
    flex: 1; overflow-y: auto; background-color: var(--bg-chat);
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-repeat: repeat; background-size: 400px; opacity: 0.9;
}

.messages-container { padding: 20px 5%; display: flex; flex-direction: column; gap: 5px; }
.message { max-width: 65%; padding: 8px 12px; border-radius: 8px; position: relative; font-size: 14.5px; line-height: 19px; box-shadow: 0 1px 0.5px rgba(11,20,26,.13); margin-bottom: 8px; word-wrap: break-word; }
.message-in { background-color: var(--message-in); align-self: flex-start; border-top-left-radius: 0; }
.message-out { background-color: var(--message-out); align-self: flex-end; border-top-right-radius: 0; }
.msg-time { font-size: 11px; color: var(--text-muted); float: right; margin: 10px 0 -5px 15px; }
.msg-tick { float: right; margin: 10px 0 -5px 5px; font-size: 11px; color: #8696a0; }
.msg-tick.tick-read { color: #53bdeb; }
.unread-badge { background: var(--primary-color); color: #fff; border-radius: 50%; padding: 2px 7px; font-size: 12px; margin-left: auto; font-weight: bold; }

/* Image and file messages */
.message-image { max-width: 250px; border-radius: 8px; display: block; margin-bottom: 5px; cursor: pointer; }
.message-file { display: flex; align-items: center; padding: 10px; background: rgba(0,0,0,0.05); border-radius: 8px; text-decoration: none; color: inherit; margin-bottom: 5px; }
.message-file i { font-size: 24px; margin-right: 10px; color: var(--primary-color); }

.chat-footer { background-color: var(--bg-panel); padding: 10px 16px; display: flex; align-items: center; position: relative; }
.message-form { display: flex; width: 100%; align-items: center; gap: 10px; }
.icon-btn { background: none; border: none; color: #54656f; font-size: 24px; cursor: pointer; padding: 5px; transition: color 0.2s; }
.icon-btn:hover { color: var(--text-main); }
#message-input { flex: 1; border: none; border-radius: 8px; padding: 12px 15px; font-size: 15px; outline: none; }
.send-btn { color: var(--text-muted); }
.send-btn:hover { color: var(--primary-color); }

/* Back button (Mobile only) */
.back-btn { display: none; margin-right: 10px; }

/* Emoji/Sticker Picker Container */
.emoji-picker-wrapper { 
    display: none; position: absolute; bottom: 65px; left: 15px; 
    background: #fff; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); 
    padding: 10px; z-index: 100; width: 330px;
}
.picker-tabs { display: flex; gap: 10px; margin-bottom: 5px; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }
.picker-tab { background: none; border: none; padding: 5px 10px; cursor: pointer; color: var(--text-muted); font-weight: 500; font-size: 14px; }
.picker-tab.active { color: var(--primary-color); border-bottom: 2px solid var(--primary-color); }

emoji-picker { width: 100%; height: 320px; --background: #fff; --indicator-color: var(--primary-color); }

#sticker-container { display: none; grid-template-columns: repeat(4, 1fr); gap: 15px; max-height: 320px; overflow-y: auto; padding: 10px; }
.sticker-item { width: 100%; height: auto; cursor: pointer; transition: transform 0.2s; }
.sticker-item:hover { transform: scale(1.15); }

/* File Input hidden */
#file-input { display: none; }
#profile-input { display: none; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-container { height: 100vh; max-width: 100%; top: 0; }
    body::before { display: none; }
    
    .sidebar { width: 100%; min-width: 100%; }
    .main-chat { display: none; width: 100%; position: absolute; top: 0; left: 0; height: 100%; z-index: 10; }
    
    /* When chat is active */
    .app-container.chat-active .sidebar { display: none; }
    
    .emoji-picker-wrapper { width: 90%; left: 5%; bottom: 60px; }
    .app-container.chat-active .main-chat { display: flex; }
    
    .back-btn { display: block; }
    .message { max-width: 85%; }
}
