:root {
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --bg: #f1f5f9;
    /* Paleta única do menu (horizontal e vertical usam as MESMAS cores) */
    --nav-bg: #0f172a;
    --nav-hover: #1e293b;
    --nav-border: #1e293b;
}

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

/* ── Navbar superior (topnav) ─────────────────────────────── */
.topnav {
    min-height: 52px; background: var(--nav-bg);
    position: fixed; top: 0; left: 0; right: 0; z-index: 1030; padding: 0 .5rem;
}
/* Bootstrap cria .dropdown-backdrop p/ nav fixa — esconde p/ não escurecer a página */
.dropdown-backdrop { display: none !important; }
.topnav-inner { min-height: 52px; gap: .5rem; }
.topnav-brand { padding: 0 .5rem 0 0; flex-shrink: 0; text-decoration: none; }
.topnav-brand:hover { opacity: .85; }
.topnav-logo { height: 36px; width: auto; object-fit: contain; }
.topnav-brand-default {
    display: inline-flex; align-items: center; gap: .5rem;
    color: #fff; font-weight: 700; font-size: 1.1rem;
}
.topnav-brand-default i { color: var(--brand); }

.topnav .navbar-collapse { flex-grow: 1; align-items: center; }
.topnav .nav-link {
    color: #94a3b8; padding: .35rem .6rem; border-radius: 6px; font-size: .85rem;
    white-space: nowrap; display: flex; align-items: center; gap: .4rem;
    transition: all .18s; line-height: 1.3;
}
.topnav .nav-link:hover, .topnav .nav-link.active, .topnav .nav-link.show {
    background: var(--nav-hover); color: #f1f5f9;
}
.topnav .nav-link.active { box-shadow: inset 2px 0 0 var(--brand); }
.topnav .nav-link i { font-size: .95rem; flex-shrink: 0; }
.topnav .dropdown-toggle::after { margin-left: .2rem; }

