/* ================================================================
   DANBEL WA — Complete WhatsApp Web Style
   ================================================================ */

/* ────────────────────────────────────────────────────────────────
   DESIGN TOKENS — Official WhatsApp Web Colors
──────────────────────────────────────────────────────────────── */
:root {
    --wa-green:         #00a884;
    --wa-green-dark:    #005c4b;
    --wa-green-light:   #25d366;
    --wa-accent:        #53bdeb;

    --bg-body:          #111b21;
    --bg-panel:         #111b21;
    --bg-header:        #202c33;
    --bg-chat:          #0b141a;
    --bg-input:         #2a3942;
    --bg-hover:         #2a3942;
    --bg-active:        rgba(0,168,132,.10);

    --bubble-sent:      #005c4b;
    --bubble-recv:      #202c33;

    --text-primary:     #e9edef;
    --text-secondary:   #8696a0;
    --text-accent:      #53bdeb;
    --text-danger:      #ef4444;

    --border:           #313d45;
    --border-light:     rgba(255,255,255,.06);
    --shadow:           0 2px 8px rgba(0,0,0,.35);
    --shadow-lg:        0 8px 30px rgba(0,0,0,.45);

    --sidebar-w:        82px;
    --radius-sm:        8px;
    --radius-md:        12px;
    --radius-lg:        18px;
    --radius-xl:        24px;
    --radius-full:      9999px;

    --transition:       all .2s ease;
}

/* Light Theme Override */
body.theme-light {
    --bg-body:          #f0f2f5;
    --bg-panel:         #ffffff;
    --bg-header:        #f0f2f5;
    --bg-chat:          #efeae2;
    --bg-input:         #ffffff;
    --bg-hover:         #f5f6f6;
    --bg-active:        rgba(0,168,132,.08);
    --bubble-sent:      #d9fdd3;
    --bubble-recv:      #ffffff;
    --text-primary:     #111b21;
    --text-secondary:   #667781;
    --border:           #e9edef;
    --border-light:     rgba(0,0,0,.06);
}

/* ────────────────────────────────────────────────────────────────
   RESET & BASE
──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    background: var(--bg-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ────────────────────────────────────────────────────────────────
   APP LAYOUT
──────────────────────────────────────────────────────────────── */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-body);
}

/* ────────────────────────────────────────────────────────────────
   LEFT SIDEBAR (Icon Bar — 82px)
──────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-header);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0 10px;
    z-index: 10;
    flex-shrink: 0;
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 18px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.sidebar-logo:hover { transform: scale(1.05); }
.sidebar-logo-img { width: 100%; height: 100%; object-fit: cover; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    width: 100%;
    padding: 0 8px;
}

.nav-item {
    width: 100%;
    padding: 10px 6px 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    transition: var(--transition);
    position: relative;
    border: none;
    background: transparent;
    font-family: inherit;
    text-decoration: none;
    user-select: none;
}
.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.nav-item.active {
    background: var(--bg-active);
    color: var(--wa-green);
}
.nav-item.active .nav-icon { color: var(--wa-green); }

.nav-icon {
    font-size: 1.2rem;
    line-height: 1;
}
.nav-label {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    line-height: 1;
    white-space: nowrap;
}
.nav-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--wa-green);
    color: white;
    font-size: .6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    pointer-events: none;
}

/* Tooltip on hover */
.nav-item[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #1a2631;
    color: white;
    font-size: .72rem;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s ease;
    z-index: 100;
    box-shadow: var(--shadow);
}
.nav-item[data-tooltip]:hover::after { opacity: 1; }

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    width: 100%;
}

.bridge-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-danger);
    transition: var(--transition);
    cursor: default;
}
.bridge-status-indicator.online {
    background: var(--wa-green);
    box-shadow: 0 0 8px var(--wa-green);
}

.theme-btn {
    font-size: 1.1rem;
    padding: 8px !important;
}

/* ────────────────────────────────────────────────────────────────
   MAIN CONTENT AREA
──────────────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
    overflow: hidden;
    min-width: 0;
}

/* ────────────────────────────────────────────────────────────────
   HEADER BAR
──────────────────────────────────────────────────────────────── */
.header {
    height: 60px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    flex-shrink: 0;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.header-left h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}
.bridge-status-text {
    font-size: .75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: rgba(239,68,68,.1);
    color: var(--text-danger);
    transition: var(--transition);
}
.bridge-status-text.online {
    background: rgba(0,168,132,.1);
    color: var(--wa-green);
}
.bridge-status-text i { font-size: .55rem; }

.header-add-btn {
    gap: 6px;
    white-space: nowrap;
}

/* ────────────────────────────────────────────────────────────────
   ACCOUNTS SECTION
──────────────────────────────────────────────────────────────── */
/* ────────────────────────────────────────────────────────────────
   ACCOUNTS SECTION
──────────────────────────────────────────────────────────────── */
.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 28px;
    overflow-y: auto;
    align-content: start;
    flex: 1;
}

