/* ============================================
   NEXUS - Global Styles (Eye-Care Edition)
   Sistema visual diseñado para trabajo prolongado
   ============================================ */

/* ============================================
   VARIABLES CSS - Paleta Eye-Care
   Evitamos contraste extremo (blanco puro sobre negro puro)
   ============================================ */
:root {
    /* === FONDOS === */
    --nexus-bg-base: #0B0E14;        /* Azul medianoche oscuro - base de toda la app */
    --nexus-bg-surface: #161B22;     /* Gris azulado - paneles y contenedores */
    --nexus-bg-elevated: #21262D;    /* Gris medio - elementos flotantes/modales */

    /* === COLORES DE MARCA === */
    --nexus-primary: #9D50FF;        /* Violeta vibrante - Primary Glow */
    --nexus-primary-dark: #7B3FCC;
    --nexus-primary-light: #B87FFF;
    --nexus-secondary: #4DE8FF;      /* Cian eléctrico - indicadores IA */
    --nexus-secondary-dark: #3CB8CC;
    --nexus-secondary-light: #7FFFFF;

    /* === GRADIENTE DE ACENTO (solo para logo y detalles específicos) === */
    --nexus-gradient: linear-gradient(45deg, #4DE8FF, #9D50FF);

    /* === TEXTO (sin blanco puro) === */
    --nexus-text: #E6EDF3;           /* Gris muy claro */
    --nexus-text-muted: #8B949E;     /* Gris medio */
    --nexus-text-disabled: #484F58;  /* Gris oscuro */

    /* === BORDES Y LÍNEAS === */
    --nexus-border: #30363D;         /* Borde estándar (1px, estado reposo) */
    --nexus-border-subtle: #21262D;  /* Borde sutil */
    --nexus-divider: #21262D;        /* Divisores */

    /* === ESTADOS === */
    --nexus-success: #3FB950;
    --nexus-warning: #D29922;
    --nexus-error: #F85149;
    --nexus-info: #4DE8FF;

    /* === GLOW (Luz ambiental) === */
    --nexus-glow-primary: rgba(157, 80, 255, 0.15);
    --nexus-glow-secondary: rgba(77, 232, 255, 0.15);
    --nexus-glow-ambient: rgba(157, 80, 255, 0.06);

    /* === TRANSICIONES === */
    --nexus-transition: 0.2s ease;
    --nexus-transition-slow: 0.3s ease;

    /* === TAMAÑOS DE FUENTE (escala base) === */
    --nexus-font-scale: 1;
    --nexus-font-xs: calc(0.75rem * var(--nexus-font-scale));
    --nexus-font-sm: calc(0.8125rem * var(--nexus-font-scale));
    --nexus-font-base: calc(0.875rem * var(--nexus-font-scale));
    --nexus-font-md: calc(1rem * var(--nexus-font-scale));
    --nexus-font-lg: calc(1.125rem * var(--nexus-font-scale));
    --nexus-font-xl: calc(1.25rem * var(--nexus-font-scale));
    --nexus-font-2xl: calc(1.5rem * var(--nexus-font-scale));
}

/* === ESCALAS DE TAMAÑO DE FUENTE === */
html.font-scale-compact {
    --nexus-font-scale: 0.85;
}

html.font-scale-small {
    --nexus-font-scale: 0.92;
}

html.font-scale-normal {
    --nexus-font-scale: 1;
}

html.font-scale-large {
    --nexus-font-scale: 1.1;
}

/* ============================================
   BASE STYLES
   ============================================ */
html, body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: var(--nexus-font-base);
    background-color: var(--nexus-bg-base);
    color: var(--nexus-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Aplicar escala a elementos MudBlazor */
.mud-typography-body1 {
    font-size: var(--nexus-font-base) !important;
}

.mud-typography-body2 {
    font-size: var(--nexus-font-sm) !important;
}

.mud-typography-caption {
    font-size: var(--nexus-font-xs) !important;
}

.mud-typography-h6 {
    font-size: var(--nexus-font-lg) !important;
}

.mud-typography-h5 {
    font-size: var(--nexus-font-xl) !important;
}

.mud-typography-h4 {
    font-size: var(--nexus-font-2xl) !important;
}

/* Scrollbar estilizada */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--nexus-bg-base);
}