/* Dropdowns dos grupos (Cadastros / Administração) */
.topnav-dropdown-menu {
    background: var(--nav-bg); border: 1px solid var(--nav-hover); border-radius: 8px;
    min-width: 190px; margin-top: 4px !important; padding: 4px;
}
.topnav-dropdown-menu .dropdown-item {
    color: #94a3b8; font-size: .85rem; padding: .45rem .75rem; border-radius: 5px;
    display: flex; align-items: center; gap: .5rem;
}
.topnav-dropdown-menu .dropdown-item:hover,
.topnav-dropdown-menu .dropdown-item.active,
.topnav-dropdown-menu .dropdown-item:focus { background: var(--nav-hover); color: #f1f5f9; }
.topnav-dropdown-menu .dropdown-item i { width: 16px; text-align: center; flex-shrink: 0; }

/* Ações fixas à direita (sino/usuário/sair) — sempre visíveis */
.topnav-actions { flex-shrink: 0; }
.topnav-bell-btn { color: #94a3b8; }
.topnav-bell-btn:hover { color: #e2e8f0; }
.topnav-user-icon { color: #94a3b8; font-size: 1.35rem; flex-shrink: 0; }
.topnav-user-name { font-size: .78rem; color: #e2e8f0; white-space: nowrap; line-height: 1.2; }
.topnav-user-role { font-size: .67rem; color: #64748b; line-height: 1.2; }
.topnav-logout-btn {
    color: #94a3b8; padding: .35rem .5rem; border-radius: 6px; text-decoration: none;
    font-size: 1.1rem; display: flex; align-items: center; transition: color .15s, background .15s;
}
.topnav-logout-btn:hover { color: #ef4444; background: rgba(239,68,68,.08); }
.topnav-toggler { border: none; color: #94a3b8; background: none; font-size: 1.4rem;
    line-height: 1; padding: .2rem .4rem; }
.topnav-toggler:focus { box-shadow: none; }

.main-content { margin-top: 52px; padding: 1.5rem 2rem; min-height: calc(100vh - 52px); }

@media (max-width: 991.98px) {
    /* Links recolhidos abrem em painel abaixo da barra */
    .topnav .navbar-collapse {
        background: var(--nav-bg); padding: .5rem; border-top: 1px solid var(--nav-hover);
        margin: 0 -.5rem; max-height: 80vh; overflow-y: auto;
    }
    .topnav .navbar-nav .nav-link { padding: .55rem .75rem; }
    .topnav-dropdown-menu { background: var(--nav-bg); border-color: var(--nav-hover); }
    .main-content { padding: 1rem; }
}

/* ── Sidebar (layout vertical opcional) ───────────────────── */
.sidebar {
    width: 240px; height: 100vh; background: var(--nav-bg);
    position: fixed; top: 0; left: 0; z-index: 1030;
    display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-brand {
    padding: .85rem 1rem; border-bottom: 1px solid var(--nav-hover); text-decoration: none;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-brand:hover { opacity: .85; }
.sidebar-logo { max-width: 180px; max-height: 46px; height: auto; object-fit: contain; }
.sidebar-brand-default { color: #fff; font-weight: 700; font-size: 1.1rem;
    display: flex; align-items: center; gap: .5rem; }
.sidebar-brand-default i { color: var(--brand); }
.sidebar > ul.nav {
    flex: 1 1 0; overflow-y: auto; overflow-x: hidden; min-height: 0; flex-wrap: nowrap;
    scrollbar-width: thin; scrollbar-color: #334155 transparent;
}
.sidebar > ul.nav::-webkit-scrollbar { width: 4px; }
.sidebar > ul.nav::-webkit-scrollbar-track { background: transparent; }
.sidebar > ul.nav::-webkit-scrollbar-thumb { background-color: #334155; border-radius: 4px; }
.sidebar .nav-link {
    color: #94a3b8; padding: .6rem 1rem; border-radius: 6px; margin: 2px 8px;
    font-size: .88rem; transition: all .18s; display: flex; align-items: center; gap: .5rem;
}
.sidebar .nav-link:hover, .sidebar .nav-link.active { background: var(--nav-hover); color: #f1f5f9; }
.sidebar .nav-link.active { box-shadow: inset 3px 0 0 var(--brand); }
.sidebar .nav-link i { width: 18px; text-align: center; font-size: 1rem; }
.sidebar .collapse .nav-link {
    font-size: .84rem; padding: .45rem .75rem; margin: 1px 8px 1px 16px; gap: .4rem;
}
.sidebar .nav-link-collapse::after {
    content: ''; display: inline-block; width: .5rem; height: .5rem; margin-left: auto;
    border-right: 2px solid #94a3b8; border-bottom: 2px solid #94a3b8;
    transform: rotate(45deg); transition: transform .2s;
}
.sidebar .nav-link-collapse[aria-expanded="true"]::after { transform: rotate(-135deg); }
.sidebar-footer { flex-shrink: 0; border-top: 1px solid var(--nav-hover); padding: .75rem 1rem; }
.sidebar-footer-inner { display: flex; align-items: center; gap: .6rem; }
.sidebar-user-icon { color: #94a3b8; font-size: 1.5rem; flex-shrink: 0; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: .8rem; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .7rem; color: #64748b; }
.sidebar-bell-btn { color: #94a3b8; }
.sidebar-bell-btn:hover { color: #e2e8f0; }
.sidebar-logout-btn {
    color: #94a3b8; font-size: 1.1rem; padding: .35rem .5rem; border-radius: 6px;
    text-decoration: none; display: flex; align-items: center; transition: color .15s, background .15s;
}
.sidebar-logout-btn:hover { color: #ef4444; background: rgba(239,68,68,.08); }
.sidebar-mobile-toggle { position: fixed; top: .5rem; left: .5rem; z-index: 1040; }

/* main-content quando o layout é sidebar */
.main-content.layout-sidebar { margin-top: 0; margin-left: 240px; min-height: 100vh; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    .sidebar.show { transform: translateX(0); }
    .main-content.layout-sidebar { 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; position: relative; }

/* Foto de perfil do WhatsApp sobre o avatar (lista / cabeçalho) */
.chat-av-img {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; border-radius: 50%;
}

/* ── 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; position: relative;
}

/* 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; }

/* ── Switch grande (integrações / pagamento online) ── */
.switch-large .form-check-input {
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
}
