:root {
    --whatsapp-teal: #008069;
    --whatsapp-bg: #f0f2f5;
    --sidebar-bg: #ffffff;
    --chat-bg: #e5ddd5;
    --sent-bubble: #d9fdd3;
    --received-bubble: #ffffff;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --border-color: #d1d7db;
    --search-bg: #f0f2f5;
}

body.dark-mode {
    --whatsapp-bg: #0b141a;
    --sidebar-bg: #111b21;
    --chat-bg: #0b141a;
    --sent-bubble: #005c4b;
    --received-bubble: #202c33;
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --border-color: #222d34;
    --search-bg: #202c33;
}

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

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

.app-container {
    width: 100%;
    height: 100%;
    display: flex;
    background: var(--sidebar-bg);
    box-shadow: 0 6px 18px rgba(0,0,0,0.1);
}

/* Sidebar */
.sidebar {
    width: 30%;
    max-width: 450px;
    min-width: 300px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    height: 60px;
    padding: 10px 16px;
    background: var(--whatsapp-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.profile-section img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.search-container {
    padding: 7px 12px;
    background: var(--sidebar-bg);
}

.search-wrapper {
    background: var(--search-bg);
    border-radius: 8px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    height: 35px;
}

.search-icon {
    margin-right: 10px;
    color: var(--text-secondary);
}

#chat-search {
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    font-size: 14px;
    color: var(--text-primary);
}

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

.chat-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.chat-item:hover {
    background: var(--search-bg);
}

.chat-item.active {
    background: var(--search-bg);
}

.chat-avatar {
    width: 49px;
    height: 49px;
    border-radius: 50%;
    margin-right: 15px;
}

.chat-details {
    flex: 1;
}

.chat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.chat-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.chat-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-phone {
    font-size: 12px;
    color: var(--whatsapp-teal);
    font-weight: 500;
}

body.dark-mode .chat-phone {
    color: #8696a0; /* Standard WhatsApp secondary text color for Dark Mode */
}

.chat-last-msg {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

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

.no-chat-view {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
}

.no-chat-content h1 {
    font-weight: 300;
    margin: 15px 0;
    color: var(--text-primary);
}

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

.chat-header {
    height: 60px;
    padding: 10px 16px;
    background: var(--whatsapp-bg);
    display: flex;
    align-items: center;
    border-left: 1px solid var(--border-color);
}

.chat-info {
    display: flex;
    align-items: center;
}

.chat-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 15px;
}

.chat-meta h2 {
    font-size: 16px;
    color: var(--text-primary);
}

.chat-meta p {
    font-size: 13px;
    color: var(--text-secondary);
}

body.dark-mode .chat-meta p {
    color: #8696a0; /* Standard WhatsApp secondary text color */
}

.messages-container {
    flex: 1;
    padding: 20px 5%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.date-divider {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.date-divider span {
    background: #e1f3fb;
    color: #54656f;
    padding: 5px 12px;
    border-radius: 7px;
    font-size: 12.5px;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
    text-transform: uppercase;
}

body.dark-mode .date-divider span {
    background: #182229;
    color: #8696a0; /* Standard WhatsApp secondary text color */
}

.message {
    max-width: 65%;
    padding: 6px 10px;
    border-radius: 8px;
    margin-bottom: 12px;
    position: relative;
    font-size: 14.2px;
    line-height: 1.5;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
}

.message.sent {
    align-self: flex-end;
    background: var(--sent-bubble);
    color: var(--text-primary);
}

.message.received {
    align-self: flex-start;
    background: var(--received-bubble);
    color: var(--text-primary);
}

.message-text {
    white-space: pre-wrap;
}

.message-time {
    display: block;
    text-align: right;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.hidden {
    display: none !important;
}

.loading-spinner {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--whatsapp-bg);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card {
    background: var(--sidebar-bg);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    text-align: center;
    width: 100%;
    max-width: 400px;
}

.login-logo {
    font-size: 50px;
    margin-bottom: 20px;
}

.login-card h2 {
    color: var(--text-primary);
    margin-bottom: 10px;
}

.login-card p {
    color: var(--text-secondary);
    font-size: 14.5px;
    margin-bottom: 30px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.login-form input {
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--search-bg);
    color: var(--text-primary);
    outline: none;
    font-size: 15px;
}

.login-form button {
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: var(--whatsapp-teal);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
}

.login-form button:hover {
    filter: brightness(0.9);
}

.login-error {
    color: #ea5455;
    font-size: 13px;
    margin-top: 5px;
}