/* Empty State */
.accounts-empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 30px;
    text-align: center;
    color: var(--text-secondary);
    animation: fadeInUp .4s ease;
}
.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: .55;
    filter: drop-shadow(0 4px 12px rgba(0,168,132,.25));
}
.accounts-empty-state h3 { font-size: 1.15rem; font-weight: 700; color: var(--text-primary); margin-bottom: 10px; }
.accounts-empty-state p  { font-size: .85rem; margin-bottom: 24px; line-height: 1.7; max-width: 320px; }

/* ══ ACCOUNT CARD ══════════════════════════════════════════════ */
.account-card {
    background: linear-gradient(165deg, #1c2b35 0%, #18252e 60%, #152028 100%);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 20px;
    position: relative;
    transition: transform .25s cubic-bezier(.25,.46,.45,.94),
                box-shadow .25s ease,
                border-color .25s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: default;
    animation: cardAppear .3s ease both;
}
@keyframes cardAppear {
    from { opacity: 0; transform: translateY(12px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

.account-card:hover {
    transform: translateY(-5px) scale(1.01);
    border-color: rgba(0,168,132,.4);
    box-shadow: 0 18px 48px rgba(0,0,0,.45),
                0 0 0 1px rgba(0,168,132,.15),
                0 0 30px rgba(0,168,132,.08);
}

/* Online card glow */
.account-card.is-online {
    border-color: rgba(0,168,132,.25);
    box-shadow: 0 4px 20px rgba(0,0,0,.3),
                0 0 24px rgba(0,168,132,.06);
}
.account-card.is-online:hover {
    box-shadow: 0 18px 48px rgba(0,0,0,.45),
                0 0 0 1px rgba(0,168,132,.3),
                0 0 40px rgba(0,168,132,.15);
}

/* ── TOP STATUS BAR ── */
.card-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px 10px;
    background: rgba(0,0,0,.2);
    border-bottom: 1px solid rgba(255,255,255,.05);
    flex-shrink: 0;
}

.card-status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 6px;
    border-radius: 20px;
    background: rgba(239,68,68,.12);
    border: 1px solid rgba(239,68,68,.2);
    transition: all .3s ease;
}
.card-status-pill.online {
    background: rgba(0,168,132,.12);
    border-color: rgba(0,168,132,.25);
}

.account-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all .3s ease;
}
.status-online {
    background: var(--wa-green);
    box-shadow: 0 0 6px var(--wa-green);
    animation: statusPulse 2s infinite;
}
.status-offline {
    background: var(--text-danger);
    box-shadow: 0 0 4px rgba(239,68,68,.4);
}
@keyframes statusPulse {
    0%,100% { opacity:1; box-shadow: 0 0 6px var(--wa-green); }
    50%      { opacity:.7; box-shadow: 0 0 12px var(--wa-green); }
}

.card-status-label {
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-danger);
    text-transform: uppercase;
    letter-spacing: .4px;
    transition: color .3s;
}
.card-status-pill.online .card-status-label { color: var(--wa-green); }

.notification-badge {
    background: var(--text-danger);
    color: white;
    font-size: .65rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
    box-shadow: 0 0 10px rgba(239,68,68,.5);
    animation: badgePop .35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes badgePop {
    from { transform: scale(0) rotate(-15deg); }
    to   { transform: scale(1) rotate(0deg); }
}

/* ── DISPLAY AREA (QR / Avatar) ── */
.card-display-area {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px 16px;
    min-height: 200px;
    position: relative;
}

/* QR View */
.card-qr-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: fadeInUp .3s ease;
}

.qr-frame {
    position: relative;
    padding: 10px;
    background: white;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,.4),
                0 0 0 1px rgba(255,255,255,.05);
}

/* Animated corner brackets */
.qr-frame-corner {
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--wa-green);
    border-style: solid;
    animation: cornerPulse 2s ease-in-out infinite;
}
.qr-frame-corner.tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.qr-frame-corner.tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.qr-frame-corner.bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.qr-frame-corner.br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }
@keyframes cornerPulse {
    0%,100% { opacity:.6; }
    50%      { opacity:1; }
}

.qr-container {
    width: 148px;
    height: 148px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 6px;
}
.qr-initializing {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #aaa;
    font-size: .76rem;
    text-align: center;
    padding: 10px;
}
.qr-initializing i { font-size: 1.6rem; color: #ccc; }
.qr-initializing p { margin: 0; line-height: 1.4; }

.qr-scan-hint {
    font-size: .72rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    margin: 0;
}
.qr-scan-hint i { color: var(--wa-green); }

/* Avatar View */
.card-avatar-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    animation: fadeInUp .35s ease;
}

.avatar-container {
    position: relative;
    width: 120px;
    height: 120px;
}
.avatar-img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--wa-green);
    box-shadow: 0 0 0 4px rgba(0,168,132,.15),
                0 8px 24px rgba(0,0,0,.4);
    display: block;
}
.avatar-online-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(0,168,132,.4);
    animation: ringPulse 2.5s ease-in-out infinite;
    pointer-events: none;
}
@keyframes ringPulse {
    0%,100% { transform: scale(1);    opacity: .5; }
    50%      { transform: scale(1.07); opacity: .15; }
}
.avatar-check-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--wa-green);
    border: 2px solid var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .6rem;
    color: white;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
}

