/* =====================================================
   NEXUM OMNIA — NEXUM Console
   Sistema visual del sitio corporativo
   (copia de src/global.css v1.0 de nexumomnia.com y del
   css del Portal de Clientes; mismos valores, sin cambios
   de identidad) + componentes propios de la consola
   (Etapa 8, NEXUM Core v0.7.0)
   ===================================================== */

/* 1. IDENTIDAD Y VARIABLES */

:root {
  color-scheme: dark;

  /* Colores corporativos */
  --nexum-blue: #004c97;
  --nexum-teal: #00b5ad;
  --nexum-gradient: linear-gradient(
    115deg,
    var(--nexum-blue),
    var(--nexum-teal)
  );

  /* Acento funcional (aprobado 2026-11-13): SOLO errores,
     vencimientos, estados críticos y bloqueos administrativos.
     Nunca decorativo. */
  --nexum-danger: #d95f5f;
  --nexum-danger-bg: rgba(217, 95, 95, 0.12);
  --nexum-danger-border: rgba(217, 95, 95, 0.35);

  /* Superficies */
  --bg-primary: #06101a;
  --bg-secondary: #0a1724;
  --bg-tertiary: #102131;
  --bg-card: rgba(15, 32, 47, 0.78);

  /* Texto */
  --text-primary: #f4f8fc;
  --text-secondary: #a8b8c8;
  --text-muted: #74899b;

  /* Bordes y efectos */
  --border-color: rgba(164, 196, 220, 0.14);
  --border-highlight: rgba(0, 181, 173, 0.35);
  --shadow-card: 0 18px 50px rgba(0, 0, 0, 0.22);

  /* Dimensiones */
  --container-width: 1200px;
  --header-height: 78px;
  --section-spacing: 100px;

  /* Radios */
  --radius-small: 8px;
  --radius-medium: 14px;
  --radius-large: 22px;
  --radius-pill: 999px;

  /* Transiciones */
  --transition-fast: 180ms ease;
  --transition-normal: 280ms ease;
}

/* 2. REINICIO GENERAL */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 20px);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family:
    Inter,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  color: inherit;
}

::selection {
  background: rgba(0, 181, 173, 0.3);
  color: #ffffff;
}

/* 3. ESTRUCTURA */

.container {
  width: min(
    calc(100% - 48px),
    var(--container-width)
  );
  margin-inline: auto;
}

.section {
  padding-block: var(--section-spacing);
}

.section-heading {
  max-width: 760px;
  margin-bottom: 48px;
}

.section-heading h2 {
  margin: 12px 0 18px;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.section-heading p {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

/* 4. TIPOGRAFÍA */

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-primary);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(2.5rem, 6vw, 4.6rem);
}

h2 {
  font-size: clamp(2rem, 4vw, 3rem);
}

p {
  color: var(--text-secondary);
}

.text-gradient {
  background: var(--nexum-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--nexum-teal);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

/* 5. BOTONES */

.btn {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 23px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  background: none;
  font-size: 0.94rem;
  font-weight: 650;
  text-align: center;
  cursor: pointer;
  transition:
    background var(--transition-normal),
    border-color var(--transition-normal),
    transform var(--transition-normal),
    box-shadow var(--transition-normal);
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn-primary {
  background: var(--nexum-gradient);
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 181, 173, 0.15);
}

.btn-primary:hover {
  box-shadow: 0 12px 30px rgba(0, 181, 173, 0.25);
}

.btn-secondary {
  border-color: var(--border-color);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-primary);
}

.btn-secondary:hover {
  border-color: var(--border-highlight);
  background: rgba(0, 181, 173, 0.08);
}

.btn-danger {
  border-color: var(--nexum-danger-border);
  background: var(--nexum-danger-bg);
  color: var(--nexum-danger);
}

.btn-danger:hover {
  background: rgba(217, 95, 95, 0.2);
}

.btn-sm {
  min-height: 36px;
  padding: 8px 14px;
  font-size: 0.86rem;
}

.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--nexum-teal);
  font-weight: 650;
  cursor: pointer;
  transition: gap var(--transition-fast);
}

.btn-text:hover {
  gap: 13px;
}

.btn-text:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* 6. TARJETAS */

.card {
  padding: 28px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-medium);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  transition:
    transform var(--transition-normal),
    border-color var(--transition-normal),
    background var(--transition-normal);
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-highlight);
  background: var(--bg-tertiary);
}

