/*
 * Desarrollado por: Luis Carlos
 * nexora.css — Hoja de estilos base de NEXORA ERP
 *
 * Tokens y componentes tomados directamente de nexora-erp-mockup.html
 * (fuente de verdad visual del proyecto). No se trae ningún estilo del
 * sistema anterior — ni colores, ni tipografías, ni nombres de clase.
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: dark;
  --bg:         #070D16;
  --panel:      #0C1522;
  --panel-alt:  #101B2A;
  --panel-hi:   #132133;
  --steel:      #1C2A3B;
  --steel-soft: #152232;
  --cyan:       #3FC7D9;
  --cyan-soft:  #2E97A6;
  --cyan-wash:  rgba(63,199,217,0.12);
  --amber:      #E0A73E;
  --text:       #E7EDF4;
  --text-dim:   #8CA0B3;
  --text-faint: #546679;
  --ok:         #4CC38A;
  --danger:     #E4685F;

  --font-display: 'Manrope', sans-serif;
  --font-body:    'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.02) inset, 0 12px 28px -14px rgba(0,0,0,0.55);
  --panel-rgb: 12,21,34;
}

/* ================= MODO CLARO =================
 * Mismos nombres de variable, valores distintos — ningún componente
 * necesita saber en qué tema está, solo usa var(--x) y el navegador
 * resuelve el valor correcto según la clase en <html>.
 * Los colores de marca (cyan/amber/ok/danger) se mantienen iguales en
 * ambos temas a propósito — es la identidad de NEXORA, no debe
 * "cambiar de personalidad" entre modos. */
html.tema-claro {
  color-scheme: light;
  --bg:         #EEF3F6;
  --panel:      #FCFEFF;
  --panel-alt:  #F2F6F8;
  --panel-hi:   #FFFFFF;
  --steel:      #D9E2E8;
  --steel-soft: #E6ECF0;
  --cyan-wash:  rgba(20,150,170,0.10);
  --text:       #16222C;
  --text-dim:   #55697A;
  --text-faint: #8B99A3;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.6) inset, 0 10px 26px -16px rgba(23,41,54,0.18);
  --panel-rgb: 255,255,255;
}
html.tema-claro .card:hover { box-shadow: 0 16px 34px -16px rgba(23,41,54,0.22); }
html.tema-claro ::-webkit-scrollbar-thumb { background: var(--steel); }
html.tema-claro ::selection { color: #FFFFFF; }

html, body { background: var(--bg); color: var(--text); font-family: var(--font-body); width: 100%; min-height: 100vh; -webkit-font-smoothing: antialiased; }
body {
  overscroll-behavior-y: contain;
  background-image:
    radial-gradient(circle at 12% 8%, rgba(63,199,217,0.05), transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(63,199,217,0.03), transparent 45%),
    linear-gradient(var(--steel-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--steel-soft) 1px, transparent 1px);
  background-size: auto, auto, 64px 64px, 64px 64px;
  background-position: 0 0, 0 0, -1px -1px, -1px -1px;
}
::selection { background: var(--cyan); color: #00232A; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--panel); }
::-webkit-scrollbar-thumb { background: var(--steel); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan-soft); }
a { color: inherit; text-decoration: none; touch-action: manipulation; }
button {
  font-family: inherit;
  -webkit-appearance: none; appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
select {
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238CA0B3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input:not([type="checkbox"]):not([type="radio"]), textarea { -webkit-appearance: none; appearance: none; -webkit-tap-highlight-color: transparent; }
input[type="checkbox"], input[type="radio"] { -webkit-tap-highlight-color: transparent; }
code, .mono, td.mono { font-family: var(--font-mono); }
h1, h2, h3 { font-family: var(--font-display); }

/* ================= BRAND MARK ================= */
.mark svg { display: block; width: 100%; height: 100%; }

/* ================= LOGIN ================= */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 80px 20px 40px; }
.login-card {
  width: 420px; max-width: 100%;
  background: linear-gradient(175deg, var(--panel-hi), var(--panel));
  border: 1px solid var(--steel);
  border-radius: var(--radius-lg);
  padding: 42px 38px 32px;
  box-shadow: var(--shadow-card);
  clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 0 100%);
}
.login-mark { width: 52px; height: 52px; margin: 0 auto 20px; }
.login-title { text-align: center; font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: .01em; color: var(--text); }
.login-title span { color: var(--cyan); }
.login-sub { text-align: center; font-size: 13px; color: var(--text-dim); margin-top: 5px; }
.login-divider { height: 1px; background: var(--steel); margin: 24px 0 22px; }
.login-secure { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 18px; font-size: 12px; color: var(--text-dim); }
.login-secure svg { width: 14px; height: 14px; color: var(--cyan-soft); flex: none; }
.login-foot { margin-top: 26px; text-align: center; font-size: 11.5px; color: var(--text-faint); }

/* ================= CAMPOS / FORMULARIOS ================= */
.field { margin-bottom: 17px; position: relative; }
.field label { display: block; font-weight: 600; font-size: 12.5px; color: var(--text-dim); margin-bottom: 7px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--steel); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font-body); font-size: 14px; padding: 11px 13px; outline: none; transition: .15s;
}
.nx-select {
  background: var(--panel); border: 1px solid var(--steel); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font-body); font-size: 13.5px; font-weight: 600;
  padding: 10px 34px 10px 13px; outline: none; cursor: pointer; transition: .15s;
}
.nx-select:hover { border-color: var(--cyan-soft); }
.nx-select:focus { border-color: var(--cyan-soft); box-shadow: 0 0 0 3px var(--cyan-wash); }
.nx-tab {
  background: transparent; border: 1px solid var(--steel); border-radius: var(--radius-sm);
  color: var(--text-dim); font-family: var(--font-body); font-size: 13px; font-weight: 600;
  padding: 8px 16px; cursor: pointer; transition: .15s;
}
.nx-tab:hover { border-color: var(--cyan-soft); color: var(--text); }
.nx-tab.activo { background: var(--cyan-wash); border-color: var(--cyan-soft); color: var(--cyan); }
.field select { padding-right: 34px; }
.field input::placeholder, .field textarea::placeholder { color: var(--text-faint); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--cyan-soft); box-shadow: 0 0 0 3px var(--cyan-wash); }
.field input.has-toggle { padding-right: 42px; }
.field-toggle {
  position: absolute; right: 11px; bottom: 11px; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); cursor: pointer; background: none; border: none; padding: 0;
}
.field-toggle:hover { color: var(--cyan-soft); }
.field-toggle svg { width: 18px; height: 18px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); }
.checkbox-row input[type="checkbox"] { width: auto; accent-color: var(--cyan); }
.link { color: var(--cyan-soft); font-weight: 600; }
.link:hover { color: var(--cyan); text-decoration: underline; }

