:root {
    --primary:    #25D366;
    --primary-dk: #128C7E;
    --sidebar-w:  260px;
    --topbar-h:   56px;
}

/* ---- Layout ---- */
body { background: #f0f2f5; font-family: 'Segoe UI', sans-serif; }

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    position: fixed;
    top: 0; left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform .3s ease;
}

.sidebar-brand {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-icon { font-size: 1.8rem; color: var(--primary); }
.sidebar-brand .brand-name { font-size: 1.1rem; font-weight: 700; color: #fff; margin-left: .5rem; }

.sidebar-nav { flex: 1; padding: .5rem 0; overflow-y: auto; }
.sidebar-nav .nav-section {
    padding: .6rem 1rem .3rem;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: rgba(255,255,255,.35);
}
.sidebar-nav .nav-item { padding: 0; }
.sidebar-nav .nav-link {
    padding: .65rem 1.5rem;
    color: rgba(255,255,255,.7);
    display: flex;
    align-items: center;
    gap: .75rem;
    border-left: 3px solid transparent;
    transition: all .2s;
    font-size: .9rem;
}
.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(37,211,102,.1);
    border-left-color: var(--primary);
}
.sidebar-nav .nav-link i { width: 1.1rem; text-align: center; }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.08);
    color: rgba(255,255,255,.5);
    font-size: .8rem;
}

/* Status badge in sidebar */
#sidebar-wa-status { font-size: .75rem; }

.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar .page-title { font-size: 1.05rem; font-weight: 600; color: #212529; margin: 0; }

.content-body { padding: 1.5rem; }

/* ---- Stat Cards ---- */
.stat-card {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.stat-card .card-body { padding: 1.25rem; }
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; color: #6c757d; margin-top: .25rem; }

/* ---- Connection QR ---- */
.qr-wrapper {
    display: inline-block;
    padding: 1rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.qr-wrapper img { width: 260px; height: 260px; }

.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}
.status-dot.connected    { background: #25D366; box-shadow: 0 0 0 3px rgba(37,211,102,.25); }
.status-dot.disconnected { background: #dc3545; }
.status-dot.connecting   { background: #ffc107; animation: pulse 1.2s infinite; }
.status-dot.qr_pending   { background: #0d6efd; animation: pulse 1.2s infinite; }

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

/* ---- Tables ---- */
.table-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    overflow: hidden;
}
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: #6c757d; border-top: none; }
.table td { vertical-align: middle; font-size: .9rem; }

/* ---- Badges ---- */
.badge-status-running    { background: rgba(37,211,102,.15); color: #0a7a3c; }
.badge-status-completed  { background: rgba(13,110,253,.15); color: #084298; }
.badge-status-paused     { background: rgba(255,193,7,.15);  color: #856404; }
.badge-status-draft      { background: rgba(108,117,125,.15); color: #41464b; }
.badge-status-cancelled  { background: rgba(220,53,69,.15);  color: #842029; }
.badge-status-scheduled  { background: rgba(13,202,240,.15); color: #055160; }
.badge-status-sent       { background: rgba(37,211,102,.15); color: #0a7a3c; }
.badge-status-failed     { background: rgba(220,53,69,.15);  color: #842029; }
.badge-status-pending    { background: rgba(255,193,7,.15);  color: #856404; }
.badge-status-delivered  { background: rgba(13,110,253,.15); color: #084298; }

/* ---- Progress ---- */
.campaign-progress { height: 6px; border-radius: 3px; }

/* ---- Forms ---- */
.form-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

/* ---- Template preview ---- */
.template-card {
    border-radius: 10px;
    border: 1px solid #dee2e6;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s;
}
.template-card:hover, .template-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37,211,102,.2);
}
.template-card .message-bubble {
    background: #DCF8C6;
    border-radius: 8px;
    padding: .6rem .85rem;
    font-size: .85rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
}

/* ---- Loader ---- */
.loader-overlay {
    position: fixed; inset: 0;
    background: rgba(255,255,255,.8);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
.spinner-wa {
    width: 48px; height: 48px;
    border: 4px solid #dee2e6;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast ---- */
.toast-container { z-index: 11000; }