.card h2,
.card h3 {
  margin-top: 0;
}

/* 7. CAMPOS Y FORMULARIOS */

.form-control {
  width: 100%;
  min-height: 48px;
  padding: 12px 15px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-small);
  outline: none;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  border-color: var(--nexum-teal);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

select.form-control {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

textarea.form-control {
  min-height: 110px;
  resize: vertical;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 650;
}

.field {
  margin-bottom: 18px;
}

.field-error {
  margin: 6px 0 0;
  color: var(--nexum-danger);
  font-size: 0.86rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
}

.form-hint {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

/* 8. FONDOS Y SEPARADORES */

.surface-secondary {
  background: var(--bg-secondary);
}

.surface-tertiary {
  background: var(--bg-tertiary);
}

.gradient-line {
  height: 1px;
  border: 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--nexum-teal),
    transparent
  );
  opacity: 0.45;
}

/* 9. ACCESIBILIDAD */

:focus-visible {
  outline: 2px solid var(--nexum-teal);
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* 10. ENCABEZADO DE LA CONSOLA (mismo criterio que Header.astro) */

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  background: rgba(6, 16, 26, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(16px);
}

.header-container {
  width: min(1300px, calc(100% - 40px));
  min-height: 92px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  grid-template-areas: "brand . toggle chip";
  column-gap: 24px;
  align-items: center;
  padding-top: 12px;
  padding-bottom: 12px;
  position: relative;
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  justify-self: start;
}

.brand-logo {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: contain;
  object-position: left center;
}

.brand-console {
  display: inline-flex;
  align-items: center;
  margin-left: 12px;
  padding: 4px 12px;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-pill);
  background: rgba(0, 181, 173, 0.1);
  color: var(--nexum-teal);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.main-navigation {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px 22px 24px;
  background: #06101a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  z-index: 50;
}

.main-navigation.is-open {
  display: flex;
}

.nav-link {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: #dce7f2;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: #00b5ad;
  background: rgba(0, 181, 173, 0.14);
  border-color: rgba(0, 181, 173, 0.45);
}

.menu-toggle {
  grid-area: toggle;
  display: block;
  width: 42px;
  height: 42px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  height: 2px;
  margin: 5px 0;
  background: #fff;
}

.user-chip {
  grid-area: chip;
  display: flex;
  align-items: center;
  gap: 16px;
  padding-left: 22px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 0.84rem;
  flex-shrink: 0;
}

.user-chip strong {
  color: var(--text-primary);
}

.user-chip button {
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--nexum-teal);
  font-size: 0.84rem;
  font-weight: 650;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.user-chip button:hover {
  background: rgba(0, 181, 173, 0.14);
  border-color: rgba(0, 181, 173, 0.45);
}

/* 11. PIE DE LA CONSOLA (mismo criterio que Footer.astro) */

.nexum-footer {
  background: #050d15;
  border-top: 1px solid rgba(164, 196, 220, 0.13);
}

.footer-bottom {
  padding: 22px 24px;
}

.footer-bottom-container {
  width: min(100%, 1200px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
}

.footer-bottom p {
  margin: 0;
  color: #74899b;
  font-size: 0.78rem;
}

.footer-bottom a {
  color: #00b5ad;
  font-weight: 650;
}

/* 12. COMPONENTES PROPIOS DE LA CONSOLA */

.grid {
  display: grid;
  gap: 22px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Píldora de estado: radio de píldora, texto siempre visible
   (el color nunca es la única señal). */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.pill-ok {
  border-color: var(--border-highlight);
  background: rgba(0, 181, 173, 0.1);
  color: var(--nexum-teal);
}

.pill-danger {
  border-color: var(--nexum-danger-border);
  background: var(--nexum-danger-bg);
  color: var(--nexum-danger);
}

/* Distintivo de rol. */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-pill);
  background: rgba(0, 181, 173, 0.08);
  color: var(--nexum-teal);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.role-badge.platform {
  border-color: rgba(0, 76, 151, 0.6);
  background: rgba(0, 76, 151, 0.25);
  color: #7db8e8;
}

/* Tarjeta de indicador (dashboard administrativo). */
.stat-card {
  padding: 24px;
}

.stat-number {
  display: block;
  margin: 4px 0 2px;
  font-size: 2.2rem;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Mensajes de aviso y error. */
.alert {
  padding: 14px 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-small);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.94rem;
}

.alert-danger {
  border-color: var(--nexum-danger-border);
  background: var(--nexum-danger-bg);
  color: #f3c1c1;
}

.alert-ok {
  border-color: var(--border-highlight);
  background: rgba(0, 181, 173, 0.1);
  color: var(--text-primary);
}

.alert p {
  margin: 0;
  color: inherit;
}

/* Estado vacío: nunca datos simulados. */
.empty-state {
  padding: 32px 28px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-medium);
  text-align: center;
}

.empty-state p {
  margin: 0;
}

/* Indicador de carga. */
.loading {
  padding: 48px 0;
  color: var(--text-muted);
  text-align: center;
}

/* Filas de datos (detalle de registro). */
.data-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.data-row:last-child {
  border-bottom: 0;
}

.data-row dt {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.data-row dd {
  margin: 0;
  text-align: right;
}

/* Historial de solicitudes. */
.history {
  margin: 0;
  padding: 0;
  list-style: none;
}

.history li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.history li:last-child {
  border-bottom: 0;
}

.history .history-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Selector de organización. */
.org-switcher {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  padding: 14px 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-medium);
  background: var(--bg-card);
}

.org-switcher label {
  margin: 0;
}

.org-switcher select {
  min-width: 220px;
}

/* Pantalla de acceso. */
.login-wrap {
  display: flex;
  justify-content: center;
  padding: 80px 0;
}

.login-card {
  width: min(100%, 460px);
}

.login-card .brand-logo {
  width: 210px;
  height: 66px;
  margin: 0 auto 24px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
  text-align: center;
}

.login-card .login-sub {
  margin: 0 0 28px;
  text-align: center;
}

/* Tablas de datos (listados administrativos). */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-medium);
  background: var(--bg-card);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  vertical-align: middle;
}