.card-phone-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: var(--radius-full);
    background: rgba(0,168,132,.12);
    border: 1px solid rgba(0,168,132,.2);
    font-size: .75rem;
    font-weight: 600;
    color: var(--wa-green);
}
.card-phone-badge i { font-size: .9rem; }

/* ── CARD BOTTOM: INFO + ACTIONS ── */
.card-bottom {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-top: 1px solid rgba(255,255,255,.05);
    background: rgba(0,0,0,.15);
}

.card-name-area {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}
.account-name {
    font-size: .98rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.rename-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: .75rem;
    transition: all .2s;
    flex-shrink: 0;
}
.rename-btn:hover {
    background: rgba(0,168,132,.15);
    color: var(--wa-green);
    transform: rotate(15deg);
}

.account-id {
    font-size: .67rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: .6;
    margin-bottom: 12px;
    padding: 3px 6px;
    background: rgba(0,0,0,.2);
    border-radius: 4px;
    border-left: 2px solid var(--border);
}

.card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
}

/* Main chat button */
.card-btn-chat {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 14px;
    background: var(--wa-green);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: .83rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s cubic-bezier(.25,.46,.45,.94);
    font-family: inherit;
    letter-spacing: .2px;
}
.card-btn-chat:hover {
    background: #009974;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0,168,132,.4);
}
.card-btn-chat:active { transform: translateY(0); }
.card-btn-chat i { font-size: .85rem; }

/* Icon buttons group */
.card-icon-btns {
    display: flex;
    gap: 6px;
}
.card-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.04);
    color: var(--text-secondary);
    font-size: .85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    flex-shrink: 0;
}
.card-settings-btn:hover {
    background: rgba(83,189,235,.12);
    border-color: rgba(83,189,235,.3);
    color: var(--wa-accent);
    transform: rotate(90deg);
}
.card-delete-btn:hover {
    background: rgba(239,68,68,.12);
    border-color: rgba(239,68,68,.3);
    color: var(--text-danger);
    transform: scale(1.05);
}

/* ────────────────────────────────────────────────────────────────
   BUTTONS
──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: .85rem;
    font-family: inherit;
    transition: var(--transition);
    white-space: nowrap;
    gap: 6px;
    text-decoration: none;
    line-height: 1;
}
.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 7px; }
.btn-full { width: 100%; justify-content: center; }

.btn-primary {
    background: var(--wa-green);
    color: white;
}
.btn-primary:hover { background: #009974; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
    background: rgba(239,68,68,.12);
    color: #fca5a5;
    border: 1px solid rgba(239,68,68,.3);
}
.btn-danger:hover { background: var(--text-danger); color: white; border-color: var(--text-danger); }

.btn-settings {
    background: rgba(255,255,255,.05);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-settings:hover { background: var(--wa-green); color: white; border-color: var(--wa-green); }

/* ────────────────────────────────────────────────────────────────
   CHATS CONTAINER (Dual Pane)
──────────────────────────────────────────────────────────────── */
.chats-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Chat Sidebar (left pane) */
.chats-sidebar {
    width: 340px;
    min-width: 280px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    flex-shrink: 0;
    overflow: hidden;
}

/* Active Account Header */
.chats-active-account-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(0,168,132,.04);
    flex-shrink: 0;
}
.active-account-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.active-account-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--wa-green-dark);
    border: 2px solid var(--wa-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    overflow: hidden;
    flex-shrink: 0;
}
.active-account-meta { flex: 1; min-width: 0; }
.active-account-label {
    font-size: .65rem;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.active-account-name {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.account-switcher-select {
    width: 100%;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: .8rem;
    outline: none;
    cursor: pointer;
    font-family: inherit;
}
.account-switcher-select option { background: var(--bg-header); }

/* Notification Banner */
.notification-banner {
    background: var(--wa-accent);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    transition: background .3s;
}
.notif-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.notif-content { flex: 1; min-width: 0; }
.notif-title {
    font-size: .78rem;
    font-weight: 700;
    color: #111b21;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notif-subtitle {
    font-size: .68rem;
    color: #202c33;
    font-weight: 500;
}
.notif-dismiss {
    background: transparent;
    border: none;
    color: #202c33;
    cursor: pointer;
    font-size: .85rem;
    padding: 4px;
    font-weight: bold;
    flex-shrink: 0;
}
.notif-dismiss:hover { opacity: .7; }

/* Search Bar */
.chats-sidebar-header {
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.search-bar-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border-radius: 20px;
    padding: 7px 14px;
}
.search-icon { color: var(--text-secondary); font-size: .85rem; }
.chats-sidebar-header input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: .88rem;
    outline: none;
    font-family: inherit;
}
.chats-sidebar-header input::placeholder { color: var(--text-secondary); }

.btn-new-chat {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--wa-green);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    transition: var(--transition);
    flex-shrink: 0;
}
.btn-new-chat:hover { background: #009974; transform: scale(1.05); }

/* Filter Tabs */
.chat-filter-tabs {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
}
.chat-filter-tabs::-webkit-scrollbar { display: none; }

.filter-tab {
    padding: 4px 14px;
    border-radius: var(--radius-full);
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: var(--transition);
    font-family: inherit;
}
.filter-tab.active, .filter-tab:hover {
    background: var(--wa-green);
    border-color: var(--wa-green);
    color: white;
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
}
.empty-chat-placeholder {
    text-align: center;
    color: var(--text-secondary);
    padding: 30px 20px;
    font-size: .85rem;
    line-height: 1.6;
}

.chat-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background .15s;
    position: relative;
}
.chat-list-item:hover { background: var(--bg-hover); }
.chat-list-item.active {
    background: var(--bg-active);
    border-left: 3px solid var(--wa-green);
    padding-left: 11px;
}