::-webkit-scrollbar-thumb {
    background: var(--nexus-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484F58;
}

/* ============================================
   LUZ AMBIENTAL - Técnica de Glow de Fondo
   Círculos de degradado grandes (400px+) con opacidad 5-8%
   ============================================ */
.nexus-ambient-glow {
    position: relative;
    overflow: hidden;
}

.nexus-ambient-glow::before,
.nexus-ambient-glow::after {
    content: '';
    position: fixed;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

/* Glow violeta en esquina superior derecha */
.nexus-ambient-glow::before {
    top: -200px;
    right: -200px;
    background: radial-gradient(circle, rgba(157, 80, 255, 0.06) 0%, transparent 70%);
}

/* Glow cian en esquina inferior izquierda */
.nexus-ambient-glow::after {
    bottom: -200px;
    left: -200px;
    background: radial-gradient(circle, rgba(77, 232, 255, 0.05) 0%, transparent 70%);
}

/* ============================================
   LÍNEAS DE CONEXIÓN (Estilo Circuito)
   Líneas de 1px con opacidad 10% para separar secciones
   ============================================ */
.nexus-circuit-line {
    position: relative;
}

.nexus-circuit-line::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(157, 80, 255, 0.1) 20%,
        rgba(77, 232, 255, 0.1) 50%,
        rgba(157, 80, 255, 0.1) 80%,
        transparent 100%
    );
}

/* ============================================
   COMPONENTES MudBlazor - Overrides
   ============================================ */

/* Paper/Card con borde sutil */
.mud-paper {
    border: 1px solid var(--nexus-border-subtle) !important;
    transition: border-color var(--nexus-transition), box-shadow var(--nexus-transition);
}

.mud-paper:hover {
    border-color: var(--nexus-border) !important;
}

/* ============================================
   CARDS DE ESTADÍSTICAS
   ============================================ */
.nexus-stat-card {
    background: linear-gradient(135deg, var(--nexus-bg-surface) 0%, var(--nexus-bg-elevated) 100%);
    border: 1px solid var(--nexus-border-subtle);
    border-radius: 8px;
    padding: 24px;
    transition: all var(--nexus-transition);
    position: relative;
    overflow: hidden;
}

.nexus-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    transition: background var(--nexus-transition);
}

.nexus-stat-card:hover {
    border-color: var(--nexus-primary);
    /* Resplandor exterior suave en violeta (hover) */
    box-shadow: 0 0 20px var(--nexus-glow-primary);
}

.nexus-stat-card:hover::before {
    background: var(--nexus-gradient);
}

.nexus-stat-card.primary {
    border-left: 3px solid var(--nexus-primary);
}

.nexus-stat-card.secondary {
    border-left: 3px solid var(--nexus-secondary);
}

.nexus-stat-card.success {
    border-left: 3px solid var(--nexus-success);
}

.nexus-stat-card.error {
    border-left: 3px solid var(--nexus-error);
}

/* Stat value grande */
.nexus-stat-value {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--nexus-text);
}

.nexus-stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--nexus-text-muted);
    margin-bottom: 8px;
}

.nexus-stat-sublabel {
    font-size: 0.8125rem;
    color: var(--nexus-secondary);
    margin-top: 4px;
}

/* ============================================
   TABLAS
   ============================================ */
.mud-table {
    background: var(--nexus-bg-surface) !important;
    border-radius: 8px !important;
    overflow: hidden;
}

.mud-table-head {
    background: var(--nexus-bg-base) !important;
}

.mud-table-row:hover {
    background: var(--nexus-bg-elevated) !important;
}

/* ============================================
   CHIPS DE ESTADO
   ============================================ */
.nexus-chip-running {
    background: rgba(77, 232, 255, 0.12) !important;
    color: var(--nexus-secondary) !important;
    border: 1px solid rgba(77, 232, 255, 0.25) !important;
}

