:root {
    --wa-teal: #008069;
    --wa-teal-dark: #005c4b;
    --wa-teal-light: #25d366;
    --wa-green-send: #00a884;
    --wa-bg-panel: #f0f2f5;
    --wa-bg-chat: #efeae2;
    --wa-bubble-in: #ffffff;
    --wa-bubble-out: #d9fdd3;
    --wa-bubble-system: #ffeecd;
    --wa-text-primary: #111b21;
    --wa-text-secondary: #667781;
    --wa-border: #e9edef;
    --wa-blue-tick: #53bdeb;
    --wa-gray-tick: #8696a0;
    --wa-badge: #25d366;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

svg, path {
    pointer-events: none;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: var(--font-family);
    background: #eae6df;
    overflow: hidden;
    color: var(--wa-text-primary);
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 127px;
    background-color: var(--wa-teal);
    z-index: 0;
}

.whatsapp-app {
    position: relative;
    z-index: 1;
    display: flex;
    max-width: 1600px;
    height: 100vh;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 6px 18px rgba(11, 20, 26, 0.08);
    overflow: hidden;
}

/* Sidebar */
.wa-sidebar {
    width: 400px;
    min-width: 320px;
    max-width: 450px;
    height: 100%;
    border-right: 1px solid var(--wa-border);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow: hidden;
}

.sidebar-top-bar {
    height: 60px;
    flex-shrink: 0;
    background: var(--wa-bg-panel);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--wa-border);
}

.user-avatar-wrap {
    cursor: pointer;
}

.wa-my-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-icons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.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.15s;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* App Download Banner in Sidebar */
.sidebar-app-banner {
    background: #f0f2f5;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--wa-border);
}
.sidebar-app-banner .banner-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-app-banner .banner-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--wa-text-primary);
}
.sidebar-app-banner .banner-sub {
    font-size: 0.7rem;
    color: var(--wa-text-secondary);
}
.sidebar-app-banner a.get-app-btn {
    background: #00a884;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 16px;
    text-decoration: none;
    white-space: nowrap;
}

/* Search Bar */
.sidebar-search {
    padding: 8px 12px;
    flex-shrink: 0;
    background: #fff;
    border-bottom: 1px solid var(--wa-border);
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--wa-bg-panel);
    padding: 6px 12px;
    border-radius: 8px;
}

.search-input-wrap input {
    border: none;
    background: none;
    outline: none;
    width: 100%;
    font-size: 0.9rem;
    color: var(--wa-text-primary);
}

/* Filter Tabs */
.chat-filter-tabs {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--wa-border);
}

