/* =============================
   Theme & Design System
   ============================= */
:root {
  /* Paleta de colores (HSL) */
  --color-primary-h: 260;
  --color-primary-s: 70%;
  --color-primary-l: 55%;
  --color-primary: hsl(var(--color-primary-h), var(--color-primary-s), var(--color-primary-l));

  --color-bg-light: #ffffff;
  --color-bg-dark: #07050d;
  --color-text-light: #07050d;
  --color-text-dark: #f3f4f6;

  /* Transparencias para glassmorphism */
  --glass-bg: rgba(10, 7, 20, 0.45);
  --glass-border: rgba(168, 85, 247, 0.15);

  /* Tipografía */
  --font-primary: 'Inter', system-ui, sans-serif;
  --font-heading: 'Outfit', system-ui, sans-serif;
}

/* Modo oscuro */
[data-theme='dark'] {
  --color-bg: var(--color-bg-dark);
  --color-text: var(--color-text-dark);
  --glass-bg: rgba(10, 7, 20, 0.45);
  --glass-border: rgba(168, 85, 247, 0.15);
}

/* Modo claro */
[data-theme='light'] {
  --color-bg: var(--color-bg-light);
  --color-text: var(--color-text-light);
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(0, 0, 0, 0.08);
}

/* Aplicación global */
html, body {
  background: transparent !important;
  color: var(--color-text);
  font-family: var(--font-primary);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Glassmorphism reusable class */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Micro‑animaciones */
@keyframes bump {
  0% { transform: scale(1); }
  30% { transform: scale(1.15); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.bump {
  animation: bump 0.4s ease-out;
}

/* Navbar scrolling effect */
.navbar.scrolled {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  transition: background 0.3s ease;
}

/* Responsividad básica */
@media (max-width: 768px) {
  .nav-links {
    flex-direction: column;
    gap: 1rem;
    display: none;
  }
  .navbar-actions {
    gap: 0.5rem;
  }
  .mobile-toggle {
    display: block;
  }
}

/* Dark‑mode toggle button styling */
.theme-toggle {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: 1.2rem;
}

/* Transición de carga suave para imágenes diferidas */
img[data-src] {
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
}
img.loaded {
  opacity: 1;
}

/* Banner de Consentimiento de Cookies Premium */
.cookie-banner {
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: 380px;
  background: rgba(15, 11, 28, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: translateY(150%);
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.cookie-banner.visible {
  transform: translateY(0);
}

.cookie-banner h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cookie-banner h4 i {
  color: var(--color-primary);
}

.cookie-banner p {
  font-size: 13px;
  line-height: 1.5;
  color: #9ca3af;
  margin: 0;
}

.cookie-actions {
  display: flex;
  gap: 12px;
}

.cookie-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.cookie-btn.accept {
  background: linear-gradient(135deg, var(--color-primary), #7c3aed);
  border: none;
  color: #fff;
}

.cookie-btn.accept:hover {
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.4);
  transform: translateY(-1px);
}

.cookie-btn.reject {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
}

.cookie-btn.reject:hover {
  background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 480px) {
  .cookie-banner {
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }
}

/* ==========================================
   REALTIME CHET WIDGET PREMIUM STYLES
   ========================================== */
.chat-widget {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9998;
}

.chat-widget-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), #7c3aed);
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(var(--color-primary-rgb), 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.chat-widget-toggle:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 6px 25px rgba(var(--color-primary-rgb), 0.6);
}

.chat-widget-toggle::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  border: 2px solid var(--color-primary);
  animation: pulseChatBorder 2s infinite;
  pointer-events: none;
}

@keyframes pulseChatBorder {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.3); opacity: 0; }
}

.chat-window {
  position: fixed;
  bottom: 96px;
  left: 24px;
  width: 360px;
  height: 480px;
  background: rgba(15, 11, 28, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-window.visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.chat-header {
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header-info img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-primary);
}

.chat-header-text h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.chat-status {
  font-size: 11px;
  color: var(--color-success);
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
}

.close-chat {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 18px;
  cursor: pointer;
  transition: color 0.3s;
}

.close-chat:hover {
  color: #fff;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(7, 5, 13, 0.2);
}

.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: msgFadeIn 0.3s ease forwards;
}

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

.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--color-primary), #7c3aed);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.chat-msg.staff {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: #fff;
  border-bottom-left-radius: 2px;
}

.chat-msg.system {
  align-self: center;
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 11px;
  padding: 0;
  text-align: center;
  max-width: 100%;
}

.msg-meta {
  font-size: 10px;
  opacity: 0.6;
}

.chat-input-bar {
  background: rgba(255, 255, 255, 0.01);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: 12px 16px;
}

.chat-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 10px 18px;
  color: #fff;
  font-size: 13px;
  font-family: var(--font-body);
  transition: all 0.3s;
}

.chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: rgba(var(--color-primary-rgb), 0.02);
}

.chat-send-btn {
  background: linear-gradient(135deg, var(--color-primary), #7c3aed);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.3s;
}

.chat-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(var(--color-primary-rgb), 0.4);
}

/* Typing Indicator Animation */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  width: fit-content;
}

