/* css/mw-shell.css
   Marco de la aplicacion con el estilo nuevo: menu lateral azul, barra de arriba y MODO OSCURO.
   Se carga DESPUES de main.css, componentes.css y mw-ui.css (por eso gana sobre ellos).

   Modo oscuro: <html data-theme="dark">. Lo pone js/mw-shell.js (boton de la luna) y se recuerda
   en este navegador. Funciona completo en las paginas con el estilo nuevo (.mwp: Planes, Routers,
   Clientes, Agregar cliente, Ficha); las viejas se adaptan a medias hasta que les toque el rediseño.
*/

/* ===================== 1. Colores ===================== */
:root {
  /* menu lateral (azul marino, igual en claro y en oscuro) */
  --sh-bg: #0f1e3d;
  --sh-line: #1c2d52;
  --sh-text: #dbe5f6;
  --sh-muted: #93a5c6;
  --sh-sec: #6f84aa;
  --sh-hover: rgba(255, 255, 255, .06);
  --sh-on: rgba(96, 165, 250, .18);
  --sh-bar: #60a5fa;
  --sh-card: rgba(255, 255, 255, .04);
  --sh-card-line: #22365f;
  --sh-w: 260px;       /* ancho del menu */
  --sh-w-mini: 72px;   /* ancho encogido */
}

/* Modo oscuro: variables viejas (main.css) y nuevas (.mwp) */
html[data-theme="dark"] {
  color-scheme: dark;
  --sh-bg: #0a1428;
  --sh-line: #18264a;
  --bg: #0b1220;
  --panel: #111a2b;
  --panel-2: #18233a;
  --panel-hover: #152036;
  --text: #dbe3ef;
  --text-secondary: #8a9ab3;
  --text-muted: #6b7a93;
  --border: #1f2b40;
  --border-light: #18233a;
  --primary-lighter: rgba(96, 165, 250, .15);
  --success-light: rgba(16, 185, 129, .15);
  --warning-light: rgba(245, 158, 11, .15);
  --danger-light: rgba(239, 68, 68, .15);
  --info-light: rgba(14, 165, 233, .15);
  --card-bg: #111a2b;
  --topbar-bg: #0f1828;
  --topbar-border: #1f2b40;
  --bg-color: #0b1220;
  --text-color: #dbe3ef;
  --border-color: #1f2b40;
}
html[data-theme="dark"] .mwp {
  --mwp-bg: #0b1220;
  --mwp-surface: #111a2b;
  --mwp-ink: #e8eef8;
  --mwp-text: #cbd5e1;
  --mwp-muted: #8a9ab3;
  --mwp-line: #23314a;
  --mwp-line-2: #18233a;
  --mwp-primary: #3b82f6;
  --mwp-primary-dark: #60a5fa;
  --mwp-warn: #fbbf24;
  --mwp-warn-bg: rgba(245, 158, 11, .12);
  --mwp-warn-line: rgba(245, 158, 11, .3);
  --mwp-ok: #34d399;
  --mwp-err: #f87171;
  --mwp-m-pppoe: #818cf8;
  --mwp-m-sq: #2dd4bf;
  --mwp-m-pcq: #fbbf24;
  --mwp-m-hs: #f472b6;
  --mwp-m-otro: #94a3b8;
  --mwp-code-bg: #060b16;
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }

/* ===================== 2. Menu lateral ===================== */
.sidebar {
  width: var(--sh-w);
  background: var(--sh-bg);
  border-right: 1px solid var(--sh-line);
  box-shadow: none;
  color: var(--sh-text);
  transition: width .2s ease, transform .3s ease;
}
.sidebar .logo { padding: 18px 18px 14px; border-bottom: 0; }
.sidebar .logo .logo-icon { width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8); box-shadow: 0 4px 12px rgba(37, 99, 235, .35); }
.sidebar .logo .logo-icon i { font-size: 18px; }
.sidebar .logo-text h1 { color: #fff; font-size: 16px; }
.sidebar .logo-text h1 span { color: inherit; }
.sidebar .logo-text p { color: var(--sh-muted); font-size: 11.5px; }

.sidebar .sidebar-menu { padding: 4px 10px 10px; }
.sidebar .sidebar-menu::-webkit-scrollbar-thumb { background: var(--sh-line); }

/* Titulos de grupo: Operacion / Configuracion */
.sidebar .menu > li.mw-sec { font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--sh-sec); padding: 14px 10px 6px; margin: 0; }

