/* ============================================================
   MensGrupo - CSS Principal
   Tema claro/escuro via data-bs-theme + CSS Variables
   ============================================================ */

/* ─── Variáveis Tema Claro ───────────────────────────────── */
:root,
[data-bs-theme="light"] {
    --mg-sidebar-bg:        #1a1d21;
    --mg-sidebar-text:      rgba(255,255,255,.75);
    --mg-sidebar-active:    #25d366;
    --mg-sidebar-hover-bg:  rgba(255,255,255,.08);
    --mg-sidebar-width:     240px;
    --mg-brand-green:       #25d366;
    --mg-navbar-bg:         #ffffff;
    --mg-navbar-border:     #e9ecef;
    --mg-body-bg:           #f4f6f9;
    --mg-card-bg:           #ffffff;
    --mg-card-border:       #e9ecef;
    --mg-text-primary:      #212529;
    --mg-text-muted:        #6c757d;
    --mg-stat-shadow:       0 2px 12px rgba(0,0,0,.08);
    --mg-transition:        all .2s ease;
}

/* ─── Variáveis Tema Escuro ──────────────────────────────── */
[data-bs-theme="dark"] {
    --mg-sidebar-bg:        #111316;
    --mg-sidebar-text:      rgba(255,255,255,.7);
    --mg-navbar-bg:         #1e2025;
    --mg-navbar-border:     #2d3035;
    --mg-body-bg:           #16181c;
    --mg-card-bg:           #1e2025;
    --mg-card-border:       #2d3035;
    --mg-text-primary:      #e9ecef;
    --mg-text-muted:        #8d9197;
    --mg-stat-shadow:       0 2px 12px rgba(0,0,0,.3);
}

/* ─── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    background-color: var(--mg-body-bg);
    color: var(--mg-text-primary);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: .9rem;
    transition: background-color .3s, color .3s;
    min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.app-sidebar {
    width: var(--mg-sidebar-width);
    min-width: var(--mg-sidebar-width);
    background: var(--mg-sidebar-bg);
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width .25s ease, transform .25s ease;
    z-index: 1000;
    flex-shrink: 0;
}

.app-sidebar .nav-link {
    color: var(--mg-sidebar-text);
    border-radius: 8px;
    padding: .5rem .75rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .875rem;
    transition: var(--mg-transition);
    margin-bottom: 2px;
}

.app-sidebar .nav-link:hover {
    background: var(--mg-sidebar-hover-bg);
    color: #fff;
}

.app-sidebar .nav-link.active {
    background: var(--mg-brand-green);
    color: #fff;
    font-weight: 600;
}

.app-sidebar .nav-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-section-label {
    color: rgba(255,255,255,.35);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 1rem .75rem .3rem;
}

.sidebar-brand {
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: var(--mg-brand-green);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

.brand-icon-lg {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,.06);
    margin: 0;
}

/* Overlay mobile */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
    backdrop-filter: blur(2px);
}

/* ─── Navbar ─────────────────────────────────────────────── */
.app-navbar {
    background: var(--mg-navbar-bg);
    border-bottom: 1px solid var(--mg-navbar-border);
    min-height: 56px;
    z-index: 100;
    transition: background .3s;
}

/* ─── Cards & Conteúdo ───────────────────────────────────── */
.card {
    background: var(--mg-card-bg) !important;
    border-color: var(--mg-card-border) !important;
    border-radius: 12px !important;
    transition: background .3s, border-color .3s;
}

.card-header {
    background: transparent !important;
    border-color: var(--mg-card-border) !important;
    padding: 1rem 1.25rem;
}

/* ─── Stat Cards ─────────────────────────────────────────── */
.stat-card {
    background: var(--mg-card-bg);
    border: 1px solid var(--mg-card-border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--mg-stat-shadow);
    transition: transform .2s, box-shadow .2s;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,.12);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: .5rem;
    opacity: .8;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: .25rem;
}

.stat-label {
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--mg-text-muted);
}

.stat-sub {
    font-size: .75rem;
    color: var(--mg-text-muted);
    margin-top: .2rem;
}

