/* ============================================================
   Nexus-WhatsApp — "Slate pro"
   Tema plano y sobrio. Oscuro por defecto, claro con
   html[data-theme="light"]. Sin degradados/blur/neón.
   Se conservan TODOS los nombres de clase de las páginas.
   ============================================================ */

:root {
    --bg: #0f172a;
    --panel: #1e293b;
    --panel-2: #243244;
    --panel-glass: rgba(30, 41, 59, 0.80);
    --border: #334155;
    --border-2: #3f4d63;
    --text: #f1f5f9;
    --muted: #b6c2d2;
    --faint: #8593a4;

    --accent: #1466ff;
    --accent-2: #0a5cff;
    --accent-3: #0048d6;
    --accent-soft: rgba(20, 102, 255, 0.26);
    --accent-brd: rgba(20, 102, 255, 0.55);
    --accent-ink: #7aa9ff;

    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.14);
    --ok: #34d399;
    --ok-soft: rgba(52, 211, 153, 0.14);

    --flash-err-text: #fca5a5;
    --flash-warn-text: #fcd34d;
    --flash-ok-text: #6ee7b7;
    --btn-text: #ffffff;
    --badge-text: #ffffff;

    --radius: 12px;
    --radius-sm: 8px;
    --nav-active-bg: var(--accent-soft);
    --nav-active-ink: var(--accent-ink);
    --chat-active: rgba(20, 102, 255, 0.28);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    --elev: 0 1px 2px rgba(0, 0, 0, 0.30), 0 14px 32px rgba(0, 0, 0, 0.42);
    --elev-hover: 0 2px 6px rgba(0, 0, 0, 0.38), 0 22px 48px rgba(0, 0, 0, 0.52);
}

/* El navegador pinta los selectores nativos (fecha/hora, scrollbars) acorde al tema. */
html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

html[data-theme="light"] {
    --bg: #f1f5f9;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --panel-glass: rgba(255, 255, 255, 0.80);
    --border: #e2e8f0;
    --border-2: #cbd5e1;
    --text: #0b1220;
    --muted: #475569;
    --faint: #64748b;

    --accent: #1741d6;
    --accent-2: #1741d6;
    --accent-3: #1233b0;
    --accent-soft: #c2d6ff;
    --accent-brd: rgba(23, 65, 214, 0.50);
    --accent-ink: #1535ad;

    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warn: #b45309;
    --warn-soft: #fef3c7;
    --ok: #059669;
    --ok-soft: #d1fae5;

    --flash-err-text: #b91c1c;
    --flash-warn-text: #92400e;
    --flash-ok-text: #047857;
    --btn-text: #ffffff;
    --badge-text: #ffffff;

    --nav-active-bg: #c2d6ff;
    --nav-active-ink: #1535ad;
    --chat-active: #d6e4ff;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    --elev: 0 1px 2px rgba(15, 23, 42, 0.06), 0 12px 28px rgba(15, 23, 42, 0.12);
    --elev-hover: 0 2px 6px rgba(15, 23, 42, 0.09), 0 20px 44px rgba(15, 23, 42, 0.17);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "SF Pro Display", "Segoe UI", system-ui, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    font-size: 15px;
    min-height: 100vh;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Fondo de partículas conectadas (red neuronal). Detrás del contenido. */
#particles { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

/* ------------------------------- Shell --------------------------------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 230px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    background: var(--panel-glass);
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    border-right: 1px solid var(--border);
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.side-brand svg { width: 24px; height: 24px; color: var(--accent); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.12; }
.brand-name { font-size: 17px; font-weight: 600; color: var(--text); }
.brand-sub { font-size: 10px; font-weight: 500; letter-spacing: 1.6px; text-transform: uppercase; color: var(--accent-ink); margin-top: 1px; }

/* Selector de canal activo */
.chan-chip {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 9px; margin-bottom: 10px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    text-decoration: none; color: var(--text);
    transition: border-color .15s ease, background .15s ease;
}
.chan-chip:hover { border-color: var(--border-2); background: var(--panel-2); }
.chan-av {
    width: 28px; height: 28px; flex: none; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent-ink);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 500;
}
.chan-meta { flex: 1; min-width: 0; }
.chan-name { display: block; font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan-sub { display: block; font-size: 11px; color: var(--faint); }
.chan-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chan-dot.ok { background: var(--ok); }
.chan-dot.bad { background: var(--danger); }

/* Navegación agrupada */
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.nav-group { font-size: 12px; color: var(--faint); margin: 12px 8px 3px; }
.nav-group:first-child { margin-top: 2px; }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 9px; border-radius: var(--radius-sm);
    color: var(--muted); text-decoration: none; font-size: 14.5px;
    transition: background .15s ease, color .15s ease;
}
.sidebar nav a svg { width: 18px; height: 18px; flex: none; }
.sidebar nav a:hover { background: var(--panel-2); color: var(--text); }
.sidebar nav a.active { background: var(--nav-active-bg); color: var(--nav-active-ink); }
.side-foot { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }

.token-state { font-size: 12px; padding: 5px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--muted); display: block; }
.token-state.ok { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-brd); }
.token-state.bad { background: var(--danger-soft); color: var(--flash-err-text); border-color: var(--danger); }
.user-chip { color: var(--muted); }
.side-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }

.theme-btn {
    background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
    width: 34px; height: 34px; cursor: pointer; font-size: 15px; line-height: 1; padding: 0; flex: none;
    color: var(--text); transition: border-color .15s ease;
}
.theme-btn:hover { border-color: var(--border-2); }
.theme-float { position: fixed; top: 16px; right: 16px; z-index: 50; }

/* ------------------------------- Topbar -------------------------------- */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 26px; border-bottom: 1px solid var(--border);
    background: var(--panel-glass); backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%); position: sticky; top: 0; z-index: 8;
}
.topbar h1 { font-size: 21px; font-weight: 600; margin: 0; letter-spacing: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-right .user-chip { font-size: 12.5px; }
.op-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--accent-brd); }
.op-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

/* ----------------------------- Contenedor ------------------------------ */
.container { max-width: 1600px; width: 100%; margin: 0 auto; padding: 22px 30px 70px; }
h1 { font-size: 21px; font-weight: 600; margin: 0 0 18px; }
h2 { font-size: 18px; font-weight: 600; margin: 22px 0 12px; color: var(--text); }

/* -------------------------------- Cards -------------------------------- */
.card {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; margin-bottom: 18px; box-shadow: var(--elev);
    transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--elev-hover); }
.card h2:first-child, .card h2[style] { margin-top: 0; }

/* ------------------------------ Formularios ---------------------------- */
label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=number], input[type=password], input[type=file],
input[type=datetime-local], input[type=date], input[type=time], input[type=month],
textarea, select {
    width: 100%; background: var(--panel-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); padding: 10px 13px;
    font-size: 15px; font-family: inherit; transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 110px; resize: vertical; }

/* Secciones colapsables (pantalla Ajustes) */
.card.sect > .sect-h { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; user-select: none; }
.card.sect > .sect-h::after { content: '▾'; font-size: 12px; color: var(--faint); transition: transform .18s ease; }
.card.sect.collapsed > .sect-h::after { transform: rotate(-90deg); }
.card.sect.collapsed > :not(.sect-h) { display: none; }

/* Formulario a dos columnas (Grupos, como Publicar) */
.split-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 22px; align-items: start; }
.split-2 .col-right { border-left: 1px solid var(--border); padding-left: 22px; }
@media (max-width: 900px) { .split-2 { grid-template-columns: 1fr; gap: 4px; } .split-2 .col-right { border-left: 0; padding-left: 0; } }

/* Dos tarjetas lado a lado (mismo ancho), p.ej. grupos reales + locales */
.cards-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.cards-2 > .card { overflow-x: auto; }
.cards-2 table th, .cards-2 table td { padding: 7px 9px; }
@media (max-width: 1100px) { .cards-2 { grid-template-columns: 1fr; } }

/* Botón-enlace pequeño (p.ej. "ver ID") */
.link-mini { background: none; border: 0; padding: 0; font: inherit; font-size: 12px; color: var(--accent); cursor: pointer; text-decoration: underline; }
.link-mini:hover { color: var(--accent-ink); }
.id-val { font-size: 11px; word-break: break-all; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly] { color: var(--muted); }
select option { background: var(--panel); color: var(--text); }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 200px; }

/* -------------------------------- Botones ------------------------------ */
.btn {
    display: inline-block; background: var(--accent-2); color: var(--btn-text);
    border: 1px solid var(--accent-2); border-radius: var(--radius-sm);
    padding: 10px 20px; font-size: 15px; font-weight: 600; cursor: pointer;
    margin-top: 16px; transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--accent-3); border-color: var(--accent-3); }
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--border-2); }
.btn.secondary:hover { background: var(--panel-2); border-color: var(--border-2); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { margin: 0; padding: 6px 13px; font-size: 13px; font-weight: 500; }

/* -------------------------------- Flashes ------------------------------ */
.flash { padding: 11px 15px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; }
.flash.success { background: var(--ok-soft); border-color: var(--ok); color: var(--flash-ok-text); }
.flash.error { background: var(--danger-soft); border-color: var(--danger); color: var(--flash-err-text); }
.flash.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--flash-warn-text); }

/* --------------------------------- Tablas ------------------------------ */
table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
tbody tr:hover, table tr:hover td { background: var(--panel-2); }
td.mono, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }

/* --------------------------------- Stats ------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--elev); }
.stat .num { font-size: 28px; font-weight: 600; color: var(--text); }
.stat .lbl { font-size: 13px; color: var(--muted); margin-top: 5px; }

/* ------------------------------ Misceláneos ---------------------------- */
.hint { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.nx-help { background: var(--accent-soft); border: 1px solid var(--accent-brd); border-radius: var(--radius); padding: 11px 15px; margin-bottom: 18px; font-size: 13.5px; }
.nx-help > summary { cursor: pointer; color: var(--accent-ink); font-weight: 500; list-style: none; }
.nx-help > summary::-webkit-details-marker { display: none; }
.nx-help > summary::before { content: '▸ '; }
.nx-help[open] > summary::before { content: '▾ '; }
.nx-help .body { margin-top: 9px; color: var(--text); line-height: 1.6; }
.nx-help .body ul { margin: 6px 0; padding-left: 18px; }
.nx-help .body li { margin: 3px 0; }
.nx-help .body a { color: var(--accent-ink); }
.pill {
    display: inline-block; font-size: 11.5px; padding: 3px 11px; border-radius: 99px;
    background: var(--panel-2); border: 1px solid var(--border); margin: 2px; color: var(--text); text-decoration: none;
}
.pill:hover { border-color: var(--accent); }
.foot { text-align: center; color: var(--faint); font-size: 12px; padding: 24px; }
.eyebrow { display: inline-block; font-size: 11.5px; font-weight: 500; color: var(--accent-ink); letter-spacing: .5px; padding: 5px 12px; background: var(--accent-soft); border: 1px solid var(--accent-brd); border-radius: var(--radius-sm); }

.role-pill { display: inline-block; font-size: 11px; padding: 2px 10px; border-radius: 99px; }
.role-pill.admin { background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--accent-brd); }
.role-pill.creator { background: var(--warn-soft); color: var(--flash-warn-text); border: 1px solid var(--warn); }
.role-pill.member { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }

.wa-pill { display: inline-block; font-size: 10.5px; padding: 1px 8px; border-radius: 99px; }
.wa-pill.yes { background: var(--ok-soft); color: var(--flash-ok-text); }
.wa-pill.no { background: var(--danger-soft); color: var(--flash-err-text); }
.wa-pill.unk { background: var(--panel-2); color: var(--muted); }

.radio-group { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.radio-group label {
    flex: 1; min-width: 200px; margin: 0; padding: 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; color: var(--text); display: flex; gap: 8px; align-items: flex-start; background: var(--panel);
    transition: border-color .15s ease, background .15s ease;
}
.radio-group label:hover { background: var(--panel-2); border-color: var(--border-2); }
.radio-group input { width: auto; margin-top: 3px; }

/* ------------------------- Jobs (cola de tareas) ------------------------ */
.jobpill { display: inline-flex; align-items: center; padding: 6px 13px; border-radius: 99px; background: var(--accent-soft); border: 1px solid var(--accent-brd); color: var(--accent-ink); font-size: 12.5px; text-decoration: none; }
.progress { height: 9px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--border); overflow: hidden; margin: 10px 0 4px; }
.progress .bar { height: 100%; background: var(--accent-2); transition: width .4s ease; }
.job-status { font-size: 11px; padding: 3px 10px; border-radius: 99px; }
.job-status.running, .job-status.pending { background: var(--accent-soft); color: var(--accent-ink); }
.job-status.done { background: var(--panel-2); color: var(--muted); }
.job-status.paused { background: var(--warn-soft); color: var(--flash-warn-text); }
.job-status.error, .job-status.canceled { background: var(--danger-soft); color: var(--flash-err-text); }
.job-log { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--muted); white-space: pre-wrap; max-height: 150px; overflow-y: auto; margin-top: 8px; }

/* ------------------------------- Login --------------------------------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px;
    background: radial-gradient(circle at 50% 26%, rgba(20, 102, 255, 0.18), transparent 62%), var(--bg); }
.auth-card {
    position: relative; z-index: 1; width: 100%; max-width: 410px; padding: 38px 32px; border-radius: 16px; margin-bottom: 0;
    background: var(--panel); border: 1px solid var(--accent-brd);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset,
                0 30px 64px -22px rgba(15, 23, 42, 0.6),
                0 0 0 1px rgba(20, 102, 255, 0.12),
                0 0 70px -14px rgba(20, 102, 255, 0.55);
    animation: authFloat 6.5s ease-in-out infinite;
}
@keyframes authFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@media (prefers-reduced-motion: reduce) { .auth-card { animation: none; } }
.auth-head { text-align: center; margin-bottom: 24px; }
.logo-gradient { font-weight: 600; font-size: 17px; letter-spacing: 2px; color: var(--accent); margin-bottom: 12px; }
.auth-card h1 { font-size: 25px; font-weight: 600; margin: 0 0 6px; }
.auth-sub { font-size: 13.5px; color: var(--muted); margin: 0 0 10px; }
.auth-card label { font-size: 12.5px; }
.auth-card .btn { width: 100%; padding: 13px; font-size: 15px; }
.auth-foot { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; font-size: 11.5px; color: var(--muted); }

/* ------------------------------- Responsive ----------------------------- */
@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar { position: static; width: auto; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; border-right: none; border-bottom: 1px solid var(--border); }
    .side-brand { padding: 0 8px 0 0; }
    .chan-chip { margin: 0; }
    .nav-group { display: none; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 2px; flex: 1 1 100%; }
    .sidebar nav a { padding: 6px 9px; font-size: 12.5px; gap: 6px; }
    .side-foot { border: none; padding: 0; margin: 0 0 0 auto; flex-direction: row; align-items: center; }
    .topbar { padding: 12px 16px; }
    .container { padding: 16px 14px 60px; }
}