.alerta-error, .alerta-exito {
  display: none; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px;
}
.alerta-error.visible, .alerta-exito.visible { display: block; }
.alerta-error { background: rgba(228,104,95,0.1); border: 1px solid rgba(228,104,95,0.3); color: var(--danger); }
.alerta-exito { background: rgba(76,195,138,0.1); border: 1px solid rgba(76,195,138,0.3); color: var(--ok); }

/* ================= BOTONES ================= */
.btn-primary {
  background: var(--cyan); color: #00232A; border: none; border-radius: var(--radius-sm);
  font-family: var(--font-display); font-weight: 700; font-size: 14.5px; letter-spacing: .2px;
  padding: 13px; cursor: pointer; transition: .15s;
}
.btn-primary:hover { background: #57D2E3; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary.full { width: 100%; }

.btn-secundario {
  background: var(--panel-alt); color: var(--text-dim); border: 1px solid var(--steel); border-radius: var(--radius-sm);
  font-size: 13px; padding: 11px 18px; cursor: pointer; transition: .15s;
}
.btn-secundario:hover { border-color: var(--cyan-soft); color: var(--text); }
.btn-peligro { color: var(--danger); }
.btn-peligro:hover { border-color: var(--danger); color: var(--danger); }

.btn-icono {
  background: none; border: none; cursor: pointer; color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center; padding: 6px; border-radius: var(--radius-sm); transition: .15s;
}
.btn-icono:hover { color: var(--cyan); background: var(--panel-alt); }

.spinner {
  display: inline-block; width: 13px; height: 13px; margin-right: 6px;
  border: 2px solid rgba(0,35,42,0.35); border-top-color: #00232A; border-radius: 50%; animation: nx-girar .7s linear infinite; vertical-align: -2px;
}
@keyframes nx-girar { to { transform: rotate(360deg); } }

/* ================= LAYOUT: sidebar + topbar + footer ================= */
.app { min-height: 100vh; }

.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 230px; background: var(--panel); border-right: 1px solid var(--steel); display: flex; flex-direction: column; z-index: 30; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 11px; height: 64px; padding: 0 22px; border-bottom: 1px solid var(--steel); flex: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 15px; letter-spacing: .01em; line-height: 1.15; }
.brand-name span { display: block; font-weight: 500; font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }
#brandNombreTexto { font-weight: 800; font-size: 15px; color: var(--text); margin-top: 0; letter-spacing: .01em; }