.chat-item-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--wa-green-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}
.chat-item-avatar-img {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--wa-green);
    flex-shrink: 0;
}
.chat-item-avatar-placeholder {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--wa-green-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.chat-item-info { flex: 1; min-width: 0; }
.chat-item-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 3px;
}
.chat-item-name {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-item-time {
    font-size: .68rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 6px;
}
.chat-item-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-item-lastmsg {
    font-size: .78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}
.chat-item-badge {
    background: var(--wa-green);
    color: white;
    font-size: .62rem;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* ────────────────────────────────────────────────────────────────
   CHAT WINDOW (right pane)
──────────────────────────────────────────────────────────────── */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-chat);
    background-image:
        radial-gradient(rgba(255,255,255,.02) 1px, transparent 0),
        radial-gradient(rgba(255,255,255,.02) 1px, transparent 0);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
}

body.theme-light .chat-window {
    background-image:
        radial-gradient(rgba(0,0,0,.015) 1px, transparent 0),
        radial-gradient(rgba(0,0,0,.015) 1px, transparent 0) !important;
}

/* Chat Header */
.chat-window-header {
    height: 60px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    flex-shrink: 0;
}
.chat-header-contact {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}
.chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--wa-green-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    font-weight: 700;
    color: white;
    overflow: hidden;
    flex-shrink: 0;
}
.chat-header-info h3 {
    font-size: .92rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1px;
}
.chat-header-status {
    font-size: .72rem;
    color: var(--text-secondary);
}
.chat-header-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.chat-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.chat-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Messages */
.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8% 16px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* Welcome placeholder */
.welcome-chat-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}
.welcome-chat-icon { font-size: 5rem; margin-bottom: 20px; opacity: .6; }
.welcome-chat-state h3 {
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.welcome-chat-state p {
    font-size: .85rem;
    line-height: 1.7;
    max-width: 380px;
}
.welcome-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: .78rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── DATE SEPARATOR ── */
.date-sep {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0 10px;
    user-select: none;
}
.date-sep span {
    background: var(--bg-header);
    color: var(--text-secondary);
    font-size: .72rem;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    letter-spacing: .2px;
    border: 1px solid var(--border-light);
}
body.theme-light .date-sep span {
    background: #e1f3fb;
    color: #54656f;
    border-color: rgba(0,0,0,.06);
}

/* ════ MESSAGES ════════════════════════════════════════════════ */
.message {
    max-width: 66%;
    padding: 6px 9px 22px;
    border-radius: 8px;
    font-size: .9rem;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 1px 1px rgba(0,0,0,.13);
    word-break: break-word;
    animation: msgIn .18s ease;
    margin-bottom: 2px;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0);   }
}

/* Consecutive messages from same person — reduce gap */
.message + .message.sent,
.message + .message.received { margin-top: 1px; }

.message.sent {
    background: var(--bubble-sent);
    color: var(--text-primary);
    align-self: flex-end;
    border-top-right-radius: 2px;
}
.message.sent::after {
    content: '';
    position: absolute;
    top: 0; right: -8px;
    border-left: 8px solid var(--bubble-sent);
    border-top: 6px solid var(--bubble-sent);
    border-right: 8px solid transparent;
    border-bottom: 6px solid transparent;
}

.message.received {
    background: var(--bubble-recv);
    color: var(--text-primary);
    align-self: flex-start;
    border-top-left-radius: 2px;
}
.message.received::before {
    content: '';
    position: absolute;
    top: 0; left: -8px;
    border-right: 8px solid var(--bubble-recv);
    border-top: 6px solid var(--bubble-recv);
    border-left: 8px solid transparent;
    border-bottom: 6px solid transparent;
}

