/**
 * a2host - Main CSS Design System (Zero-Build)
 * Paleta Dark SaaS Obsidian / Emerald / Lime con Glassmorphism de 3 niveles y WCAG 2.1 AA.
 */

:root {
  /* Paleta Base Obsidian */
  --bg-base: #080c08;
  --bg-base-alt: #0b120c;
  --bg-surface: rgba(14, 22, 15, 0.72);
  --bg-surface-elevated: rgba(18, 30, 20, 0.85);
  --bg-surface-hover: rgba(28, 44, 30, 0.88);
  --bg-modal: rgba(11, 18, 12, 0.94);
  --bg-input: rgba(8, 14, 9, 0.85);

  /* Acentos de Marca (CPIC / SENA / Emerald & Lime) */
  --accent-lime: #a3e635;
  --accent-lime-hover: #bef264;
  --accent-lime-glow: rgba(163, 230, 53, 0.22);
  --accent-emerald: #10b981;
  --accent-emerald-dark: #059669;
  --accent-emerald-glow: rgba(16, 185, 129, 0.2);

  /* Estados Funcionales */
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.12);
  --color-success-border: rgba(16, 185, 129, 0.28);

  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  --color-warning-border: rgba(245, 158, 11, 0.3);

  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.12);
  --color-danger-border: rgba(239, 68, 68, 0.32);

  --color-info: #0ea5e9;
  --color-info-bg: rgba(14, 165, 233, 0.12);
  --color-info-border: rgba(14, 165, 233, 0.28);

  /* Tipografía */
  --text-primary: #f8fafc;
  --text-secondary: rgba(248, 250, 252, 0.75);
  --text-muted: rgba(248, 250, 252, 0.45);
  --text-inverse: #080c08;

  /* Bordes y Separadores Glassmorphism */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-focus: rgba(163, 230, 53, 0.6);
  --border-active: rgba(163, 230, 53, 0.4);

  /* Sombras y Luces Internas (Glass Edge Sheen) */
  --glass-sheen: inset 0 1px 0 0 rgba(255, 255, 255, 0.12);
  --glass-sheen-strong: inset 0 1px 0 0 rgba(255, 255, 255, 0.2);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55), 0 0 32px rgba(163, 230, 53, 0.06);

  /* Curvaturas de Borde */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transiciones Suaves */
  --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-base: 220ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Reset y Base Universal
   ========================================================================== */

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

html {
  font-size: 16px;
  color-scheme: dark;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  letter-spacing: -0.012em;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Tabular Nums para evitar saltos en métricas y contadores */
.tabular-nums, .stat-value, .badge-port, .metric-value {
  font-variant-numeric: tabular-nums;
}

/* Ambient Glow Blobs de Fondo */
.ambient-glow-wrapper {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.ambient-blob {
  position: absolute;
  border-radius: var(--radius-full);
  filter: blur(120px);
  opacity: 0.14;
}

.ambient-blob-1 {
  top: -100px;
  left: 10%;
  width: 480px;
  height: 480px;
  background: var(--accent-lime);
  animation: pulseBlob 10s ease-in-out infinite alternate;
}

.ambient-blob-2 {
  top: 40%;
  right: -100px;
  width: 520px;
  height: 520px;
  background: var(--accent-emerald);
  opacity: 0.10;
}

.ambient-blob-3 {
  bottom: -120px;
  left: 25%;
  width: 420px;
  height: 420px;
  background: var(--accent-emerald-dark);
  opacity: 0.08;
}

@keyframes pulseBlob {
  0% { transform: scale(1) translateY(0); opacity: 0.12; }
  100% { transform: scale(1.15) translateY(30px); opacity: 0.18; }
}

/* ==========================================================================
   Scrollbars Personalizados
   ========================================================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(163, 230, 53, 0.4);
  background-clip: padding-box;
}

/* ==========================================================================
   Estructura General de la Aplicación (Shell)
   ========================================================================== */

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.main-container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
  flex: 1;
}

/* Header & Barra Superior */
.top-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--glass-sheen), var(--shadow-sm);
  padding: 0.75rem 1.25rem;
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(163, 230, 53, 0.18), rgba(16, 185, 129, 0.15));
  border: 1px solid var(--border-active);
  box-shadow: var(--glass-sheen), 0 0 16px var(--accent-lime-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-lime);
  flex-shrink: 0;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, #ffffff 40%, var(--accent-lime) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-version {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  background: rgba(163, 230, 53, 0.12);
  border: 1px solid rgba(163, 230, 53, 0.25);
  color: var(--accent-lime);
}

.brand-subdomain {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Barra de Telemetría en Vivo
   ========================================================================== */

.telemetry-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.telemetry-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.telemetry-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.telemetry-details {
  display: flex;
  flex-direction: column;
}

.telemetry-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.telemetry-value-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.telemetry-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* RAM Progress Bar */
.ram-bar-container {
  width: 72px;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.ram-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  background: var(--accent-lime);
  transition: width 0.4s ease, background 0.4s ease;
}

.ram-bar-fill.ram-warning {
  background: var(--color-warning);
}

.ram-bar-fill.ram-danger {
  background: var(--color-danger);
}

/* Indicador Pulsante Apache */
.status-pulsing-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseDot 2s infinite;
}

.status-pulsing-dot.mock {
  background: var(--color-warning);
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
}

.status-pulsing-dot.offline {
  background: var(--color-danger);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: none;
}

@keyframes pulseDot {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Usuario y Botón Logout */
.user-menu-section {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
}

.user-role-tag {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.12rem 0.45rem;
  border-radius: var(--radius-full);
}

.user-role-tag.role-admin {
  background: rgba(163, 230, 53, 0.15);
  color: var(--accent-lime);
  border: 1px solid rgba(163, 230, 53, 0.3);
}

.user-role-tag.role-operator {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  transform: scale(1.04);
}

/* ==========================================================================
   Pestañas Principales (Tab Navigation)
   ========================================================================== */

.tabs-nav-container {
  margin: 1.5rem 0 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tabs-list {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  min-width: max-content;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 1.15rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: var(--accent-lime);
  border-bottom-color: var(--accent-lime);
  background: rgba(163, 230, 53, 0.06);
  font-weight: 600;
}

.tab-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.tab-btn.active .tab-badge {
  background: rgba(163, 230, 53, 0.2);
  color: var(--accent-lime);
}

/* ==========================================================================
   Paneles de Contenido de Pestañas
   ========================================================================== */

.tab-panel {
  display: none;
  animation: fadeInTab var(--transition-base);
}

.tab-panel.active {
  display: block;
}

@keyframes fadeInTab {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Clases Utilitarias */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-lime); }
.tabular-nums { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