.nav-group { padding: 0 14px; margin-bottom: 20px; }
.brand + .nav-group { margin-top: 20px; }
.nav-label { font-weight: 700; font-size: 10.5px; color: var(--text-faint); letter-spacing: .08em; text-transform: uppercase; padding: 0 10px; margin-bottom: 8px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; color: var(--text-dim); font-size: 13.5px; font-weight: 500; border-radius: var(--radius-sm); transition: .15s; cursor: pointer; }
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-item:hover { color: var(--text); background: var(--panel-alt); }
.nav-item.activo { color: var(--text); background: var(--cyan-wash); box-shadow: inset 2px 0 0 var(--cyan); }
.nav-item.activo svg { opacity: 1; color: var(--cyan); }

.sidebar-foot { margin-top: auto; height: 42px; display: flex; align-items: center; padding: 0 22px; border-top: 1px solid var(--steel); flex: none; }
.op-status { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }

.main { margin-left: 230px; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { display: flex; flex-direction: column; background: rgba(var(--panel-rgb),0.7); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 10; padding-top: env(safe-area-inset-top, 0px); }
.topbar-row1 { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; padding: 0 26px; border-bottom: 1px solid var(--steel); }
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.menu-btn { display: none; width: 34px; height: 34px; align-items: center; justify-content: center; border: 1px solid var(--steel); border-radius: var(--radius-sm); color: var(--text-dim); cursor: pointer; flex: none; }
.menu-btn svg { width: 18px; height: 18px; display: block; }
.topbar-title { font-family: var(--font-display); font-weight: 800; font-size: 18px; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 16px; flex: none; }

.icon-btn { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--steel); border-radius: var(--radius-sm); color: var(--text-dim); cursor: pointer; position: relative; transition: .15s; }
.icon-btn:hover { color: var(--cyan-soft); border-color: var(--cyan-soft); }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--steel); }
.avatar { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--steel-soft); border: 1px solid var(--steel); display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; font-size: 12px; color: var(--cyan); overflow: hidden; flex-shrink: 0; }
.user-name { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.user-role { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-dim); }

.user-menu { position: relative; }
.user-chip-btn { background: none; border: none; cursor: pointer; transition: .15s; border-radius: var(--radius-sm); padding: 4px 6px 4px 14px; color: inherit; font-family: inherit; }
.user-chip-btn:hover { background: var(--panel-alt); }
.user-menu-panel {
  position: absolute; top: calc(100% + 10px); right: 0; min-width: 210px; z-index: 40;
  background: linear-gradient(175deg, var(--panel-hi), var(--panel)); border: 1px solid var(--steel);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 6px;
}
.user-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: var(--radius-sm);
  background: none; border: none; color: var(--text-dim); font-size: 13px; font-family: var(--font-body);
  text-align: left; cursor: pointer; transition: .15s;
}
.user-menu-item svg { flex-shrink: 0; opacity: .85; }
.user-menu-item:hover { background: var(--panel-alt); color: var(--text); }
.user-menu-item-danger:hover { background: rgba(228,104,95,0.1); color: var(--danger); }
.user-menu-divider { height: 1px; background: var(--steel); margin: 6px 4px; }

.app-footer { position: fixed; bottom: 0; left: 230px; right: 0; z-index: 8; height: 42px; display: flex; align-items: center; justify-content: space-between; padding: 0 26px; padding-bottom: env(safe-area-inset-bottom, 0px); background: rgba(var(--panel-rgb),0.92); backdrop-filter: blur(8px); border-top: 1px solid var(--steel); box-sizing: content-box; }
.footer-left, .footer-right { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); }
.footer-right b { color: var(--text); font-weight: 600; }

.content { padding: 24px 26px calc(70px + env(safe-area-inset-bottom, 0px)); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 12px; }
.section-head h1, .section-head h2 { font-weight: 700; font-size: 18px; }

.sidebar-backdrop { display: none; }
@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .app-footer { left: 0; }
  .menu-btn { display: flex; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(4,8,14,0.6); z-index: 25; }
  .footer-left { display: none; }
}

/* ================= TARJETAS RESUMEN / PANELES ================= */
.cards-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
@media (max-width: 980px) { .cards-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 620px) { .cards-grid { grid-template-columns: 1fr; } }

