/* =============================================
   WhatsApp CRM - Estilos Principais
   ============================================= */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #0a0e14;
    --sidebar-hover: rgba(255,255,255,0.06);
    --sidebar-active: rgba(37,211,102,0.15);
    --primary: #25d366;
    --primary-hover: #1ebe5a;
    --primary-subtle: rgba(37,211,102,0.12);
    --surface: #111827;
    --surface-2: #1a2236;
    --surface-3: #1f2937;
    --body-bg: #0d1117;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --border-color: rgba(255,255,255,0.08);
    --glass-bg: rgba(17,24,39,0.7);
    --glass-border: rgba(255,255,255,0.06);
    --purple: #a78bfa;
    --radius: 12px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--body-bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* =============================================
   Login Page
   ============================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d1117 0%, #111827 50%, #0d1117 100%);
    position: relative;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(37,211,102,0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(37,211,102,0.05) 0%, transparent 40%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

.login-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2.5rem;
    backdrop-filter: blur(20px);
    box-shadow: 0 25px 50px rgba(0,0,0,0.4);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #128c7e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.2rem;
    font-size: 2rem;
    color: #fff;
    box-shadow: 0 8px 30px rgba(37,211,102,0.25);
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.login-header p {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.9rem;
}

.login-form .form-control {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    color: var(--text);
    border-radius: 10px;
    height: 54px;
}

.login-form .form-control:focus {
    background: rgba(255,255,255,0.06);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,211,102,0.15);
    color: var(--text);
}

.login-form .form-floating label {
    color: var(--text-muted);
}

.btn-login {
    height: 50px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, #128c7e 100%);
    border: none;
    color: #fff;
    transition: var(--transition);
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(37,211,102,0.3);
    background: linear-gradient(135deg, var(--primary-hover) 0%, #0e7a6d 100%);
    color: #fff;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* =============================================
   App Layout
   ============================================= */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.2rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.sidebar-brand i {
    font-size: 1.6rem;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--text);
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--primary);
    border-left-color: var(--primary);
}

.sidebar-link.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.sidebar-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.5rem;
}

.user-avatar i {
    font-size: 1.8rem;
    color: var(--text-muted);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.user-role {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.logout-link {
    padding: 0.5rem 0.5rem;
    border-radius: 8px;
    margin-top: 0.25rem;
    border-left: none !important;
}

.logout-link:hover {
    background: rgba(239,68,68,0.1);
    color: #ef4444;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.top-navbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.page-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.connection-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.status-connected,
.status-connected .status-dot {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34,197,94,0.5);
}

.status-dot.status-connecting,
.status-connecting .status-dot {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245,158,11,0.5);
    animation: pulse 1.5s infinite;
}

.status-dot.status-disconnected,
.status-disconnected .status-dot {
    background: #6b7280;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.25rem;
}

.page-content {
    padding: 1.5rem;
}

/* =============================================
   Cards
   ============================================= */
.glass-card {
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius) !important;
    backdrop-filter: blur(12px);
    transition: var(--transition);
}

.glass-card:hover {
    border-color: rgba(255,255,255,0.1) !important;
}

.glass-card .card-header {
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.glass-card .card-footer {
    background: rgba(255,255,255,0.02);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
}

/* Stat Cards */
.stat-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    border-color: rgba(255,255,255,0.12);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-info h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

.stat-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0;
}

/* Instance Cards */
.instance-card {
    transition: var(--transition);
}

.instance-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}

.avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #128c7e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.3rem;
}

.instance-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.instance-status-dot.status-connected { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.instance-status-dot.status-connecting { background: #f59e0b; animation: pulse 1.5s infinite; }
.instance-status-dot.status-disconnected { background: #6b7280; }

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge.status-connected {
    background: rgba(34,197,94,0.12);
    color: #22c55e;
}

.status-badge.status-connecting {
    background: rgba(245,158,11,0.12);
    color: #f59e0b;
}

.status-badge.status-disconnected {
    background: rgba(107,114,128,0.12);
    color: #9ca3af;
}

.status-badge.status-banned {
    background: rgba(239,68,68,0.12);
    color: #ef4444;
}

/* =============================================
   Buttons
   ============================================= */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #1da855 100%) !important;
    border: none !important;
    font-weight: 600;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37,211,102,0.25);
}

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
}

.btn-ghost:hover {
    color: var(--text);
    background: rgba(255,255,255,0.06);
    border-radius: 6px;
}

/* =============================================
   Form Controls
   ============================================= */
.form-control, .form-select {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    color: var(--text);
    border-radius: 8px;
}