.wa-filter-tab {
    background: var(--wa-bg-panel);
    border: none;
    color: var(--wa-text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.wa-filter-tab.active {
    background: #e7fce3;
    color: #008069;
    font-weight: 600;
}

/* Chats List */
.chats-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    transition: background 0.15s;
}

.chat-item:hover {
    background: #f5f6f6;
}

.chat-item.active {
    background: #f0f2f5;
}

.chat-item-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat-item-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.group-avatar-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #dfe5e7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.vip-icon {
    background: #fef3c7;
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 11px;
    height: 11px;
    background: #25d366;
    border: 2px solid #fff;
    border-radius: 50%;
}

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

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.chat-item-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--wa-text-primary);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.verified-badge-wa {
    background: #25d366;
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.chat-item-time {
    font-size: 0.75rem;
    color: var(--wa-text-secondary);
}

.chat-item-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-item-msg {
    font-size: 0.85rem;
    color: var(--wa-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-pill {
    background: var(--wa-badge);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 12px;
}

/* Chat Pane */
.wa-chat-pane {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--wa-bg-chat);
    position: relative;
    overflow: hidden;
}

/* Chat Header */
.chat-header {
    height: 60px;
    flex-shrink: 0;
    background: var(--wa-bg-panel);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--wa-border);
    z-index: 10;
}

.back-btn-mobile {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    margin-right: 8px;
    cursor: pointer;
    color: var(--wa-text-secondary);
}

.chat-header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.header-avatar-wrap {
    position: relative;
}

.header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.header-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--wa-text-primary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-status {
    font-size: 0.75rem;
    color: var(--wa-text-secondary);
}

.header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Chat Body */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 40px;
    display: flex;
    flex-direction: column;
    background-image: radial-gradient(#d1d7db 1px, transparent 1px);
    background-size: 20px 20px;
}

.encryption-notice {
    background: #ffeecd;
    color: #54656f;
    font-size: 0.75rem;
    padding: 6px 14px;
    border-radius: 8px;
    text-align: center;
    max-width: 480px;
    margin: 0 auto 16px;
    flex-shrink: 0;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

.messages-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Message Bubble */
.wa-message {
    max-width: 65%;
    padding: 7px 12px 6px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 1px rgba(11, 20, 26, 0.12);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.wa-message-in {
    align-self: flex-start;
    background: var(--wa-bubble-in);
    border-top-left-radius: 0;
}

.wa-message-out {
    align-self: flex-end;
    background: var(--wa-bubble-out);
    border-top-right-radius: 0;
}

.wa-msg-meta {
    font-size: 0.65rem;
    color: var(--wa-text-secondary);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
    float: right;
    margin-left: 8px;
}

.wa-blue-ticks {
    color: var(--wa-blue-tick);
    font-weight: 700;
    font-size: 0.8rem;
}

/* Voice Note Bubble */
.voice-note-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
}

.vn-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #00a884;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
}

.vn-waveform {
    flex: 1;
    height: 20px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.vn-bar {
    width: 3px;
    background: #8696a0;
    border-radius: 2px;
}

.vn-duration {
    font-size: 0.75rem;
    color: var(--wa-text-secondary);
}

/* Interactive Chips Inside Chat */
.wa-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.wa-chip-btn {
    background: #ffffff;
    border: 1px solid #00a884;
    color: #008069;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.wa-chip-btn:hover {
    background: #00a884;
    color: white;
}

/* Profile Card Inside WhatsApp Bubble */
.wa-profile-card {
    background: #ffffff;
    border: 1px solid var(--wa-border);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
}

.wa-profile-card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
}

.wa-profile-body {
    padding: 12px;
}

.wa-profile-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--wa-text-primary);
}

.wa-profile-meta {
    font-size: 0.8rem;
    color: #008069;
    font-weight: 600;
    margin-bottom: 6px;
}

.wa-profile-bio {
    font-size: 0.8rem;
    color: var(--wa-text-secondary);
    line-height: 1.4;
    margin-bottom: 10px;
}

.wa-connect-btn {
    background: #25d366;
    color: white;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    cursor: pointer;
}

/* Authentic WhatsApp Footer */
.chat-footer {
    height: 62px;
    flex-shrink: 0;
    background: var(--wa-bg-panel);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
}

.footer-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wa-text-secondary);
    border-radius: 50%;
    transition: background 0.15s;
}
.footer-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.footer-input-wrap {
    flex: 1;
    background: #ffffff;
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
}

.footer-input-wrap input {
    width: 100%;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--wa-text-primary);
    background: transparent;
}

/* Mic & Send Buttons Toggle */
.send-action-btn {
    cursor: pointer;
    min-width: 42px;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--wa-text-secondary);
}

.send-action-btn.has-text {
    color: var(--wa-green-send);
}

/* Responsive Mobile Layout */
@media (max-width: 768px) {
    body::before { display: none; }
    .whatsapp-app {
        height: 100vh;
        width: 100%;
    }
    .wa-sidebar {
        width: 100%;
        max-width: 100%;
        position: absolute;
        height: 100%;
        z-index: 20;
        transition: transform 0.3s ease;
    }
    .wa-sidebar.hide-mobile {
        transform: translateX(-100%);
    }
    .wa-chat-pane {
        width: 100%;
    }
    .back-btn-mobile {
        display: block;
    }
    .chat-body {
        padding: 12px 16px;
    }
    .wa-message {
        max-width: 88%;
    }
}
