/* ═══════════════════════════════════════════════════════════
   NUDI WORKSPACE — PWA INSTALL EXPERIENCE & MODAL SYSTEM
   Design System: Dark Cyber-SaaS · OLED Dark · Liquid Glass
   Typography: Outfit (Headings/Buttons) · Inter (Body/Steps) · JetBrains Mono (Code/Badges)
   ═══════════════════════════════════════════════════════════ */

/* ── 1. Botón de Instalación en Header (Cian OLED & Neon Glow) ── */
.btn-pwa-install {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  background: rgba(34, 211, 238, 0.08);
  color: #22d3ee;
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 8px;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-pwa-install::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.2), transparent);
  transition: left 0.6s ease;
}

.btn-pwa-install:hover {
  background: rgba(34, 211, 238, 0.16);
  border-color: #22d3ee;
  color: #f8fafc;
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.4), 0 4px 14px rgba(0, 0, 0, 0.6);
  transform: translateY(-1px);
}

.btn-pwa-install:hover::before {
  left: 100%;
}

.btn-pwa-install:active {
  transform: translateY(0);
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.3);
}

.btn-pwa-install .pwa-btn-icon {
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.6));
}

.btn-pwa-install .pwa-btn-text {
  font-weight: 600;
}

/* Indicador de pulso activo en el botón */
.btn-pwa-install .pwa-pulse-dot {
  width: 6px;
  height: 6px;
  background-color: #22d3ee;
  border-radius: 50%;
  box-shadow: 0 0 8px #22d3ee;
  animation: nudiPwaPulseDot 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes nudiPwaPulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

/* ── 2. Banner Flotante Cyber-Glass Inferior ──────────────── */
#nudi-pwa-banner {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99998;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(2, 6, 23, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(34, 211, 238, 0.4);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75), 0 0 25px rgba(34, 211, 238, 0.18);
  color: #f8fafc;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  max-width: 440px;
  animation: nudiPwaSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

/* Con una ventana modal abierta el banner se aparta. Vive en z-index 99998 y
   los overlays del panel entre 1000 y 2100: en móvil el banner es una barra
   de ancho completo pegada abajo, exactamente donde cae el pie de un modal
   centrado, y dejaba sus botones sin recibir un solo toque. Se esconde con
   visibility y no con display para que offsetHeight siga midiendo y
   --nudi-pwa-banner-h no se falsee mientras el modal esté abierto. Es el
   mismo selector que ya usa app.js para no abrir dos overlays a la vez. Si el
   navegador no entiende :has(), la regla se ignora entera y el banner se
   comporta como antes. */
body:has(.modal-overlay:not(.hidden)) #nudi-pwa-banner {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@keyframes nudiPwaSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.nudi-pwa-banner-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  border: 1px solid rgba(34, 211, 238, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 4px;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.25);
}

.nudi-pwa-banner-icon svg,
.nudi-pwa-banner-icon img {
  width: 100%;
  height: 100%;
  display: block;
}

.nudi-pwa-banner-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nudi-pwa-banner-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: #f8fafc;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nudi-pwa-banner-title .badge-highlight {
  font-size: 10px;
  padding: 1px 6px;
  background: rgba(34, 211, 238, 0.15);
  border: 1px solid rgba(34, 211, 238, 0.3);
  color: #22d3ee;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
}

.nudi-pwa-banner-desc {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.35;
}

.nudi-pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.nudi-pwa-btn-install {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.35);
}

.nudi-pwa-btn-install:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(6, 182, 212, 0.5);
}

.nudi-pwa-btn-close {
  background: transparent;
  color: #64748b;
  border: none;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.nudi-pwa-btn-close:hover {
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.05);
}

/* ── 3. Modal Cyber Dark Glass de Instalación Guiada ─────── */
.nudi-pwa-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: nudiPwaFadeIn 0.25s ease-out;
  box-sizing: border-box;
}

@keyframes nudiPwaFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.nudi-pwa-modal {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.98));
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(34, 211, 238, 0.18);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  position: relative;
  animation: nudiPwaScaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  color: #f8fafc;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  box-sizing: border-box;
}

@keyframes nudiPwaScaleUp {
  from { opacity: 0; transform: scale(0.93) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Encabezado del Modal */
.nudi-pwa-modal-header {
  padding: 22px 24px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.06) 0%, transparent 100%);
}

.nudi-pwa-modal-header-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nudi-pwa-modal-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1.5px solid rgba(34, 211, 238, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.3);
  flex-shrink: 0;
}

.nudi-pwa-modal-logo svg,
.nudi-pwa-modal-logo img {
  width: 100%;
  height: 100%;
}

.nudi-pwa-modal-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nudi-pwa-modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.01em;
  margin: 0;
}

.nudi-pwa-modal-title .cyan-text {
  color: #22d3ee;
}

.nudi-pwa-modal-subtitle {
  font-size: 0.82rem;
  color: #94a3b8;
  margin: 0;
}

.nudi-pwa-modal-close {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
}