.sidebar .menu > li > a { color: var(--sh-text); padding: 8px 10px; gap: 11px; border-radius: 9px; font-weight: 500; }
.sidebar .menu > li > a i { color: var(--sh-muted); font-size: 14px; }
.sidebar .menu > li > a:hover { background: var(--sh-hover); color: #fff; }
.sidebar .menu > li > a.active { background: var(--sh-on); color: #fff; font-weight: 600; }
.sidebar .menu > li > a.active i { color: var(--sh-bar); }
.sidebar .menu > li > a.active::before,
.sidebar .submenu li a.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--sh-bar); }
/* El grupo de la pagina abierta queda resaltado */
.sidebar .has-submenu.active > a { color: #fff; }
.sidebar .has-submenu.active > a > i:first-child { color: var(--sh-bar); }
.sidebar .submenu-arrow { color: var(--sh-muted); opacity: 1; font-size: 10px !important; }

.sidebar .submenu { background: none; border-left: 1px solid var(--sh-line); border-radius: 0;
  margin: 2px 0 4px 19px; padding-left: 12px; animation: none; }
.sidebar .submenu li a { position: relative; color: var(--sh-muted); padding: 6px 10px; font-size: 13.5px;
  border-left: 0; border-radius: 8px; justify-content: flex-start; margin: 1px 0; }
.sidebar .submenu li a:hover { color: var(--sh-text); background: var(--sh-hover); border-left-color: transparent; }
.sidebar .submenu li a.active { color: #fff; background: var(--sh-on); font-weight: 600; border-left-color: transparent; }
.sidebar .submenu li a.active::before { left: -13px; }
.sidebar .submenu li a i { font-size: 12px; width: 16px; opacity: 1; color: inherit; }
.sidebar .submenu li a span:not(.menu-badge) { flex: 1; }

/* Contadores */
.sidebar .menu-badge { animation: none; margin-left: auto; min-width: 20px; height: 20px; padding: 0 7px; border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 20px; background: #ef4444; color: #fff; display: inline-flex; justify-content: center; }
.sidebar .menu-badge.warning { background: #f59e0b; }
.sidebar .menu-badge.n { background: var(--sh-hover); color: var(--sh-muted); font-weight: 600; }
.sidebar .menu-badge[hidden], .sidebar .menu-badge.cero { display: none; }

/* Pie: routers en linea + usuario */
.sidebar .sidebar-footer { background: none; border-top: 1px solid var(--sh-line); padding: 10px; }
.mw-routers { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 9px; font-size: 12.5px; margin-bottom: 8px;
  background: rgba(16, 185, 129, .12); color: #34d399; cursor: pointer; }
.mw-routers .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .25); }
.mw-routers.mal { background: rgba(239, 68, 68, .14); color: #fca5a5; }
.mw-routers.mal .dot { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, .25); }
.mw-routers.nada { background: var(--sh-hover); color: var(--sh-muted); }
.mw-routers.nada .dot { background: var(--sh-muted); box-shadow: none; }
.mw-routers span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-me { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 9px; }
.mw-me .av { width: 32px; height: 32px; border-radius: 50%; background: #6366f1; color: #fff; display: grid; place-items: center;
  font-weight: 600; font-size: 12.5px; flex: none; }
.mw-me .info { flex: 1; min-width: 0; }
.mw-me .info b { display: block; font-size: 13px; color: var(--sh-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-me .info small { display: block; font-size: 11.5px; color: var(--sh-muted); }
.mw-me button { border: 0; background: none; color: var(--sh-muted); cursor: pointer; padding: 7px; border-radius: 7px; font-size: 14px; }
.mw-me button:hover { background: var(--sh-hover); color: #fff; }
.sidebar .version-info { color: var(--sh-sec); font-size: 10.5px; padding: 4px 10px 0; }

/* ===================== 3. Menu encogido (boton ☰ en computadora) ===================== */
@media (min-width: 1025px) {
  .sidebar.collapsed { width: var(--sh-w-mini); }
  .sidebar.collapsed ~ .main-content, body.mw-mini .main-content { margin-left: var(--sh-w-mini); }
  body.mw-mini .topbar { left: var(--sh-w-mini); }
  .main-content { transition: margin-left .2s ease; }
  .sidebar.collapsed .logo { justify-content: center; padding-left: 0; padding-right: 0; }
  .sidebar.collapsed .logo-text,
  .sidebar.collapsed .menu > li > a > span,
  .sidebar.collapsed .submenu-arrow,
  .sidebar.collapsed .submenu,
  .sidebar.collapsed .mw-sec,
  .sidebar.collapsed .mw-routers span,
  .sidebar.collapsed .mw-me .info,
  .sidebar.collapsed .mw-me .salir,
  .sidebar.collapsed .version-info { display: none !important; }
  .sidebar.collapsed .menu > li > a { justify-content: center; }
  .sidebar.collapsed .menu > li > a .menu-badge:not(.n) { display: block; position: absolute; top: 5px; right: 9px;
    min-width: 0; width: 8px; height: 8px; padding: 0; font-size: 0; }
  .sidebar.collapsed .mw-routers, .sidebar.collapsed .mw-me { justify-content: center; }
  .sidebar.collapsed .mw-me { flex-direction: column; gap: 4px; }
}

/* ===================== 4. Barra de arriba ===================== */
.sidebar-toggle { display: flex; align-items: center; } /* antes solo salia en el celular: ahora tambien encoge el menu en la computadora */
.topbar { background: var(--topbar-bg); border-bottom: 1px solid var(--topbar-border); }
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .topbar .breadcrumb,
html[data-theme="dark"] .sidebar-toggle,
html[data-theme="dark"] .topbar-item { color: var(--text); }
html[data-theme="dark"] .search-bar,
html[data-theme="dark"] .isp-selector { background: var(--panel-2); border-color: var(--border); color: var(--text); }
html[data-theme="dark"] .search-bar input { background: transparent; color: var(--text); }
html[data-theme="dark"] .user-dropdown,
html[data-theme="dark"] .notification-panel { background: var(--panel); border-color: var(--border); color: var(--text); }
html[data-theme="dark"] .user-dropdown a,
html[data-theme="dark"] .notification-item { color: var(--text); }
html[data-theme="dark"] .notification-item.unread { background: rgba(96, 165, 250, .08); }
html[data-theme="dark"] .notification-header { border-color: var(--border); }

/* ===================== 5. Paginas con el estilo nuevo en modo oscuro =====================
   Los fondos claros fijos de mw-ui.css se pasan a variables con parche_mwui_oscuro.py; aqui solo los campos. */
html[data-theme="dark"] .mwp input:not([type=checkbox]):not([type=radio]),
html[data-theme="dark"] .mwp select,
html[data-theme="dark"] .mwp textarea { background: var(--mwp-surface) !important; color: var(--mwp-text); border-color: var(--mwp-line); }
html[data-theme="dark"] .mwp input::placeholder,
html[data-theme="dark"] .mwp textarea::placeholder { color: #5b6b85; }
html[data-theme="dark"] .mwp .mwl-map { background: #0e1729; }
html[data-theme="dark"] .mwp .mwp-switch input::after { background: #e2e8f0; }

/* Paginas viejas: lo minimo para que no deslumbren (se rediseñan una por una) */
html[data-theme="dark"] .card,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .finanzas-container,
html[data-theme="dark"] .accion-rapida,
html[data-theme="dark"] .page-btn { background: var(--panel); color: var(--text); border-color: var(--border); }
html[data-theme="dark"] table td { color: var(--text); }
html[data-theme="dark"] table tbody tr { border-color: var(--border); }
html[data-theme="dark"] .modal-header { border-color: var(--border); }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { background-color: var(--panel); color: var(--text); border-color: var(--border); }

/* ===================== 6. Celular ===================== */
@media (max-width: 1024px) {
  .sidebar { box-shadow: 0 10px 40px rgba(2, 6, 23, .45); }
}

/* mw-cobros: celular */
/* componentes.css (viejo) dejaba 70px vacios a la izquierda en pantallas pequenas; el menu nuevo se abre encima */
@media (max-width: 1024px) {
  body .main-content { margin-left: 0; width: auto; }
}