.data-table thead th {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: rgba(0, 181, 173, 0.04);
}

.data-table td.actions {
  white-space: nowrap;
  text-align: right;
}

/* Barra de herramientas: filtros y acciones de una lista. */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 22px;
  padding: 16px 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-medium);
  background: var(--bg-card);
}

.toolbar .field {
  margin-bottom: 0;
  min-width: 170px;
}

.toolbar .spacer {
  flex: 1;
}

/* Pestañas dentro de una vista de detalle. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 26px;
  padding-bottom: 0;
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  padding: 10px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 650;
  cursor: pointer;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  border-bottom-color: var(--nexum-teal);
  color: var(--nexum-teal);
}

/* Diálogo de confirmación. */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 8, 13, 0.78);
}

.modal-card {
  width: min(100%, 480px);
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 28px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-medium);
  background: var(--bg-tertiary);
  box-shadow: var(--shadow-card);
}

.modal-card h3 {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Fila de acciones en una tarjeta. */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

/* Nota de permiso: explica por qué una acción no está disponible. */
.permission-note {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.86rem;
}

/* 13. RESPONSIVE */

@media (max-width: 1100px) {
  .header-container {
    gap: 14px;
  }

  .main-navigation {
    gap: 11px;
  }

  .brand-logo {
    width: 110px;
    height: 110px;
  }

  .nav-link {
    font-size: 12px;
  }

  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 850px) {
  .header-container {
    min-height: 82px;
    display: flex;
    flex-wrap: wrap;
    padding-bottom: 12px;
  }

  .brand-logo {
    width: 96px;
    height: 96px;
  }

  .menu-toggle {
    display: block;
  }

  .main-navigation {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    align-items: stretch;
    flex-direction: column;
    padding: 18px 22px 24px;
    background: #06101a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .main-navigation.is-open {
    display: flex;
  }

  .nav-link {
    display: block;
    padding: 10px 0;
    font-size: 14px;
  }

  .user-chip {
    order: 3;
    width: 100%;
    padding: 10px 0 0;
    border-left: 0;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 68px;
    --section-spacing: 68px;
  }

  .container {
    width: min(calc(100% - 36px), var(--container-width));
  }

  .section-heading {
    margin-bottom: 32px;
  }

  .card {
    padding: 22px;
  }

  .btn {
    padding: 11px 18px;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .toolbar .field {
    min-width: 0;
    flex: 1 1 45%;
  }
}

@media (max-width: 480px) {
  .container {
    width: calc(100% - 30px);
  }
}

@media (max-width: 380px) {
  .brand-logo {
    width: 84px;
    height: 84px;
  }
}