.nudi-pwa-modal-close:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* Cuerpo del Modal */
.nudi-pwa-modal-body {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Badge de Plataforma Detectada */
.nudi-pwa-platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  color: #cbd5e1;
  align-self: flex-start;
}

.nudi-pwa-platform-badge .badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px #10b981;
}

/* Beneficios clave */
.nudi-pwa-benefits-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.nudi-pwa-benefit-item {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.nudi-pwa-benefit-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.nudi-pwa-benefit-label {
  font-family: 'Outfit', sans-serif;
  font-size: 0.74rem;
  font-weight: 600;
  color: #cbd5e1;
}

/* Tarjeta de Guía Paso a Paso (iOS Safari) */
.nudi-pwa-steps-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nudi-pwa-step-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(34, 211, 238, 0.15);
  border-radius: 12px;
  transition: border-color 0.2s ease;
}

.nudi-pwa-step-card:hover {
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(15, 23, 42, 0.9);
}

.nudi-pwa-step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  color: #ffffff;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}

.nudi-pwa-step-content {
  flex: 1;
  font-size: 0.86rem;
  color: #cbd5e1;
  line-height: 1.4;
}

.nudi-pwa-step-content strong {
  color: #22d3ee;
  font-weight: 600;
}

.nudi-pwa-step-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-radius: 6px;
  font-size: 0.82rem;
  color: #67e8f9;
  font-family: 'JetBrains Mono', monospace;
  margin: 0 2px;
}

/* Pie del Modal */
.nudi-pwa-modal-footer {
  padding: 16px 24px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(2, 6, 23, 0.5);
}

.nudi-pwa-btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  padding: 9px 16px;
  border-radius: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nudi-pwa-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

.nudi-pwa-btn-primary {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  border: none;
  color: #ffffff;
  padding: 9px 20px;
  border-radius: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
}

.nudi-pwa-btn-primary:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(6, 182, 212, 0.55);
}

/* ── 4. Responsive & Safe Areas ──────────────────────────── */
@media (max-width: 640px) {
  #nudi-pwa-banner {
    bottom: 16px;
    left: 16px;
    right: 16px;
    max-width: none;
    padding: 12px 14px;
    gap: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .nudi-pwa-modal {
    max-width: 100%;
    border-radius: 16px;
  }

  .nudi-pwa-modal-header {
    padding: 18px 18px 14px;
  }

  .nudi-pwa-modal-body {
    padding: 18px;
    gap: 14px;
  }

  .nudi-pwa-benefits-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .nudi-pwa-benefit-item {
    flex-direction: row;
    justify-content: flex-start;
    padding: 8px 12px;
    gap: 10px;
    text-align: left;
  }

  .nudi-pwa-modal-footer {
    padding: 14px 18px 18px;
    flex-direction: column-reverse;
  }

  .nudi-pwa-btn-secondary,
  .nudi-pwa-btn-primary {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 900px) {
  #btn-pwa-install-header {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   5. PORTAL DE INSTALACIÓN OBLIGATORIA MÓVIL (PWA GATE)
   ═══════════════════════════════════════════════════════════ */
#nudi-pwa-gate {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: #020617;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: pwaGateFadeIn 0.3s ease-out;
}

@keyframes pwaGateFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.nudi-pwa-gate-card {
  width: 100%;
  max-width: 420px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 20px;
  padding: 24px 20px;
  box-sizing: border-box;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(34, 211, 238, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.nudi-pwa-gate-logo {
  width: 58px;
  height: 58px;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 16px rgba(34, 211, 238, 0.6));
}

.nudi-pwa-gate-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-radius: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: #22d3ee;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.nudi-pwa-gate-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: #f8fafc;
  margin: 0 0 8px;
  line-height: 1.25;
}

.nudi-pwa-gate-desc {
  font-family: 'Inter', sans-serif;
  font-size: 0.84rem;
  color: #94a3b8;
  line-height: 1.45;
  margin: 0 0 18px;
}

.nudi-pwa-gate-steps {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  text-align: left;
}

.nudi-pwa-gate-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 10px 12px;
}

.nudi-pwa-gate-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  color: #ffffff;
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.4);
}

.nudi-pwa-gate-step-text {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.4;
}

.nudi-pwa-gate-step-text strong {
  color: #22d3ee;
}

.nudi-pwa-gate-btn-action {
  width: 100%;
  padding: 12px 18px;
  background: linear-gradient(135deg, #22d3ee, #0891b2);
  border: none;
  border-radius: 10px;
  color: #020617;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 18px rgba(34, 211, 238, 0.4);
  transition: all 0.2s ease;
}

.nudi-pwa-gate-btn-action:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(34, 211, 238, 0.55);
}

.nudi-pwa-gate-btn-action:active {
  transform: translateY(0);
}

.nudi-pwa-gate-bypass {
  margin-top: 14px;
  background: transparent;
  border: none;
  color: #64748b;
  font-family: 'Inter', sans-serif;
  font-size: 0.76rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px;
  transition: color 0.2s ease;
}

.nudi-pwa-gate-bypass:hover {
  color: #94a3b8;
}