.nexus-chip-completed {
    background: rgba(63, 185, 80, 0.12) !important;
    color: var(--nexus-success) !important;
    border: 1px solid rgba(63, 185, 80, 0.25) !important;
}

.nexus-chip-failed {
    background: rgba(248, 81, 73, 0.12) !important;
    color: var(--nexus-error) !important;
    border: 1px solid rgba(248, 81, 73, 0.25) !important;
}

.nexus-chip-pending {
    background: rgba(210, 153, 34, 0.12) !important;
    color: var(--nexus-warning) !important;
    border: 1px solid rgba(210, 153, 34, 0.25) !important;
}

/* ============================================
   BADGES Y PROCEDIMIENTOS
   ============================================ */
.nexus-proc-badge {
    background: var(--nexus-gradient);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* ============================================
   BLOQUES DE CÓDIGO
   ============================================ */
.nexus-code {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.8125rem;
    background: var(--nexus-bg-base);
    border: 1px solid var(--nexus-border-subtle);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    color: var(--nexus-text);
}

/* ============================================
   EFECTOS DE GLOW
   ============================================ */
.nexus-glow {
    box-shadow: 0 0 20px var(--nexus-glow-primary);
}

.nexus-glow-secondary {
    box-shadow: 0 0 20px var(--nexus-glow-secondary);
}

/* Glow en hover para elementos interactivos */
.nexus-glow-hover {
    transition: box-shadow var(--nexus-transition);
}

.nexus-glow-hover:hover {
    box-shadow: 0 0 15px var(--nexus-glow-primary);
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes nexus-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.nexus-pulse {
    animation: nexus-pulse 2s ease-in-out infinite;
}

@keyframes nexus-glow-pulse {
    0%, 100% {
        box-shadow: 0 0 10px var(--nexus-glow-primary);
    }
    50% {
        box-shadow: 0 0 20px var(--nexus-glow-primary);
    }
}

.nexus-glow-pulse {
    animation: nexus-glow-pulse 2s ease-in-out infinite;
}

/* ============================================
   NAVEGACIÓN
   ============================================ */
.mud-nav-link:hover {
    background: var(--nexus-bg-elevated) !important;
}

.mud-nav-link.active {
    background: rgba(157, 80, 255, 0.08) !important;
    border-right: 2px solid var(--nexus-primary);
}

/* ============================================
   DIÁLOGOS
   ============================================ */
.mud-dialog {
    background: var(--nexus-bg-surface) !important;
    border: 1px solid var(--nexus-border) !important;
    border-radius: 12px !important;
}

/* ============================================
   BOTONES
   ============================================ */
.mud-button-filled.mud-button-primary {
    background: var(--nexus-primary) !important;
    transition: box-shadow var(--nexus-transition);
}

.mud-button-filled.mud-button-primary:hover {
    box-shadow: 0 0 15px var(--nexus-glow-primary);
}

.mud-button-outlined.mud-button-primary {
    border-color: var(--nexus-primary) !important;
    color: var(--nexus-primary) !important;
}

.mud-button-outlined.mud-button-primary:hover {
    background: rgba(157, 80, 255, 0.08) !important;
}

/* Botones con borde fino (estado reposo) */
.nexus-btn {
    background: var(--nexus-bg-elevated);
    border: 1px solid var(--nexus-border);
    border-radius: 8px;
    color: var(--nexus-text);
    transition: all var(--nexus-transition);
}

.nexus-btn:hover {
    border-color: var(--nexus-primary);
    box-shadow: 0 0 10px var(--nexus-glow-primary);
}

/* ============================================
   ERROR BOUNDARY
   ============================================ */
.blazor-error-boundary {
    background: var(--nexus-bg-surface);
    padding: 1rem;
    color: var(--nexus-error);
    border: 1px solid var(--nexus-error);
    border-radius: 8px;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* ============================================
   ICONOGRAFÍA - Estilo Outline
   Los iconos de MudBlazor ya son outline por defecto,
   pero ajustamos los colores
   ============================================ */
.mud-icon-default {
    color: var(--nexus-text-muted) !important;
}

.mud-icon-default:hover {
    color: var(--nexus-text) !important;
}

/* ============================================
   INPUTS
   ============================================ */
.mud-input-outlined .mud-input-outlined-border {
    border-color: var(--nexus-border) !important;
    transition: border-color var(--nexus-transition), box-shadow var(--nexus-transition);
}

.mud-input-outlined:hover .mud-input-outlined-border,
.mud-input-outlined.mud-input-outlined-focus .mud-input-outlined-border {
    border-color: var(--nexus-primary) !important;
}

.mud-input-outlined.mud-input-outlined-focus .mud-input-outlined-border {
    box-shadow: 0 0 8px var(--nexus-glow-primary);
}

/* ============================================
   LOGO NEXUS
   Logo con animación premium durante streaming
   ============================================ */
.nexus-logo {
    height: 48px;
    width: 48px;
    object-fit: contain;
    border-radius: 50%;
    opacity: 0.95;
    filter: brightness(0) invert(1);
    transition: opacity 0.4s ease, transform 0.3s ease, filter 0.4s ease;
}

.nexus-logo:hover {
    opacity: 1;
    transform: scale(1.05);
}

/* ── Streaming: rotación suave del logo (siempre blanco) ── */
@keyframes nexus-logo-stream-spin {
    0%   { transform: rotate(0deg)   scale(1);    filter: brightness(0) invert(1) drop-shadow(0 0 6px rgba(157,80,255,0.5)); }
    25%  { transform: rotate(90deg)  scale(1.06); filter: brightness(0) invert(1) drop-shadow(0 0 12px rgba(77,232,255,0.6)); }
    50%  { transform: rotate(180deg) scale(1);    filter: brightness(0) invert(1) drop-shadow(0 0 18px rgba(157,80,255,0.7)); }
    75%  { transform: rotate(270deg) scale(1.06); filter: brightness(0) invert(1) drop-shadow(0 0 12px rgba(77,232,255,0.6)); }
    100% { transform: rotate(360deg) scale(1);    filter: brightness(0) invert(1) drop-shadow(0 0 6px rgba(157,80,255,0.5)); }
}

/* Logo en estado de streaming/procesando */
.nexus-logo.streaming {
    animation: nexus-logo-stream-spin 4s linear infinite;
    opacity: 1;
}

/* Logo en estado de streaming con hover - pausa momentánea */
.nexus-logo.streaming:hover {
    animation-play-state: paused;
}

/* Contenedor del logo con indicador de estado */
.nexus-logo-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Streaming: Anillo orbital luminoso ── */
@keyframes nexus-orbit-ring {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes nexus-ring-glow {
    0%, 100% { opacity: 0.6; border-color: rgba(157,80,255,0.5); }
    50%      { opacity: 1;   border-color: rgba(77,232,255,0.8); }
}

.nexus-logo-container.streaming::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 58px;
    height: 58px;
    margin-top: -29px;
    margin-left: -29px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: rgba(77,232,255,0.8);
    border-right-color: rgba(157,80,255,0.4);
    animation: nexus-orbit-ring 1.8s linear infinite,
               nexus-ring-glow 3s ease-in-out infinite;
    pointer-events: none;
}

/* ── Streaming: Segundo anillo (contra-rotación) ── */
.nexus-logo-container.streaming::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 66px;
    height: 66px;
    margin-top: -33px;
    margin-left: -33px;
    border-radius: 50%;
    border: 1px solid transparent;
    border-bottom-color: rgba(157,80,255,0.5);
    border-left-color: rgba(77,232,255,0.2);
    animation: nexus-orbit-ring 3s linear infinite reverse;
    opacity: 0.6;
    pointer-events: none;
}

/* ── Idle: pequeño dot de estado (sin streaming) ── */
.nexus-logo-container:not(.streaming)::after {
    content: none;
}
.nexus-logo-container:not(.streaming)::before {
    content: none;
}
/* ---------------------------------------------------------------------------
 * Blazor reconnect modal (IIS restarts/deploys)
 * blazor.web.js toggles: components-reconnect-show/hide/failed/rejected
 * ------------------------------------------------------------------------- */

#components-reconnect-modal.nexus-reconnect-modal.components-reconnect-hide {
  display: none;
}

#components-reconnect-modal.nexus-reconnect-modal.components-reconnect-show {
  display: flex;
}

