:root {
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --bg: #f1f5f9;
}

body { background: var(--bg); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 240px;
    background: #1e293b; color: #cbd5e1; padding: 1rem 0; overflow-y: auto; z-index: 1030;
}
.sidebar .brand {
    color: #fff; font-weight: 700; font-size: 1.15rem; padding: .5rem 1.25rem 1rem;
    display: flex; align-items: center; gap: .5rem;
}
.sidebar a {
    display: flex; align-items: center; gap: .65rem; color: #cbd5e1;
    padding: .6rem 1.25rem; text-decoration: none; font-size: .92rem; border-left: 3px solid transparent;
}
.sidebar a:hover { background: #334155; color: #fff; }
.sidebar a.active { background: #0f172a; color: #fff; border-left-color: var(--brand); }
.sidebar .nav-sep { color: #64748b; font-size: .7rem; text-transform: uppercase;
    letter-spacing: .05em; padding: 1rem 1.25rem .35rem; }

.main-content { margin-left: 240px; padding: 1.5rem 2rem; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 1rem; }
}

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.topbar h5 { margin: 0; font-weight: 600; }

.card { border: none; box-shadow: 0 1px 3px rgba(0,0,0,.08); border-radius: .65rem; }
.stat-card { padding: 1.1rem 1.25rem; }
.stat-card .num { font-size: 1.8rem; font-weight: 700; }
.stat-card .lbl { color: #64748b; font-size: .85rem; }
.stat-card .ico { font-size: 1.6rem; opacity: .85; }

.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

.flash-overlay { position: fixed; top: 1rem; right: 1rem; z-index: 2000; width: 320px; }
.alert-trial-banner, .alert-vencimento-banner {
    background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
    padding: .6rem 1rem; border-radius: .5rem; margin-bottom: 1rem; font-size: .9rem;
}
.alert-vencimento-banner { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; }

#calendar { background: #fff; padding: 1rem; border-radius: .65rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ══════════════════════════════════════════════════════════════
   WhatsApp · Chat · Integrações
   ══════════════════════════════════════════════════════════════ */

/* ── Integrações ── */
.integration-locked { filter: grayscale(1); opacity: 0.6; }

/* ── WhatsApp status icon ── */
.wa-status-icon { font-size: 3rem; }

/* ── QR code image ── */
.qr-img { max-width: 260px; border-radius: 8px; }
#qr-container { min-height: 100px; }

/* ── Chat list avatar ── */
.chat-av-list { width: 44px; height: 44px; font-size: 1.2rem; }

/* ── Chat edit button ── */
.chat-edit-btn { line-height: 1; }
.chat-edit-btn i { font-size: 0.75rem; }

/* ── Context menu ── */
.ctx-menu {
    display: none; position: fixed; z-index: 9999; background: #fff;
    border: 1px solid #dee2e6; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15); min-width: 160px; overflow: hidden;
}
.ctx-menu-item { padding: 9px 16px; cursor: pointer; font-size: .9rem; }
.ctx-menu-item:hover { background: #f8f9fa; }
.ctx-menu-item-danger { color: #dc3545; }
.ctx-menu-item-danger:hover { background: #fff5f5; }

/* ── Chat — bubble elements ── */
.bubble-wrap { max-width: 72%; width: fit-content; }
.bubble {
    display: inline-block; width: 100%; padding: 8px 12px; border-radius: 12px;
    word-break: break-word; white-space: pre-wrap; font-size: 0.9rem;
    line-height: 1.4; box-sizing: border-box;
}
.bubble-time { font-size: 0.68rem; color: #888; margin-top: 2px; }
.chat-footer { background: #f8f9fa; border-top: 1px solid #dee2e6; padding: 10px 12px; }

/* WhatsApp chat bubbles */
.bubble-user  { background: #f0f0f0; color: #222; border-bottom-left-radius: 3px; }
.bubble-bot   { background: #dcf8c6; color: #222; border-bottom-right-radius: 3px; }
.bubble-agent { background: #cce5ff; color: #003; border-bottom-right-radius: 3px; }
#btnMic.recording { background-color: #dc3545 !important; color: #fff !important; }

/* Chat avatar in header */
.chat-av-header {
    width: 40px; height: 40px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: #6c757d; color: #fff;
}

/* Chat avatar per message */
.chat-av-msg {
    width: 30px; height: 30px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: #e9ecef; color: #6c757d; align-self: flex-end;
}

/* Chat message container */
.page-chat #chat-messages {
    height: calc(100vh - 280px); overflow-y: auto; padding: 1rem;
    display: flex; flex-direction: column; gap: 6px;
}

/* ── Icon sizes ── */
.icon-sm  { font-size: 0.85rem; }
.icon-3xl { font-size: 3rem; }

/* ── Chat card ── */
.card-chat { border-radius: 12px; overflow: hidden; }

/* ── Search dropdown ── */
.search-dropdown { z-index: 9999; max-height: 200px; overflow-y: auto; top: 100%; }

/* ── Unread indicator dot ── */
.badge-dot { width: 12px; height: 12px; padding: 0; }

/* ── Deleted message display ── */
.msg-deleted { font-size: 0.85rem; }

/* ── Chat media elements ── */
.audio-player { max-width: 240px; height: 36px; display: block; }
.media-img    { max-width: 200px; max-height: 180px; border-radius: 8px; cursor: pointer; display: block; }
.media-video  { max-width: 240px; max-height: 180px; border-radius: 8px; display: block; }

/* ── Media preview modal ── */
.modal-media-img   { max-height: 80vh; box-shadow: 0 8px 32px rgba(0,0,0,.4); }
.modal-media-video { max-height: 75vh; }