.typing-indicator .dot {
  width: 6px;
  height: 6px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

@media (max-width: 480px) {
  .chat-window {
    left: 16px;
    right: 16px;
    bottom: 96px;
    width: auto;
    height: 400px;
  }
  .chat-widget {
    left: 16px;
    bottom: 16px;
  }
}

/* ==========================================
   FIXED PARALLAX BACKGROUND & LOGO OVERLAY
   ========================================== */
.fixed-parallax-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  pointer-events: none;
  overflow: hidden;
  background-color: #050308; /* Fondo base ultra oscuro premium */
  background-image: 
    /* Brillo neón morado superior izquierdo (Glow Blob 1) */
    radial-gradient(circle at 10% 15%, rgba(168, 85, 247, 0.12) 0%, transparent 45%),
    /* Brillo neón cian superior derecho (Glow Blob 2) */
    radial-gradient(circle at 90% 20%, rgba(0, 242, 255, 0.08) 0%, transparent 40%),
    /* Gran destello de luz central morada */
    radial-gradient(circle at 50% 50%, rgba(168, 85, 247, 0.05) 0%, transparent 60%);
  background-size: 100% 100%, 100% 100%, 100% 100%;
  background-position: center;
  background-attachment: fixed;
  transition: background-color 0.5s ease;
}

/* Grid cibernético futurista de fondo (sobredimensionado para scroll parallax) */
.bg-cyber-grid {
  position: absolute;
  top: -200px;
  left: 0;
  width: 100%;
  height: calc(100% + 400px);
  background-image: 
    linear-gradient(rgba(168, 85, 247, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 85, 247, 0.025) 1px, transparent 1px);
  background-size: 60px 60px;
  background-position: center;
  will-change: transform;
}

/* Estrellas y partículas cibernéticas de fondo */
.bg-cyber-stars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(1.5px 1.5px at 15% 20%, rgba(255, 255, 255, 0.12), transparent),
    radial-gradient(2px 2px at 40% 75%, rgba(168, 85, 247, 0.15), transparent),
    radial-gradient(1px 1px at 70% 30%, rgba(255, 255, 255, 0.08), transparent),
    radial-gradient(1.5px 1.5px at 85% 65%, rgba(0, 242, 255, 0.12), transparent);
  background-size: 500px 500px;
  opacity: 0.7;
  pointer-events: none;
  animation: backgroundStarsPulse 8s ease-in-out infinite alternate;
}

@keyframes backgroundStarsPulse {
  0% { opacity: 0.4; }
  100% { opacity: 0.9; }
}

/* Brillo difuminado dinámico detrás del logo */
.bg-glow-blur {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.06) 0%, rgba(124, 58, 237, 0.02) 40%, transparent 70%);
  filter: blur(90px);
  border-radius: 50%;
}

/* Envoltura del logotipo que recibe el scroll parallax desde JS */
.fixed-bg-logo-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - 80px));
  width: 50vw;
  max-width: 680px;
  min-width: 300px;
  height: auto;
  pointer-events: none;
  z-index: -1;
  will-change: transform;
}

/* Logo oficial de EngineX en marca de agua fija al 10% con animación CSS */
.fixed-bg-logo {
  width: 100%;
  height: auto;
  opacity: 0.1; /* 10% opacidad premium */
  filter: grayscale(8%) drop-shadow(0 0 45px rgba(168, 85, 247, 0.18));
  animation: gentlePulseLogo 18s ease-in-out infinite alternate;
}

@keyframes gentlePulseLogo {
  0% {
    transform: scale(1) rotate(0deg);
    filter: grayscale(8%) drop-shadow(0 0 35px rgba(168, 85, 247, 0.12));
  }
  50% {
    transform: scale(1.025) rotate(0.6deg);
    filter: grayscale(4%) drop-shadow(0 0 50px rgba(168, 85, 247, 0.22));
  }
  100% {
    transform: scale(1) rotate(-0.6deg);
    filter: grayscale(8%) drop-shadow(0 0 35px rgba(168, 85, 247, 0.12));
  }
}

/* Adaptación del fondo en Modo Claro */
[data-theme='light'] .fixed-parallax-bg {
  background: #f8fafc !important;
  background-image: none !important;
}

[data-theme='light'] .bg-cyber-grid {
  background-image: 
    linear-gradient(rgba(0, 0, 0, 0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.012) 1px, transparent 1px);
}

[data-theme='light'] .bg-glow-blur {
  background: radial-gradient(circle, rgba(168, 85, 247, 0.03) 0%, transparent 60%);
}

[data-theme='light'] .fixed-bg-logo {
  opacity: 0.04;
  filter: grayscale(100%) brightness(0.2);
}

/* ==========================================================================
   PREMIUM BACKGROUNDS FOR SPA OVERLAYS (DOCS, BOT PANEL, STAFF PANEL)
   ========================================================================== */
#docs-panel-overlay,
#admin-panel-overlay,
#staff-panel-overlay {
  background-color: #050308 !important; /* Base sólida para tapar la landing de fondo */
  background-image: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Soporte para modo claro en overlays */
[data-theme='light'] #docs-panel-overlay,
[data-theme='light'] #admin-panel-overlay,
[data-theme='light'] #staff-panel-overlay {
  background-color: #f8fafc !important;
  background-image: none !important;
}

/* Evitar bug de Blink/WebKit en z-index negativo con position: fixed usando position: absolute */
#docs-panel-overlay .fixed-parallax-bg,
#admin-panel-overlay .fixed-parallax-bg,
#staff-panel-overlay .fixed-parallax-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: -2;
}
