:root {
    --wa-bg-color: #111b21;
    --wa-sidebar-bg: #111b21;
    --wa-chat-bg: #0b141a;
    --wa-header-bg: #202c33;
    --wa-panel-header: #202c33;
    --wa-search-bg: #202c33;
    --wa-input-bg: #2a3942;
    --wa-primary: #00a884;
    --wa-primary-hover: #06cf9c;
    --wa-text-primary: #e9edef;
    --wa-text-secondary: #8696a0;
    --wa-text-muted: #667781;
    --wa-border: #222d34;
    --wa-incoming-bg: #202c33;
    --wa-outgoing-bg: #005c4b;
    --wa-unread-badge: #00a884;
    --wa-active-item: #2a3942;
    --wa-hover-item: #202c33;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--wa-bg-color);
    color: var(--wa-text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 400px;
    min-width: 300px;
    background-color: var(--wa-sidebar-bg);
    border-right: 1px solid var(--wa-border);
    display: flex;
    flex-direction: column;
}

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

.user-avatar, .contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #54656f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.header-actions {
    display: flex;
    gap: 15px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--wa-text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.search-container {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.search-wrapper i {
    color: var(--wa-text-secondary);
    width: 16px;
    height: 16px;
}

.search-wrapper input {
    background: none;
    border: none;
    color: var(--wa-text-primary);
    padding: 0 10px;
    width: 100%;
    font-size: 14px;
}

.search-wrapper input:focus {
    outline: none;
}

.filter-btn {
    background: none;
    border: none;
    color: var(--wa-text-secondary);
    cursor: pointer;
}

/* Conversation List */
.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    padding: 12px 16px;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--wa-border);
    transition: background 0.2s;
}

.conversation-item:hover {
    background-color: var(--wa-hover-item);
}

.conversation-item.active {
    background-color: var(--wa-active-item);
}

.conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--wa-header-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.conv-content {
    flex: 1;
    min-width: 0;
}

.conv-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.conv-name {
    font-weight: 500;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.conv-preview {
    font-size: 14px;
    color: var(--wa-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat Area */
.chat-area {
    flex: 1;
    background-color: var(--wa-chat-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-blend-mode: overlay;
    background-opacity: 0.05;
}

.welcome-screen {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-color: var(--wa-chat-bg);
}

.welcome-content h1 {
    margin: 20px 0 10px;
    font-weight: 300;
    color: var(--wa-text-primary);
}

.welcome-content p {
    color: var(--wa-text-secondary);
    max-width: 450px;
    line-height: 1.5;
}

.welcome-image {
    color: var(--wa-text-muted);
    opacity: 0.5;
}

.encryption-note {
    margin-top: 50px;
    color: var(--wa-text-muted);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

/* Active Chat */
.active-chat {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-header {
    height: 60px;
    padding: 10px 16px;
    background-color: var(--wa-header-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.chat-contact-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.contact-details h2 {
    font-size: 16px;
    font-weight: 500;
}

.contact-status {
    font-size: 13px;
    color: var(--wa-text-secondary);
}

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

.message-row {
    display: flex;
    width: 100%;
    margin-bottom: 2px;
}

.message-row.outgoing {
    justify-content: flex-end;
}

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

.message-row.incoming .message-bubble {
    background-color: var(--wa-incoming-bg);
    border-top-left-radius: 0;
}

.message-row.outgoing .message-bubble {
    background-color: var(--wa-outgoing-bg);
    border-top-right-radius: 0;
}

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

.message-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--wa-text-secondary);
}

.chat-footer {
    min-height: 62px;
    padding: 5px 10px;
    background-color: var(--wa-header-bg);
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-wrapper {
    flex: 1;
    background-color: var(--wa-input-bg);
    border-radius: 8px;
    padding: 0 12px;
    height: 42px;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    background: none;
    border: none;
    color: var(--wa-text-primary);
    width: 100%;
    font-size: 15px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: var(--wa-header-bg);
    padding: 30px;
    border-radius: 12px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.modal h2 { margin-bottom: 10px; }
.modal p { color: var(--wa-text-secondary); margin-bottom: 20px; font-size: 14px; }

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: var(--wa-text-secondary);
}

.form-group input {
    width: 100%;
    background: var(--wa-input-bg);
    border: 1px solid var(--wa-border);
    padding: 10px;
    border-radius: 6px;
    color: white;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 25px;
}

.btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.btn-primary { background: var(--wa-primary); color: white; }
.btn-secondary { background: transparent; color: var(--wa-primary); }

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--wa-text-secondary);
    gap: 15px;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0,168,132,0.1);
    border-top: 3px solid var(--wa-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