/* Light theme bubble colors */
body.theme-light .message.sent     { color: #111b21; }
body.theme-light .message.received { color: #111b21; }

/* ── Group sender name ── */
.msg-sender-name {
    font-size: .75rem;
    font-weight: 700;
    margin-bottom: 3px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    letter-spacing: .1px;
}

/* ── Message body ── */
.message-body {
    word-break: break-word;
    margin-right: 52px;
    min-height: 1em;
    white-space: pre-wrap;
}

/* ── Timestamp + ticks ── */
.message-meta {
    position: absolute;
    bottom: 4px;
    right: 7px;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: .65rem;
    color: rgba(255,255,255,.6);
    user-select: none;
    white-space: nowrap;
}
body.theme-light .message.received .message-meta { color: rgba(0,0,0,.45); }
body.theme-light .message.sent     .message-meta { color: rgba(0,0,0,.45); }

.msg-time { font-size: .65rem; }
.tick-sent { color: var(--wa-accent); font-size: .7rem; }
.tick-read { color: var(--wa-accent); font-size: .7rem; }

/* ── Reply quote inside bubble ── */
.msg-reply-quote {
    background: rgba(0,0,0,.18);
    border-left: 3px solid var(--wa-green);
    border-radius: 5px;
    padding: 5px 9px;
    margin-bottom: 6px;
    font-size: .8rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 100%;
}
body.theme-light .msg-reply-quote { background: rgba(0,0,0,.06); }
.msg-reply-label {
    font-size: .7rem;
    font-weight: 700;
    color: var(--wa-green);
}
.msg-reply-body {
    color: var(--text-secondary);
    font-size: .8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* ── Media: Image ── */
.msg-img-wrap {
    max-width: 100%;
    border-radius: 7px;
    overflow: hidden;
    margin-bottom: 4px;
    cursor: pointer;
    position: relative;
}
.msg-img-wrap:hover::after {
    content: '🔍';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}
.msg-img {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    display: block;
    border-radius: 7px;
}

/* ── Media: Audio ── */
.msg-audio-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,.12);
    border-radius: 24px;
    padding: 8px 14px;
    margin-bottom: 4px;
    min-width: 220px;
    max-width: 320px;
}
.msg-audio-icon { font-size: 1.4rem; flex-shrink: 0; }

/* ── Media: File ── */
.msg-file-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0,0,0,.15);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 4px;
    min-width: 200px;
    max-width: 300px;
}
.msg-file-icon { font-size: 2rem; flex-shrink: 0; }
.msg-file-info { flex: 1; min-width: 0; }
.msg-file-name {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}
.msg-file-dl {
    font-size: .75rem;
    color: var(--wa-green);
    text-decoration: none;
    font-weight: 700;
}
.msg-file-dl:hover { text-decoration: underline; }

/* ── Reply button (hover) ── */
.msg-reply-btn {
    display: none;
    position: absolute;
    top: 5px;
    background: var(--bg-header);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: .72rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 5;
    padding: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.message.received .msg-reply-btn { right: -30px; }
.message.sent     .msg-reply-btn { left:  -30px; }
.message:hover .msg-reply-btn    { display: flex; }
.msg-reply-btn:hover { background: var(--wa-green); color: white; border-color: var(--wa-green); }

/* ────────────────────────────────────────────────────────────────
   CHAT INPUT AREA
──────────────────────────────────────────────────────────────── */
.chat-input-container {
    border-top: 1px solid var(--border);
    background: var(--bg-header);
    flex-shrink: 0;
}

.chat-quick-replies {
    display: flex;
    gap: 6px;
    padding: 8px 12px 4px;
    overflow-x: auto;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}
.chat-quick-replies::-webkit-scrollbar { display: none; }
.quick-reply-pill {
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: .75rem;
    font-weight: 500;
    background: rgba(0,168,132,.1);
    border: 1px solid rgba(0,168,132,.25);
    color: var(--wa-green);
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    flex-shrink: 0;
}
.quick-reply-pill:hover { background: var(--wa-green); color: white; border-color: var(--wa-green); }

/* Emoji Picker */
.emoji-picker-panel {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 340px;
    max-width: 90vw;
    background: #1e2d35;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    z-index: 200;
    box-shadow: 0 -8px 30px rgba(0,0,0,.4);
    flex-direction: column;
    gap: 8px;
}
.emoji-search-input {
    width: 100%;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,.25);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: .82rem;
    outline: none;
    font-family: inherit;
}
.emoji-cats {
    display: flex;
    gap: 6px;
    justify-content: space-around;
    padding: 4px 0;
}
.emoji-cat-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    padding: 4px;
    border-radius: 6px;
}
.emoji-cat-btn:hover { background: rgba(255,255,255,.1); transform: scale(1.2); }
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    max-height: 180px;
    overflow-y: auto;
}
.emoji-item {
    font-size: 1.2rem;
    text-align: center;
    padding: 4px;
    border-radius: 5px;
    cursor: pointer;
    transition: background .1s, transform .1s;
    line-height: 1.4;
}
.emoji-item:hover { background: rgba(255,255,255,.12); transform: scale(1.25); }

/* Reply Preview */
.reply-preview-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,.15);
    border-bottom: 1px solid var(--border);
    padding: 8px 14px;
    position: relative;
}
.reply-bar-indicator {
    width: 3px;
    height: 36px;
    background: var(--wa-green);
    border-radius: 2px;
    flex-shrink: 0;
}
.reply-bar-content { flex: 1; min-width: 0; }
.reply-preview-name {
    font-size: .72rem;
    font-weight: 700;
    color: var(--wa-green);
    margin-bottom: 2px;
}
.reply-preview-text {
    font-size: .78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reply-cancel-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    transition: color .2s;
    flex-shrink: 0;
}
.reply-cancel-btn:hover { color: var(--text-danger); }