.card {
  background: linear-gradient(165deg, var(--panel-hi), var(--panel)); border: 1px solid var(--steel); border-radius: var(--radius-md);
  border-left-width: 3px; padding: 18px 18px 16px 16px; position: relative; box-shadow: var(--shadow-card);
  transition: transform .3s cubic-bezier(.22,.8,.3,1), box-shadow .3s ease, border-color .25s ease;
}
.card:hover { transform: translateY(-5px); box-shadow: 0 16px 34px -14px rgba(0,0,0,0.65); }
.card.c-cyan   { border-left-color: var(--cyan); }
.card.c-amber  { border-left-color: var(--amber); }
.card.c-ok     { border-left-color: var(--ok); }
.card.c-danger { border-left-color: var(--danger); }
.card.c-cyan:hover   { border-color: var(--cyan);   box-shadow: 0 16px 34px -14px rgba(0,0,0,0.65), 0 0 0 1px rgba(63,199,217,0.25), 0 0 22px -6px rgba(63,199,217,0.45); }
.card.c-amber:hover  { border-color: var(--amber);  box-shadow: 0 16px 34px -14px rgba(0,0,0,0.65), 0 0 0 1px rgba(224,167,62,0.25), 0 0 22px -6px rgba(224,167,62,0.45); }
.card.c-ok:hover     { border-color: var(--ok);     box-shadow: 0 16px 34px -14px rgba(0,0,0,0.65), 0 0 0 1px rgba(76,195,138,0.25), 0 0 22px -6px rgba(76,195,138,0.45); }
.card.c-danger:hover { border-color: var(--danger); box-shadow: 0 16px 34px -14px rgba(0,0,0,0.65), 0 0 0 1px rgba(228,104,95,0.25), 0 0 22px -6px rgba(228,104,95,0.45); }
.card-value { font-family: var(--font-display); font-weight: 800; font-size: 27px; }
.card-label { font-size: 12px; color: var(--text-dim); margin-top: 3px; }

.panel-box { background: var(--panel); border: 1px solid var(--steel); border-radius: var(--radius-md); padding: 20px 20px 18px; box-shadow: var(--shadow-card); }
.panel-box-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.panel-box-head h3 { font-weight: 700; font-size: 14px; }

/* ================= TABLA ================= */
.nx-tabla-wrap { background: var(--panel); border: 1px solid var(--steel); border-radius: var(--radius-md); overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
table.nx-tabla { width: 100%; min-width: 640px; border-collapse: collapse; }
.nx-tabla th { text-align: left; font-weight: 600; font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; padding: 12px 16px; border-bottom: 1px solid var(--steel); background: var(--panel-alt); }
.nx-tabla td { padding: 12px 16px; font-size: 12.5px; border-bottom: 1px solid var(--steel-soft); color: var(--text-dim); }
.nx-tabla tbody tr:hover { background: var(--panel-alt); }
.nx-tabla .col-acciones { text-align: right; white-space: nowrap; }

.tag { font-family: var(--font-mono); font-size: 10px; padding: 3px 9px; border-radius: 999px; display: inline-block; }
.tag-ok { color: var(--ok); background: rgba(76,195,138,0.1); border: 1px solid rgba(76,195,138,0.28); }
.tag-warn { color: var(--amber); background: rgba(224,167,62,0.1); border: 1px solid rgba(224,167,62,0.28); }
.tag-danger { color: var(--danger); background: rgba(228,104,95,0.1); border: 1px solid rgba(228,104,95,0.28); }
.tag-cyan { color: var(--cyan); background: var(--cyan-wash); border: 1px solid rgba(63,199,217,0.28); }
.tag-neutral { color: var(--text-dim); background: var(--panel-alt); border: 1px solid var(--steel); }

/* ================= MODAL ================= */
.nx-modal-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(4,8,14,0.72); display: flex; align-items: center; justify-content: center; padding: 20px; }
.nx-modal-overlay.oculto { display: none; }
.nx-modal {
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  background: linear-gradient(175deg, var(--panel-hi), var(--panel)); border: 1px solid var(--steel);
  border-radius: var(--radius-lg); padding: 28px 26px; box-shadow: var(--shadow-card);
}
.nx-modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.nx-modal-header h2, .nx-modal-header h3 { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.nx-divisor { height: 1px; background: var(--steel); margin: 18px 0; }

.nx-vacio { text-align: center; padding: 48px 20px; color: var(--text-faint); }

.oculto { display: none !important; }