.stat-card-success  { border-left: 3px solid #25d366; } .stat-card-success .stat-icon  { color: #25d366; }
.stat-card-primary  { border-left: 3px solid #0d6efd; } .stat-card-primary .stat-icon  { color: #0d6efd; }
.stat-card-info     { border-left: 3px solid #0dcaf0; } .stat-card-info .stat-icon     { color: #0dcaf0; }
.stat-card-danger   { border-left: 3px solid #dc3545; } .stat-card-danger .stat-icon   { color: #dc3545; }
.stat-card-warning  { border-left: 3px solid #ffc107; } .stat-card-warning .stat-icon  { color: #ffc107; }
.stat-card-neutral  { border-left: 3px solid var(--mg-card-border); }

/* ─── Tables ─────────────────────────────────────────────── */
.table {
    color: var(--mg-text-primary);
}

.table > thead > tr > th {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--mg-text-muted);
    border-color: var(--mg-card-border);
    background: transparent;
    padding: .75rem 1rem;
}

.table > tbody > tr > td {
    border-color: var(--mg-card-border);
    padding: .65rem 1rem;
    vertical-align: middle;
}

.table-hover > tbody > tr:hover {
    background: var(--mg-sidebar-hover-bg);
}

/* ─── Footer ─────────────────────────────────────────────── */
.app-footer {
    border-top: 1px solid var(--mg-card-border);
    background: var(--mg-navbar-bg);
    color: var(--mg-text-muted);
}

/* ─── Auth Pages ─────────────────────────────────────────── */
.auth-body {
    background: linear-gradient(135deg, #0f1117 0%, #1a2332 50%, #0d3d2e 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.auth-card {
    background: var(--mg-card-bg);
    border: 1px solid var(--mg-card-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

/* ─── Avatar ─────────────────────────────────────────────── */
.avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--mg-brand-green);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ─── QR Code ────────────────────────────────────────────── */
.qr-area {
    border-top: 1px solid var(--mg-card-border);
    padding-top: 1rem;
}

.qr-code-img {
    max-width: 220px;
    width: 100%;
    border-radius: 12px !important;
}

.wa-status-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.status-connected    { background: #d1fae5; color: #059669; }
.status-waiting      { background: #fef9c3; color: #b45309; }
.status-disconnected { background: #f3f4f6; color: #9ca3af; }

[data-bs-theme="dark"] .status-connected    { background: #052e16; color: #4ade80; }
[data-bs-theme="dark"] .status-waiting      { background: #422006; color: #fbbf24; }
[data-bs-theme="dark"] .status-disconnected { background: #1f2937; color: #6b7280; }

/* ─── Grupos Checkboxes ──────────────────────────────────── */
.grupos-checkboxes {
    background: var(--mg-body-bg);
    border-color: var(--mg-card-border) !important;
    border-radius: 8px;
    max-height: 240px;
    overflow-y: auto;
}

/* ─── Badges personalizadas ──────────────────────────────── */
.bg-success-subtle  { background-color: rgba(37,211,102,.15) !important; }
.bg-primary-subtle  { background-color: rgba(13,110,253,.15) !important; }
.bg-danger-subtle   { background-color: rgba(220,53,69,.15) !important; }
.bg-warning-subtle  { background-color: rgba(255,193,7,.15) !important; }
.bg-info-subtle     { background-color: rgba(13,202,240,.15) !important; }
.bg-secondary-subtle{ background-color: rgba(108,117,125,.15) !important; }

/* ─── Toast notifications ────────────────────────────────── */
#toastContainer {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
}

.toast-item {
    background: var(--mg-card-bg);
    border: 1px solid var(--mg-card-border);
    border-radius: 10px;
    padding: .75rem 1rem;
    margin-top: .5rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    display: flex;
    align-items: center;
    gap: .75rem;
    animation: slideIn .3s ease;
    min-width: 240px;
    max-width: 320px;
}

@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ─── Responsivo Mobile ──────────────────────────────────── */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        z-index: 1000;
    }

    .app-sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,.3);
    }

    #page-content {
        width: 100%;
    }
}

/* ─── Animações ──────────────────────────────────────────── */
.btn, .nav-link, .card { transition: var(--mg-transition); }

.btn:active { transform: scale(0.97); }

/* Form controls com tema */
.form-control, .form-select, .input-group-text {
    background-color: var(--mg-card-bg);
    border-color: var(--mg-card-border);
    color: var(--mg-text-primary);
}

.form-control:focus, .form-select:focus {
    background-color: var(--mg-card-bg);
    color: var(--mg-text-primary);
    border-color: var(--mg-brand-green);
    box-shadow: 0 0 0 .25rem rgba(37,211,102,.25);
}

.form-control::placeholder { color: var(--mg-text-muted); opacity: .7; }

/* Empty state */
.empty-state { color: var(--mg-text-muted); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128,128,128,.5); }

/* ─── Landing Page ───────────────────────────────────────── */
.landing-body {
    background: #fff;
    color: #212529;
}

[data-bs-theme="dark"] .landing-body {
    background: #0d1117;
    color: #e9ecef;
}

.landing-hero {
    background: linear-gradient(135deg, #0d3d2e 0%, #1a2332 50%, #0f1117 100%);
    color: #fff;
    padding: 5rem 0 4rem;
}

.landing-nav {
    background: rgba(10,15,20,.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.plan-card {
    border: 2px solid var(--mg-card-border);
    border-radius: 16px;
    transition: transform .25s, border-color .25s, box-shadow .25s;
}

.plan-card:hover, .plan-card.featured {
    border-color: var(--mg-brand-green);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(37,211,102,.2);
}

.how-step {
    text-align: center;
    padding: 1.5rem;
}

.how-step-number {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.feature-icon-box {
    width: 56px;
    height: 56px;
    background: rgba(37,211,102,.12);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #25d366;
    margin-bottom: 1rem;
}