/* Media Preview */
.media-preview-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
}
.media-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0,0,0,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.media-preview-meta { flex: 1; min-width: 0; }
.media-filename {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.media-filesize { font-size: .72rem; color: var(--text-secondary); }
.media-remove-btn {
    background: transparent;
    border: none;
    color: var(--text-danger);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    flex-shrink: 0;
}

/* Input Bar */
.input-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    position: relative;
}
.input-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}
.input-icon-btn:hover { color: var(--wa-green); }
.input-field-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border-radius: 22px;
    padding: 8px 16px;
    min-height: 42px;
}
.msg-input-field {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: .9rem;
    outline: none;
    font-family: inherit;
    min-width: 0;
}
.msg-input-field::placeholder { color: var(--text-secondary); }
.send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--wa-green);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    transition: var(--transition);
    flex-shrink: 0;
}
.send-btn:hover { background: #009974; transform: scale(1.06); }
.send-btn:active { transform: scale(.96); }

/* ────────────────────────────────────────────────────────────────
   SETTINGS SECTION
──────────────────────────────────────────────────────────────── */
.settings-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}
.settings-card {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
}
.settings-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.settings-divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}
.settings-row-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.settings-icon {
    font-size: 1rem;
    color: var(--wa-green);
    width: 20px;
    text-align: center;
}
.settings-label {
    font-size: .9rem;
    color: var(--text-primary);
    font-weight: 500;
}
.settings-hint {
    font-size: .75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.settings-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}
.settings-subcard {
    background: rgba(255,255,255,.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
}
.subcard-title {
    font-size: .92rem;
    font-weight: 600;
    color: var(--wa-green);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 7px;
}
.subcard-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.subcard-desc {
    font-size: .78rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.5;
}
.settings-pic-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}
.settings-pic-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    background: rgba(0,0,0,.15);
    cursor: pointer;
}
.settings-pic-preview:hover { border-color: var(--wa-green); }

/* Chatbot form */
.chatbot-form { display: flex; flex-direction: column; gap: 10px; }
.chatbot-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rules-list-title {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin: 12px 0 8px;
}
.chatbot-rules-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}
.empty-rules {
    text-align: center;
    color: var(--text-secondary);
    font-size: .8rem;
    padding: 14px;
}

/* ────────────────────────────────────────────────────────────────
   FORM ELEMENTS
──────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label {
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.form-hint {
    font-size: .72rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}
.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 10px 13px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: .88rem;
    outline: none;
    transition: border-color .2s;
    font-family: inherit;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
    border-color: var(--wa-green);
    box-shadow: 0 0 0 2px rgba(0,168,132,.15);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { cursor: pointer; }
.form-select option { background: var(--bg-header); }
.form-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.form-divider::before, .form-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 42px;
    height: 22px;
    display: inline-block;
    flex-shrink: 0;
}
.toggle-switch input { display: none; }
.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 11px;
    cursor: pointer;
    transition: background .25s;
}
.toggle-switch input:checked + .toggle-track { background: var(--wa-green); }
.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform .25s;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle-switch input:checked + .toggle-track::after { transform: translateX(20px); }

/* ────────────────────────────────────────────────────────────────
   ACCOUNT SETTINGS MODAL
──────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    z-index: 50000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    animation: fadeIn .2s ease;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.modal-card {
    background: var(--bg-header);
    border-radius: var(--radius-xl);
    width: 500px;
    max-width: 95vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0,0,0,.55);
    animation: slideUp .25s ease;
    border: 1px solid var(--border);
}
@keyframes slideUp {
    from { opacity:0; transform: translateY(18px); }
    to   { opacity:1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.modal-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--wa-green-dark);
    border: 2px solid var(--wa-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    overflow: hidden;
    flex-shrink: 0;
}
.modal-header-info h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.modal-account-id-text {
    font-size: .72rem;
    color: var(--text-secondary);
    font-family: monospace;
}
.modal-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.modal-close-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-tabs {
    display: flex;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: rgba(0,0,0,.1);
}
.modal-tab {
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}
.modal-tab:hover { color: var(--text-primary); }
.modal-tab.active {
    color: var(--wa-green);
    border-bottom-color: var(--wa-green);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.modal-tab-content { display: flex; flex-direction: column; gap: 14px; }

/* Profile photo edit */
.profile-photo-edit-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.profile-photo-edit-wrap {
    position: relative;
    width: 100px;
    height: 100px;
    cursor: pointer;
    border-radius: 50%;
    overflow: hidden;
}
.profile-pic-big {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--wa-green-dark);
    border: 3px solid var(--wa-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,168,132,.25);
}
.profile-pic-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.5);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    opacity: 0;
    transition: opacity .2s;
    color: white;
    font-size: .75rem;
    font-weight: 600;
}
.profile-pic-overlay i { font-size: 1.3rem; }
.profile-photo-edit-wrap:hover .profile-pic-overlay { opacity: 1; }
.profile-photo-hint {
    font-size: .75rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ────────────────────────────────────────────────────────────────
   CALL OVERLAY
──────────────────────────────────────────────────────────────── */
.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 99998;
    /* display is controlled by JS inline style — do NOT set display here */
    align-items: stretch;
    justify-content: stretch;
}
.call-overlay-inner {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(160deg, #0a1628 0%, #0d2136 50%, #0a1a2e 100%);
}

.call-ambient-blob {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}
.call-blob-1 {
    top: -80px; left: -80px;
    width: 320px; height: 320px;
    background: radial-gradient(circle, rgba(0,168,132,.18) 0%, transparent 70%);
}
.call-blob-2 {
    bottom: -60px; right: -60px;
    width: 260px; height: 260px;
    background: radial-gradient(circle, rgba(37,211,102,.12) 0%, transparent 70%);
}

.remote-video-bg {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    opacity: .85;
    z-index: 1;
}

.call-info-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    flex: 1;
    justify-content: center;
    z-index: 2;
    padding: 40px 20px;
}