#components-reconnect-modal.nexus-reconnect-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 600px at 20% 10%, rgba(77, 232, 255, 0.10) 0%, rgba(77, 232, 255, 0.00) 60%),
    radial-gradient(900px 500px at 80% 20%, rgba(157, 80, 255, 0.12) 0%, rgba(157, 80, 255, 0.00) 55%),
    rgba(11, 14, 20, 0.72);
  backdrop-filter: blur(8px);
}

.nexus-reconnect-card {
  width: min(560px, calc(100vw - 32px));
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(22, 27, 34, 0.86);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.30) inset;
  overflow: hidden;
}

.nexus-reconnect-topline {
  height: 4px;
  background: linear-gradient(90deg, rgba(77, 232, 255, 1) 0%, rgba(157, 80, 255, 1) 100%);
}

.nexus-reconnect-content {
  padding: 18px 18px 16px;
  color: rgba(255, 255, 255, 0.92);
}

.nexus-reconnect-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.nexus-reconnect-mark {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 6px 18px rgba(77, 232, 255, 0.20));
}

.nexus-reconnect-product {
  font-family: "Plus Jakarta Sans", "Titillium Web", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.1;
}

.nexus-reconnect-env {
  margin-top: 2px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.62);
}

.nexus-reconnect-title {
  font-family: "Plus Jakarta Sans", "Titillium Web", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.2px;
  margin: 6px 0 6px;
}