.form-control:focus, .form-select:focus {
    background: rgba(255,255,255,0.06);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,211,102,0.12);
    color: var(--text);
}

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
}

/* =============================================
   List Groups
   ============================================= */
.list-group-item {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text);
}

.list-group-item-action:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text);
}

/* =============================================
   Alerts
   ============================================= */
.alert {
    border-radius: 10px;
    border: none;
    font-size: 0.875rem;
}

/* =============================================
   Dropdown
   ============================================= */
.dropdown-menu {
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.dropdown-item {
    color: var(--text);
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
}

.dropdown-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text);
}

.dropdown-divider {
    border-color: var(--border-color);
}

/* =============================================
   Responsivo
   ============================================= */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 575.98px) {
    .page-content {
        padding: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-info h3 {
        font-size: 1.5rem;
    }

    .login-card {
        padding: 1.5rem;
    }
}

/* =============================================
   Scrollbar
   ============================================= */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* =============================================
   Purple color helper
   ============================================= */
.bg-purple-subtle {
    background-color: rgba(167,139,250,0.12) !important;
}

.text-purple {
    color: var(--purple) !important;
}

/* =============================================
   Animations
   ============================================= */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-card,
.glass-card,
.instance-card {
    animation: fadeIn 0.4s ease forwards;
}

.row .col-12:nth-child(2) .stat-card,
.row .col-12:nth-child(2) .instance-card { animation-delay: 0.05s; }
.row .col-12:nth-child(3) .stat-card,
.row .col-12:nth-child(3) .instance-card { animation-delay: 0.1s; }
.row .col-12:nth-child(4) .stat-card { animation-delay: 0.15s; }
.row .col-12:nth-child(5) .stat-card { animation-delay: 0.2s; }

/* =============================================
   Inbox / Chat
   ============================================= */
.inbox-container {
    height: calc(100vh - 60px);
    overflow: hidden;
}

.inbox-container .row {
    height: 100%;
}

/* Sidebar do inbox */
.inbox-sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    height: 100%;
    overflow: hidden;
}

.inbox-header {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.inbox-filters {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

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

.inbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.inbox-item:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text);
}

.inbox-item.active {
    background: var(--primary-subtle);
}

.inbox-item-avatar {
    flex-shrink: 0;
}

.avatar-placeholder-sm {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #128c7e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
}

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

.inbox-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.15rem;
}

.inbox-item-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-item-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.inbox-item-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.inbox-item-preview .text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.badge-unread {
    font-size: 0.45rem;
    min-width: 18px;
    height: 18px;
    width: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

/* Área principal do chat */
.inbox-main {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.inbox-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--body-bg);
}