.call-avatar-wrap {
    position: relative;
    margin-bottom: 24px;
}
.call-ring-anim {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    border-radius: 50%;
    border: 2px solid rgba(0,168,132,.35);
    animation: wavePulse 2s infinite;
}
.call-ring-1 { width: 160px; height: 160px; animation-delay: 0s; }
.call-ring-2 { width: 190px; height: 190px; animation-delay: .5s; }

.call-avatar-glow {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(0,168,132,.5);
    animation: wavePulse 2s infinite;
}

.call-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wa-green-dark), #075e54);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
    font-weight: 800;
    color: white;
    border: 4px solid var(--wa-green);
    position: relative;
    z-index: 2;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0,168,132,.3);
}

.call-contact-name {
    margin: 0 0 8px;
    color: white;
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: -.3px;
}
.call-status-text {
    color: rgba(255,255,255,.65);
    font-size: .95rem;
    margin-bottom: 10px;
}
.call-timer {
    font-size: 1.4rem;
    color: white;
    font-family: 'Courier New', monospace;
    background: rgba(255,255,255,.07);
    padding: 5px 18px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,.1);
}

.call-waveform {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 32px;
    margin-top: 14px;
}
.wave-bar {
    width: 3px;
    background: rgba(0,168,132,.7);
    border-radius: 2px;
    animation: waveBar .8s ease-in-out infinite alternate;
    height: 12px;
}
.wave-bar:nth-child(1){height:8px}
.wave-bar:nth-child(2){height:18px}
.wave-bar:nth-child(3){height:28px}
.wave-bar:nth-child(4){height:16px}
.wave-bar:nth-child(5){height:24px}
.wave-bar:nth-child(6){height:12px}
.wave-bar:nth-child(7){height:20px}

@keyframes waveBar {
    from { transform: scaleY(.4); }
    to   { transform: scaleY(1.0); }
}

.local-pip {
    position: absolute;
    bottom: 110px;
    right: 16px;
    width: 100px;
    height: 140px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,.3);
    box-shadow: 0 4px 20px rgba(0,0,0,.4);
    z-index: 10;
    cursor: pointer;
}
.local-pip-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}
.pip-label {
    position: absolute;
    bottom: 4px;
    left: 0; right: 0;
    text-align: center;
    font-size: .6rem;
    color: rgba(255,255,255,.7);
}

.call-controls-bar {
    width: 100%;
    padding: 18px 0 36px;
    background: linear-gradient(transparent, rgba(0,0,0,.55));
    z-index: 5;
    display: flex;
    justify-content: center;
    gap: 16px;
}
.call-ctrl-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.call-ctrl-item span {
    font-size: .62rem;
    color: rgba(255,255,255,.6);
    font-weight: 600;
}

.call-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    font-size: 1.4rem;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,.3);
}
.call-btn:hover { transform: scale(1.07); }
.call-btn:active { transform: scale(.96); }

.btn-mute    { background: rgba(255,255,255,.15); }
.btn-mute.active { background: #f59e0b; }
.btn-speaker { background: rgba(255,255,255,.15); }
.btn-speaker.active { background: rgba(37,211,102,.3); animation: speakerPulse 1.5s infinite; }
.btn-flip    { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); }
.btn-video   { background: rgba(255,255,255,.15); }
.btn-video.active { background: #3b82f6; }
.btn-hangup  { background: #ef4444 !important; box-shadow: 0 4px 18px rgba(239,68,68,.4); }
.btn-hangup:hover { background: #dc2626 !important; }
.btn-accept  { background: var(--wa-green) !important; box-shadow: 0 4px 18px rgba(0,168,132,.4); }

@keyframes speakerPulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(37,211,102,.4); }
    50%      { box-shadow: 0 0 0 8px rgba(37,211,102,0); }
}

/* ────────────────────────────────────────────────────────────────
   INCOMING CALL
──────────────────────────────────────────────────────────────── */
.incoming-call-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9,13,22,.9);
    backdrop-filter: blur(28px);
    z-index: 99999;
    /* display controlled by JS */
    align-items: center;
    justify-content: center;
    animation: fadeIn .3s ease;
}
.incoming-call-card {
    background: linear-gradient(160deg, #1a2332 0%, #0d1f2d 100%);
    border: 1px solid rgba(0,168,132,.3);
    border-radius: var(--radius-xl);
    padding: 40px 30px;
    text-align: center;
    max-width: 380px;
    width: 92%;
    box-shadow: 0 24px 60px rgba(0,0,0,.6);
    animation: slideUp .35s ease;
}
.incoming-avatar-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
}
.incoming-ring-pulse {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid var(--wa-green);
    animation: wavePulse 2s infinite;
}
.incoming-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wa-green), #075e54);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 800;
    color: white;
    border: 3px solid var(--wa-green);
    overflow: hidden;
}
.incoming-name {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}
.incoming-number {
    color: var(--text-secondary);
    font-size: .75rem;
    font-family: monospace;
    margin-bottom: 10px;
}
.incoming-type {
    color: var(--wa-green);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 32px;
}
.incoming-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
}
.incoming-action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,.65);
    font-size: .75rem;
    font-weight: 600;
}