.nexus-reconnect-subtitle {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: 14px;
}

.nexus-reconnect-state {
  display: none;
  padding: 14px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(11, 14, 20, 0.35);
}

#components-reconnect-modal.nexus-reconnect-modal.components-reconnect-show .nexus-reconnect-state--connecting {
  display: grid;
  grid-template-columns: 18px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
}

#components-reconnect-modal.nexus-reconnect-modal.components-reconnect-show .nexus-reconnect-state--failed,
#components-reconnect-modal.nexus-reconnect-modal.components-reconnect-show .nexus-reconnect-state--rejected {
  display: none;
}

#components-reconnect-modal.nexus-reconnect-modal.components-reconnect-show.components-reconnect-failed .nexus-reconnect-state--connecting {
  display: none;
}

#components-reconnect-modal.nexus-reconnect-modal.components-reconnect-show.components-reconnect-failed .nexus-reconnect-state--failed {
  display: block;
}

#components-reconnect-modal.nexus-reconnect-modal.components-reconnect-show.components-reconnect-rejected .nexus-reconnect-state--connecting {
  display: none;
}

#components-reconnect-modal.nexus-reconnect-modal.components-reconnect-show.components-reconnect-rejected .nexus-reconnect-state--rejected {
  display: block;
}

.nexus-reconnect-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: rgba(77, 232, 255, 0.90);
  border-right-color: rgba(157, 80, 255, 0.70);
  animation: nexus-spin 0.9s linear infinite;
  grid-row: 1 / span 2;
}

@keyframes nexus-spin {
  to { transform: rotate(360deg); }
}

.nexus-reconnect-state-title {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.25;
}

.nexus-reconnect-state-hint {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.64);
  line-height: 1.35;
  margin-top: 2px;
}

.nexus-reconnect-btn {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(90deg, rgba(77, 232, 255, 0.22), rgba(157, 80, 255, 0.22));
  color: rgba(255, 255, 255, 0.92);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.nexus-reconnect-btn:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: linear-gradient(90deg, rgba(77, 232, 255, 0.28), rgba(157, 80, 255, 0.28));
}

.nexus-reconnect-footnote {
  margin-top: 12px;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  font-size: 11.5px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.54);
}

@media (max-width: 480px) {
  #components-reconnect-modal.nexus-reconnect-modal { padding: 14px; }
  .nexus-reconnect-content { padding: 16px 14px 14px; }
}
