/* 2026-06-21 */
/* hubvpn/panel/css/estilo.css */
/* HubVPN DNNS - estilos del panel con tema claro/oscuro (acento verde Mantis) */

/* --- Tema OSCURO (por defecto) --- */
:root {
    --verde: #69c350;
    --verde-osc: #4f9c3c;
    --fondo: #0e1311;
    --fondo2: #15201b;
    --panel: #161d1a;
    --panel2: #1c2521;
    --borde: #243029;
    --texto: #e7efe9;
    --gris: #8aa093;
    --sombra: rgba(0,0,0,.45);
    --rojo: #e0564f;
}
/* --- Tema CLARO --- */
html[data-tema="claro"] {
    --verde: #4f9c3c;
    --verde-osc: #3c7d2d;
    --fondo: #f3f6f3;
    --fondo2: #e6efe6;
    --panel: #ffffff;
    --panel2: #f4f8f4;
    --borde: #d9e3da;
    --texto: #1b241e;
    --gris: #5e7166;
    --sombra: rgba(40,60,45,.15);
    --rojo: #c0392b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    background: radial-gradient(1200px 600px at 50% -10%, var(--fondo2) 0%, var(--fondo) 60%);
    color: var(--texto);
    min-height: 100vh;
    transition: background .3s ease, color .3s ease;
}
a { color: var(--verde); }
b { color: var(--verde); }

/* Conmutador de tema (esquina) */
.tema-btn {
    position: fixed; top: 18px; right: 18px; z-index: 50;
    width: 42px; height: 42px; border-radius: 50%;
    border: 1px solid var(--borde); background: var(--panel);
    color: var(--texto); cursor: pointer; font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px var(--sombra);
    transition: transform .2s ease, border-color .2s ease;
}
.tema-btn:hover { transform: scale(1.08); border-color: var(--verde); }

/* ---------- LOGIN ---------- */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
    width: 100%; max-width: 400px;
    background: var(--panel); border: 1px solid var(--borde);
    border-radius: 18px; padding: 38px 34px;
    box-shadow: 0 20px 60px var(--sombra);
}
.marca { display: inline-flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.marca .punto { width: 13px; height: 13px; border-radius: 50%; background: var(--verde);
    box-shadow: 0 0 0 5px rgba(105,195,80,.15); animation: latido 2s infinite; }
@keyframes latido { 0%,100%{opacity:1} 50%{opacity:.35} }
.marca span { font-family: 'IBM Plex Mono', monospace; letter-spacing: .18em; font-size: 12px; color: var(--gris); text-transform: uppercase; }
.login-card h1 { font-family: 'Fraunces', serif; font-weight: 600; font-size: 30px; margin-bottom: 6px; }
.login-card .sub { color: var(--gris); font-size: 14px; margin-bottom: 26px; }

.campo { margin-bottom: 16px; }
.campo label { display: block; font-size: 13px; color: var(--gris); margin-bottom: 6px; }
.campo input {
    width: 100%; padding: 12px 14px; font-size: 15px;
    background: var(--panel2); color: var(--texto);
    border: 1px solid var(--borde); border-radius: 10px; outline: none;
    transition: border-color .15s ease;
}
.campo input:focus { border-color: var(--verde); }

.btn {
    width: 100%; padding: 13px; font-size: 15px; font-weight: 600;
    background: var(--verde); color: #06210a; border: none; border-radius: 10px;
    cursor: pointer; transition: background .15s ease;
    font-family: inherit;
}
.btn:hover { background: var(--verde-osc); }
.btn:disabled { opacity: .6; cursor: default; }

.aviso { margin-top: 14px; font-size: 13px; padding: 10px 12px; border-radius: 9px; display: none; }
.aviso.error { display: block; background: rgba(224,86,79,.12); border: 1px solid rgba(224,86,79,.4); color: var(--rojo); }

.pie-login { margin-top: 22px; text-align: center; font-size: 12px; color: var(--gris); }

/* ---------- PANEL ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 26px; background: var(--panel); border-bottom: 1px solid var(--borde);
}
.topbar .marca span { font-size: 13px; }
.topbar h1 { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; }
.topbar .usuario { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--gris); }
.btn-sec {
    padding: 8px 14px; font-size: 13px; font-weight: 600;
    background: transparent; color: var(--texto); border: 1px solid var(--borde);
    border-radius: 9px; cursor: pointer; font-family: inherit;
}
.btn-sec:hover { border-color: var(--verde); color: var(--verde); }

.contenido { max-width: 1100px; margin: 0 auto; padding: 30px 26px; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 28px; }
.tarjeta-kpi {
    background: var(--panel); border: 1px solid var(--borde); border-radius: 14px; padding: 22px;
}
.tarjeta-kpi .num { font-family: 'IBM Plex Mono', monospace; font-size: 32px; font-weight: 500; color: var(--verde); }
.tarjeta-kpi .lbl { font-size: 13px; color: var(--gris); margin-top: 4px; }

/* ---------- BANNER PWA ---------- */
#pwa-banner {
    position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 100;
    background: var(--verde); color: #06210a; padding: 11px 16px; border-radius: 12px;
    font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35);
    display: flex; align-items: center; gap: 12px;
}
#pwa-banner button {
    background: #06210a; color: var(--verde); border: none; border-radius: 8px;
    padding: 7px 12px; font-weight: 600; cursor: pointer; font-family: inherit;
}