/* ────────────────────────────────────────────────────────────────
   TOAST NOTIFICATIONS
──────────────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
    pointer-events: none;
}
.toast {
    background: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: toastIn .3s ease;
    cursor: pointer;
    pointer-events: all;
    border-left: 3px solid var(--wa-green);
}
.toast.toast-error { border-left-color: var(--text-danger); }
.toast.toast-warning { border-left-color: #f59e0b; }

@keyframes toastIn {
    from { opacity:0; transform: translateX(20px); }
    to   { opacity:1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity:1; transform: translateX(0); }
    to   { opacity:0; transform: translateX(20px); }
}

.toast-icon { font-size: 1.3rem; flex-shrink: 0; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: .82rem; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-msg   { font-size: .75rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ────────────────────────────────────────────────────────────────
   PASSWORD GATE
──────────────────────────────────────────────────────────────── */
.gate-overlay {
    position: fixed;
    inset: 0;
    background: #0b141a;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}
.gate-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 44px 32px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0,0,0,.6);
    animation: slideUp .4s ease;
}
.gate-logo {
    height: 58px;
    object-fit: contain;
    margin-bottom: 20px;
}
.gate-title {
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.gate-desc {
    color: var(--text-secondary);
    font-size: .85rem;
    line-height: 1.6;
    margin-bottom: 22px;
}
.gate-input-wrap { margin-bottom: 14px; }
.gate-input {
    width: 100%;
    padding: 13px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: .95rem;
    text-align: center;
    outline: none;
    font-family: inherit;
    transition: border-color .2s;
    letter-spacing: .1em;
}
.gate-input:focus { border-color: var(--wa-green); box-shadow: 0 0 0 3px rgba(0,168,132,.15); }
.gate-error {
    color: var(--text-danger);
    font-size: .8rem;
    margin-bottom: 12px;
    animation: fadeIn .2s ease;
}
.gate-btn {
    width: 100%;
    padding: 13px;
    border-radius: var(--radius-md);
    background: var(--wa-green);
    border: none;
    color: white;
    font-weight: 700;
    font-size: .95rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(0,168,132,.3);
}
.gate-btn:hover { background: #009974; transform: translateY(-1px); }
.gate-hint {
    margin-top: 16px;
    font-size: .72rem;
    color: var(--text-secondary);
    opacity: .7;
}

/* ────────────────────────────────────────────────────────────────
   ANIMATIONS
──────────────────────────────────────────────────────────────── */
@keyframes wavePulse {
    0%   { transform: scale(.85) translate(-50%,-50%); opacity: .8; }
    100% { transform: scale(1.3)  translate(-50%,-50%); opacity: 0; }
}
/* Used for non-absolute elements */
@keyframes wavePulseSimple {
    0%   { transform: scale(.85); opacity: .8; }
    100% { transform: scale(1.3); opacity: 0; }
}
.call-ring-anim { animation: wavePulseSimple 2s infinite !important; }

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

/* ────────────────────────────────────────────────────────────────
   SCROLLBARS
──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ────────────────────────────────────────────────────────────────
   LIGHT THEME OVERRIDES
──────────────────────────────────────────────────────────────── */
body.theme-light .sidebar           { background: #ffffff; border-color: #e9edef; }
body.theme-light .chats-sidebar     { background: #ffffff; }
body.theme-light .chat-window-header{ background: #f0f2f5; }
body.theme-light .chat-input-container { background: #f0f2f5; }
body.theme-light .input-field-wrap  { background: #ffffff; }
body.theme-light .account-card {
    background: linear-gradient(165deg, #ffffff 0%, #f8fafb 60%, #f3f7f9 100%) !important;
    border-color: #e9edef !important;
}
body.theme-light .card-top-bar      { background: rgba(0,0,0,.04); border-color: rgba(0,0,0,.06); }
body.theme-light .card-bottom       { background: rgba(0,0,0,.02); border-color: rgba(0,0,0,.06); }
body.theme-light .account-name      { color: #111b21 !important; }
body.theme-light .account-id        { color: #667781 !important; background: rgba(0,0,0,.04); }
body.theme-light .card-icon-btn     { background: rgba(0,0,0,.03); border-color: #e9edef; color: #667781; }
body.theme-light .settings-card     { background: #ffffff; border-color: #e9edef; }
body.theme-light .settings-subcard  { background: rgba(0,0,0,.02); }
body.theme-light .modal-card        { background: #ffffff; }
body.theme-light .modal-tabs        { background: rgba(0,0,0,.03); }
body.theme-light .gate-overlay      { background: #f0f2f5; }
body.theme-light .gate-card         { background: #ffffff; }