/* Chat header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-info h6 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-actions {
    flex-shrink: 0;
}

/* Mensagens */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--body-bg);
    background-image:
        radial-gradient(circle at 15% 85%, rgba(37,211,102,0.03) 0%, transparent 50%),
        radial-gradient(circle at 85% 15%, rgba(37,211,102,0.02) 0%, transparent 40%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message-bubble {
    max-width: 70%;
    padding: 0.6rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    animation: fadeIn 0.2s ease;
}

.message-sent {
    align-self: flex-end;
    background: #005c4b;
    border-bottom-right-radius: 4px;
}

.message-received {
    align-self: flex-start;
    background: var(--surface-2);
    border-bottom-left-radius: 4px;
}

.message-sender {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.2rem;
}

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

.message-caption {
    font-size: 0.82rem;
    margin-top: 0.3rem;
    white-space: pre-wrap;
}

.message-media {
    margin-bottom: 0.3rem;
    border-radius: 8px;
    overflow: hidden;
}

.message-media img {
    max-width: 100%;
    max-height: 300px;
    display: block;
}

.sticker-img {
    max-width: 150px !important;
    max-height: 150px !important;
}

.message-document {
    padding: 0.5rem;
    background: rgba(255,255,255,0.06);
    border-radius: 8px;
}

.message-document a {
    color: var(--text);
    text-decoration: none;
}

.message-document a:hover {
    color: var(--primary);
}

.message-location {
    padding: 0.5rem;
    background: rgba(37,211,102,0.08);
    border-radius: 8px;
    font-size: 0.82rem;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.3rem;
    margin-top: 0.2rem;
}

.message-time {
    font-size: 0.66rem;
    color: rgba(255,255,255,0.5);
}

.message-status-icon {
    font-size: 0.75rem;
}

.message-status-icon .bi-check-all.text-info {
    color: #53bdeb !important;
}

/* Campo de input */
.chat-input {
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-input .input-group {
    gap: 0.5rem;
}

.chat-input .form-control {
    border-radius: 20px;
    padding: 0.6rem 1rem;
    height: 44px;
}

.chat-input .btn {
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Attach / Location panel */
.chat-attach-panel {
    background: var(--surface-2);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    max-height: 260px;
    overflow-y: auto;
}

.attach-type-btn {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
}

.attach-type-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--primary);
}

.cursor-pointer {
    cursor: pointer;
}

/* Chat input with ghost buttons */
.chat-input .input-group {
    align-items: flex-end;
}

.chat-input .btn-ghost {
    width: 40px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
}

.chat-input textarea.form-control {
    resize: none;
    border-radius: 20px;
    padding: 0.6rem 1rem;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.5;
}

/* Responsivo para inbox */
@media (max-width: 767.98px) {
    .inbox-container {
        height: calc(100vh - 56px);
    }

    .message-bubble {
        max-width: 85%;
    }
}

/* =============================================
   WhatsApp Web Theme — 3-column chat interface
   ============================================= */

/* Layout container — negates page-content padding to fill edge-to-edge */
.wa-layout {
    display: flex;
    margin: -1.5rem;
    height: calc(100vh - 57px);
    overflow: hidden;
    font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
}

/* ── Sidebar ──────────────────────────────── */
.wa-sidebar {
    width: 360px;
    min-width: 360px;
    background: #111b21;
    border-right: 1px solid rgba(134,150,160,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wa-sidebar-top {
    background: #202c33;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.wa-sidebar-top select {
    flex: 1;
    background: #2a3942;
    border: none;
    border-radius: 8px;
    color: #e9edef;
    padding: 6px 10px;
    font-size: 0.82rem;
    cursor: pointer;
    outline: none;
}

.wa-sidebar-top-btns {
    display: flex;
    gap: 2px;
}

.wa-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #aebac1;
    padding: 8px;
    border-radius: 50%;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}
.wa-icon-btn:hover { background: rgba(134,150,160,0.12); }

.wa-search-bar {
    padding: 8px 12px;
    background: #111b21;
    flex-shrink: 0;
}

.wa-search-wrap {
    position: relative;
}

.wa-search-wrap i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #8696a0;
    font-size: 0.88rem;
    pointer-events: none;
}

.wa-search-wrap input {
    width: 100%;
    background: #202c33;
    border: none;
    outline: none;
    border-radius: 8px;
    padding: 8px 12px 8px 34px;
    color: #e9edef;
    font-size: 0.85rem;
}
.wa-search-wrap input::placeholder { color: #8696a0; }

.wa-filters {
    display: flex;
    gap: 8px;
    padding: 0 12px 8px;
    flex-shrink: 0;
}

.wa-filter-btn {
    background: #202c33;
    border: none;
    cursor: pointer;
    color: #aebac1;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    transition: all 0.15s;
    white-space: nowrap;
}
.wa-filter-btn.active {
    background: #00a884;
    color: #111b21;
    font-weight: 600;
}
.wa-filter-btn:hover:not(.active) { background: #2a3942; }

/* Chat list */
.wa-chat-list {
    flex: 1;
    overflow-y: auto;
}
.wa-chat-list::-webkit-scrollbar { width: 5px; }
.wa-chat-list::-webkit-scrollbar-track { background: transparent; }
.wa-chat-list::-webkit-scrollbar-thumb { background: rgba(134,150,160,0.2); border-radius: 3px; }

.wa-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid rgba(134,150,160,0.06);
    transition: background 0.12s;
}
.wa-chat-item:hover { background: #202c33; color: inherit; }
.wa-chat-item.active { background: #2a3942; color: inherit; }

.wa-chat-avatar {
    flex-shrink: 0;
    width: 49px;
    height: 49px;
    border-radius: 50%;
    background: #3b4a54;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aebac1;
    font-size: 1.3rem;
    overflow: hidden;
}
.wa-chat-avatar img { width: 100%; height: 100%; object-fit: cover; }

.wa-chat-info { flex: 1; min-width: 0; }

.wa-chat-row1, .wa-chat-row2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wa-chat-name {
    font-size: 0.9rem;
    font-weight: 400;
    color: #e9edef;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.wa-chat-time {
    font-size: 0.71rem;
    color: #8696a0;
    flex-shrink: 0;
    margin-left: 6px;
}
.wa-chat-item.has-unread .wa-chat-time { color: #00a884; }

.wa-chat-preview {
    font-size: 0.82rem;
    color: #8696a0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    margin-top: 2px;
}

.wa-unread-badge {
    background: #00a884;
    color: #111b21;
    border-radius: 50%;
    min-width: 19px;
    height: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0 4px;
    flex-shrink: 0;
    margin-left: 6px;
}

/* ── Main chat area ───────────────────────── */
.wa-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0b141a;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.wa-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    color: #8696a0;
    background: #0b141a;
    padding: 2rem;
    text-align: center;
}

.wa-empty-icon {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: #182229;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4.5rem;
    color: #3b4a54;
}

/* ── Contact panel ────────────────────────── */
.wa-contact-panel {
    width: 350px;
    min-width: 350px;
    background: #111b21;
    border-left: 1px solid rgba(134,150,160,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wa-cp-header {
    background: #202c33;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    color: #e9edef;
    font-size: 0.95rem;
    font-weight: 500;
}

.wa-cp-body {
    flex: 1;
    overflow-y: auto;
}
.wa-cp-body::-webkit-scrollbar { width: 5px; }
.wa-cp-body::-webkit-scrollbar-thumb { background: rgba(134,150,160,0.2); border-radius: 3px; }

.wa-cp-avatar-section {
    background: #202c33;
    padding: 24px 16px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

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

.wa-cp-avatar-placeholder {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: #3b4a54;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aebac1;
    font-size: 2.5rem;
}

.wa-cp-name {
    font-size: 1rem;
    font-weight: 500;
    color: #e9edef;
    margin: 0;
    text-align: center;
}

.wa-cp-phone {
    font-size: 0.82rem;
    color: #8696a0;
    margin: 0;
}

.wa-cp-section {
    margin-top: 8px;
    background: #202c33;
}

.wa-cp-section-label {
    padding: 12px 20px 4px;
    font-size: 0.78rem;
    color: #00a884;
    font-weight: 500;
}

.wa-cp-section-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(134,150,160,0.06);
    font-size: 0.87rem;
    color: #e9edef;
}
.wa-cp-section-item:last-child { border-bottom: none; }

.wa-cp-notes {
    width: 100%;
    background: #2a3942;
    border: 1px solid rgba(134,150,160,0.15);
    border-radius: 8px;
    color: #e9edef;
    padding: 10px 12px;
    font-size: 0.85rem;
    resize: none;
    min-height: 80px;
    font-family: inherit;
    box-sizing: border-box;
}
.wa-cp-notes:focus { outline: none; border-color: #00a884; }

.wa-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.wa-tag {
    background: #2a3942;
    border: 1px solid rgba(134,150,160,0.2);
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 0.78rem;
    color: #e9edef;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Chat header (inside show.php) ───────── */
.wa-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #202c33;
    border-bottom: 1px solid rgba(134,150,160,0.08);
    flex-shrink: 0;
}

.wa-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.wa-chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #3b4a54;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aebac1;
    overflow: hidden;
    flex-shrink: 0;
}
.wa-chat-header-avatar img { width: 40px; height: 40px; object-fit: cover; }

.wa-chat-header-info { min-width: 0; }

.wa-chat-header-name {
    font-size: 0.92rem;
    font-weight: 500;
    color: #e9edef;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wa-chat-header-sub {
    font-size: 0.73rem;
    color: #8696a0;
}

.wa-chat-header-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

/* ── Messages ─────────────────────────────── */
.wa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 20px;
    background: #0b141a;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.wa-messages::-webkit-scrollbar { width: 6px; }
.wa-messages::-webkit-scrollbar-track { background: transparent; }
.wa-messages::-webkit-scrollbar-thumb { background: rgba(134,150,160,0.2); border-radius: 3px; }

/* Date separator */
.wa-date-sep {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0 6px;
    pointer-events: none;
}
.wa-date-sep span {
    background: #182229;
    color: #8696a0;
    font-size: 0.74rem;
    padding: 5px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}

/* Bubbles */
.wa-msg {
    max-width: 65%;
    padding: 6px 9px;
    border-radius: 7.5px;
    font-size: 0.875rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    word-break: break-word;
    animation: fadeIn 0.15s ease;
}

.wa-msg-received {
    align-self: flex-start;
    background: #202c33;
    border-top-left-radius: 0;
    color: #e9edef;
}
.wa-msg-received::before {
    content: '';
    position: absolute;
    top: 0; left: -8px;
    width: 0; height: 0;
    border-top: 8px solid #202c33;
    border-left: 8px solid transparent;
}

.wa-msg-sent {
    align-self: flex-end;
    background: #005c4b;
    border-top-right-radius: 0;
    color: #e9edef;
}
.wa-msg-sent::before {
    content: '';
    position: absolute;
    top: 0; right: -8px;
    width: 0; height: 0;
    border-top: 8px solid #005c4b;
    border-right: 8px solid transparent;
}

.wa-msg-sender {
    font-size: 0.77rem;
    font-weight: 600;
    color: #06cf9c;
    margin-bottom: 3px;
}

.wa-msg-text { white-space: pre-wrap; }

.wa-msg-caption {
    font-size: 0.83rem;
    margin-top: 3px;
    white-space: pre-wrap;
}

.wa-msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    margin-top: 2px;
    float: right;
    margin-left: 8px;
    margin-bottom: -2px;
}

.wa-msg-time {
    font-size: 0.68rem;
    color: rgba(134,150,160,0.85);
    white-space: nowrap;
}

.wa-msg-status { font-size: 0.82rem; }
.wa-msg-status.read { color: #53bdeb; }
.wa-msg-status.delivered,
.wa-msg-status.sent { color: rgba(134,150,160,0.85); }

/* Media */
.wa-msg-media {
    margin-bottom: 4px;
    border-radius: 6px;
    overflow: hidden;
    max-width: 300px;
}
.wa-msg-media img {
    width: 100%;
    max-height: 260px;
    object-fit: cover;
    display: block;
    cursor: pointer;
}
.wa-msg-media video {
    width: 100%;
    max-height: 260px;
    border-radius: 6px;
}

/* Document card */
.wa-doc-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(134,150,160,0.08);
    border-radius: 6px;
    min-width: 200px;
    text-decoration: none;
    color: #e9edef;
}
.wa-doc-card:hover { background: rgba(134,150,160,0.14); color: #e9edef; }
.wa-doc-icon { font-size: 1.8rem; color: #00a884; }

/* Location */
.wa-location-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(0,168,132,0.1);
    border-radius: 6px;
    text-decoration: none;
    color: #e9edef;
    font-size: 0.85rem;
}
.wa-location-card:hover { color: #e9edef; }

/* Custom audio player */
.wa-audio-player {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 220px;
    max-width: 300px;
    padding: 2px 0;
}

.wa-audio-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(134,150,160,0.15);
    border: none;
    cursor: pointer;
    color: #e9edef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: background 0.15s;
}
.wa-audio-btn:hover { background: rgba(134,150,160,0.25); }

.wa-audio-body { flex: 1; }

.wa-audio-track {
    height: 3px;
    background: rgba(134,150,160,0.3);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    margin-bottom: 4px;
}
.wa-audio-fill {
    height: 100%;
    background: #00a884;
    border-radius: 2px;
    width: 0%;
    pointer-events: none;
    transition: width 0.1s linear;
}
.wa-audio-time {
    font-size: 0.68rem;
    color: rgba(134,150,160,0.85);
}

/* ── Input bar ─────────────────────────────── */
.wa-input-area {
    padding: 8px 16px;
    background: #202c33;
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.wa-input-wrap {
    flex: 1;
    background: #2a3942;
    border-radius: 10px;
    display: flex;
    align-items: flex-end;
    min-height: 42px;
}

.wa-input-text {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #e9edef;
    font-size: 0.9rem;
    padding: 11px 12px;
    resize: none;
    max-height: 120px;
    min-height: 42px;
    line-height: 1.5;
    font-family: inherit;
    overflow-y: auto;
}
.wa-input-text::placeholder { color: #8696a0; }

.wa-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #00a884;
    border: none;
    cursor: pointer;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: background 0.15s;
}
.wa-send-btn:hover { background: #06cf9c; }
.wa-send-btn:disabled { background: #3b4a54; cursor: not-allowed; }

/* Lazy-load button inside bubble */
.wa-load-btn {
    background: rgba(134,150,160,0.15);
    border: 1px solid rgba(134,150,160,0.25);
    border-radius: 8px;
    color: #e9edef;
    padding: 8px 14px;
    font-size: 0.83rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}
.wa-load-btn:hover { background: rgba(134,150,160,0.25); }
.wa-load-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Attach / Location panels (inside chat) */
.wa-attach-panel {
    background: #1d2b34;
    border-top: 1px solid rgba(134,150,160,0.1);
    flex-shrink: 0;
    max-height: 260px;
    overflow-y: auto;
    padding: 12px 16px;
}

/* Status badge (instance) */
.wa-status-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: #8696a0;
}
.wa-status-badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #8696a0;
}
.wa-status-badge.connected .dot { background: #00a884; }
.wa-status-badge.connected { color: #00a884; }

/* Sticker */
.wa-msg-sticker { max-width: 120px; max-height: 120px; }

/* Responsive */
@media (max-width: 900px) {
    .wa-sidebar { width: 280px; min-width: 280px; }
    .wa-contact-panel { display: none !important; }
}
@media (max-width: 600px) {
    .wa-messages { padding: 8px 16px; }
    .wa-msg { max-width: 85%; }
}