/* ---------- LAYOUT SIDEBAR ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 236px; background: var(--panel); border-right: 1px solid var(--borde);
    position: fixed; top: 0; bottom: 0; left: 0; display: flex; flex-direction: column; z-index: 40;
    transition: transform .25s ease;
}
.sidebar .cab { padding: 20px 20px 14px; border-bottom: 1px solid var(--borde); }
.sidebar nav { flex: 1; padding: 10px; overflow-y: auto; }
.sidebar nav a {
    display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 10px;
    color: var(--texto); text-decoration: none; font-size: 14px; margin-bottom: 2px;
}
.sidebar nav a .ico { width: 18px; text-align: center; opacity: .8; }
.sidebar nav a:hover { background: var(--panel2); }
.sidebar nav a.activo { background: rgba(105,195,80,.13); color: var(--verde); font-weight: 600; }
.sidebar .abajo { padding: 12px; border-top: 1px solid var(--borde); display: flex; flex-direction: column; gap: 8px; }
.sidebar .usr { font-size: 13px; color: var(--gris); padding: 2px 4px; }
.sidebar .version { font-size: 11px; color: var(--gris); font-family: 'IBM Plex Mono', monospace; text-align: center; opacity: .55; padding-top: 2px; }
.sidebar .usr b { color: var(--verde); }
.sidebar-fila { display: flex; gap: 8px; }
.sidebar-fila .btn-sec, .sidebar-fila .tema-mini { flex: 1; justify-content: center; }
.tema-mini { padding: 8px; font-size: 15px; background: transparent; border: 1px solid var(--borde); border-radius: 9px; color: var(--texto); cursor: pointer; }
.tema-mini:hover { border-color: var(--verde); }

.main { margin-left: 236px; flex: 1; min-width: 0; }
.topbar2 { display: flex; align-items: center; gap: 14px; padding: 18px 30px; border-bottom: 1px solid var(--borde); }
.topbar2 h1 { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 600; }
.topbar2 .sub { color: var(--gris); font-size: 13px; }
.hamburguesa { display: none; background: transparent; border: 1px solid var(--borde); border-radius: 8px; color: var(--texto); width: 38px; height: 38px; cursor: pointer; font-size: 16px; }
.contenido2 { padding: 26px 30px; max-width: 1080px; }

.backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.abierta { transform: translateX(0); }
    .main { margin-left: 0; }
    .hamburguesa { display: inline-flex; align-items: center; justify-content: center; }
    .backdrop.visible { display: block; }
}

.seccion { background: var(--panel); border: 1px solid var(--borde); border-radius: 14px; padding: 24px; margin-bottom: 22px; }
.seccion h2 { font-family: 'Fraunces', serif; font-size: 19px; margin-bottom: 6px; }
.seccion .nota { color: var(--gris); font-size: 14px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
    background: rgba(105,195,80,.12); color: var(--verde); border: 1px solid rgba(105,195,80,.35); }

/* ---------- TABLAS Y EDITORES (oficinas/trabajadores) ---------- */
table.datos { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
table.datos th, table.datos td { text-align: left; padding: 10px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
table.datos th { color: var(--gris); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
table.datos td.mono { font-family: 'IBM Plex Mono', monospace; }

.acc { display: flex; gap: 6px; flex-wrap: wrap; }
.mini { padding: 6px 10px; font-size: 12px; border-radius: 8px; cursor: pointer; font-family: inherit; text-decoration: none;
    border: 1px solid var(--borde); background: transparent; color: var(--texto); display: inline-block; }
.mini:hover { border-color: var(--verde); color: var(--verde); }
.mini.rojo:hover { border-color: var(--rojo); color: var(--rojo); }

.msg { margin: 0 0 18px; padding: 11px 14px; border-radius: 9px; font-size: 14px; }
.msg.ok { background: rgba(105,195,80,.12); border: 1px solid rgba(105,195,80,.4); color: var(--verde); }
.msg.error { background: rgba(224,86,79,.12); border: 1px solid rgba(224,86,79,.4); color: var(--rojo); }

.form-inline { display: flex; gap: 10px; align-items: end; margin-top: 12px; flex-wrap: wrap; }
.form-inline .campo { margin: 0; flex: 1; min-width: 160px; }
.form-inline .btn { width: auto; padding: 12px 18px; }

details.editor { margin-top: 8px; }
details.editor > summary { cursor: pointer; color: var(--verde); font-size: 12px; list-style: none; padding: 4px 0; }
details.editor > summary::-webkit-details-marker { display: none; }
.rejilla-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px;
    background: var(--panel2); border: 1px solid var(--borde); border-radius: 10px; padding: 14px; }
.rejilla-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--gris); }
.rejilla-edit label.ancho { grid-column: 1 / -1; }
.rejilla-edit .ancho { grid-column: 1 / -1; }
.rejilla-edit input, .rejilla-edit select {
    padding: 9px 10px; background: var(--panel); color: var(--texto); border: 1px solid var(--borde);
    border-radius: 8px; font-family: inherit; font-size: 13px;
}
.rejilla-edit .btn { width: auto; padding: 10px 16px; }
.campo-mono { width: 100%; margin: 8px 0; padding: 9px; background: var(--panel2); color: var(--texto);
    border: 1px solid var(--borde); border-radius: 8px; font-family: 'IBM Plex Mono', monospace; font-size: 12px; }

/* ---------- MATRIZ DE ACCESO ---------- */
.matriz-wrap { overflow-x: auto; }
.matriz { border-collapse: collapse; font-size: 14px; margin-top: 10px; }
.matriz th, .matriz td { border: 1px solid var(--borde); padding: 10px 12px; text-align: center; }
.matriz th.tleft, .matriz td.tleft { text-align: left; white-space: nowrap; }
.matriz thead th { color: var(--gris); font-size: 12px; font-weight: 600; background: var(--panel2); }
.matriz td.tleft small { color: var(--gris); font-family: 'IBM Plex Mono', monospace; }
.matriz td input { width: 18px; height: 18px; accent-color: var(--verde); cursor: pointer; }
.matriz td input:disabled { opacity: .4; }
.matriz-estado { margin-top: 14px; font-size: 13px; color: var(--gris); min-height: 18px; }
.matriz-estado.ok { color: var(--verde); }
.matriz-estado.err { color: var(--rojo); }

/* Credencial trabajador (QR) */
.cred { display: grid; grid-template-columns: 220px 1fr; gap: 22px; align-items: start; }
.cred .qr { background: #fff; padding: 12px; border-radius: 12px; }
.cred .qr svg { width: 100%; height: auto; display: block; }
.cred pre { background: var(--panel2); border: 1px solid var(--borde); border-radius: 10px; padding: 14px;
    font-family: 'IBM Plex Mono', monospace; font-size: 12px; overflow-x: auto; color: var(--texto); }
.cred .aviso-qr { color: #d6a23b; font-size: 13px; margin-top: 10px; }
@media (max-width: 620px) { .cred { grid-template-columns: 1fr; } }

/* Bloque de respuesta cruda (sandbox / túneles) */
pre.json { background: var(--panel2); border: 1px solid var(--borde); border-radius: 10px; padding: 16px;
    font-family: 'IBM Plex Mono', monospace; font-size: 13px; overflow-x: auto; margin-top: 10px; color: var(--texto); white-space: pre-wrap; word-break: break-word; }
.form-fila { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; margin-top: 14px; align-items: end; }
.form-fila .campo { margin: 0; }
.form-fila .btn { width: auto; padding: 12px 18px; }
.info-conexion { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--gris); margin-top: 4px; }
@media (max-width: 640px) { .form-fila { grid-template-columns: 1fr; } .form-fila .btn { width: 100%; } }

/* ============================================================
   RESPONSIVE + PULIDO (móvil/PWA y escritorio)
   ============================================================ */

/* Safe areas para PWA en móviles con notch / barra de gestos */
@supports (padding: env(safe-area-inset-top)) {
    .sidebar .cab { padding-top: calc(20px + env(safe-area-inset-top)); }
    .topbar2 { padding-top: calc(18px + env(safe-area-inset-top)); }
    .login-wrap { padding-top: calc(24px + env(safe-area-inset-top)); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
    .sidebar .abajo { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
    #pwa-banner { bottom: calc(22px + env(safe-area-inset-bottom)); }
}

/* Tablas anchas: scroll horizontal suave en pantallas estrechas */
@media (max-width: 760px) {
    table.datos { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table.datos thead, table.datos tbody, table.datos tr { width: max-content; min-width: 100%; }
    .matriz-wrap { -webkit-overflow-scrolling: touch; border: 1px solid var(--borde); border-radius: 10px; }
}

/* Escritorio: un poco más de aire y ancho cómodo */
@media (min-width: 1100px) {
    .contenido2 { padding: 30px 40px; max-width: 1160px; }
}

/* Móvil */
@media (max-width: 640px) {
    .contenido2 { padding: 16px 14px; }
    .topbar2 { padding: 14px 16px; gap: 10px; }
    .topbar2 h1 { font-size: 18px; }
    .topbar2 .sub { display: none; }
    .seccion { padding: 18px 15px; border-radius: 12px; margin-bottom: 16px; }
    .seccion h2 { font-size: 17px; }
    .rejilla { gap: 12px; margin-bottom: 18px; }
    .tarjeta-kpi { padding: 18px; }
    .tarjeta-kpi .num { font-size: 28px; }
    .form-inline { flex-direction: column; align-items: stretch; }
    .form-inline .campo { min-width: 0; }
    .form-inline .btn { width: 100%; }
    .rejilla-edit { grid-template-columns: 1fr !important; }
    .login-card { padding: 30px 22px; border-radius: 16px; }
    .login-card h1 { font-size: 27px; }
    .tema-btn { top: 14px; right: 14px; width: 38px; height: 38px; }
    /* Botones de acción más cómodos al tacto */
    .mini { padding: 9px 12px; font-size: 13px; }
    .acc { gap: 8px; }
}

/* Inputs: evitar zoom automático en iOS (font-size >= 16px) y mejor toque */
@media (max-width: 640px) {
    .campo input, .rejilla-edit input, .rejilla-edit select, .campo-mono, .form-inline input {
        font-size: 16px;
    }
}

/* Sin resaltado azul al tocar en móvil */
a, button, input, .mini, .btn, .btn-sec { -webkit-tap-highlight-color: transparent; }

/* Scrollbars discretas (escritorio) */
.matriz-wrap::-webkit-scrollbar, table.datos::-webkit-scrollbar { height: 8px; }
.matriz-wrap::-webkit-scrollbar-thumb, table.datos::-webkit-scrollbar-thumb { background: var(--borde); border-radius: 8px; }
