/* ==========================================================================
   WA10X - SISTEMA DE DISEÑO PREMIUM (DARK MODE / AI GLASSMORPHISM)
   ========================================================================== */

:root {
  --bg-dark: #050508;
  --bg-card: rgba(18, 18, 24, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.22);
  
  /* Colores de marca */
  --web10x-red: #e62429;
  --web10x-red-glow: rgba(230, 36, 41, 0.45);
  --whatsapp-green: #25D366;
  --whatsapp-green-glow: rgba(37, 211, 102, 0.45);
  
  /* Textos */
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  
  /* Fuentes */
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-tech: 'Space Grotesk', sans-serif;
  
  /* Transiciones */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
}

/* ==========================================================================
   1. CINEMATIC INTRO SPLASH SCREEN (< 1 SEGUNDO)
   ========================================================================== */
.cinematic-splash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #111118 0%, #050508 100%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s ease;
  pointer-events: all;
}

.cinematic-splash.fade-out {
  opacity: 0;
  transform: scale(1.06);
  pointer-events: none;
}

.splash-core {
  position: relative;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
}

.cyber-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid transparent;
}

.ring-1 {
  width: 100%;
  height: 100%;
  border-top-color: var(--web10x-red);
  border-right-color: rgba(230, 36, 41, 0.2);
  animation: spinRight 1.5s linear infinite;
  box-shadow: 0 0 25px var(--web10x-red-glow);
}

.ring-2 {
  width: 75%;
  height: 75%;
  border-bottom-color: var(--whatsapp-green);
  border-left-color: rgba(37, 211, 102, 0.2);
  animation: spinLeft 1.2s linear infinite;
  box-shadow: 0 0 25px var(--whatsapp-green-glow);
}

.ring-3 {
  width: 50%;
  height: 50%;
  border-top-color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.3);
  animation: spinRight 0.8s linear infinite;
}

@keyframes spinRight {
  to { transform: rotate(360deg); }
}

@keyframes spinLeft {
  to { transform: rotate(-360deg); }
}

.splash-logo {
  font-family: var(--font-tech);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
  z-index: 2;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}

.splash-wa {
  color: #fff;
}

.splash-10x {
  color: var(--web10x-red);
  text-shadow: 0 0 15px var(--web10x-red-glow);
}

.splash-text {
  text-align: center;
  width: 280px;
}

.splash-status {
  font-family: var(--font-tech);
  font-size: 13px;
  font-weight: 700;
  color: var(--whatsapp-green);
  letter-spacing: 2px;
  margin-bottom: 12px;
  text-shadow: 0 0 10px var(--whatsapp-green-glow);
}

.splash-bar-wrap {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.splash-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--web10x-red), var(--whatsapp-green));
  box-shadow: 0 0 12px var(--whatsapp-green);
  animation: fillBar 0.75s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fillBar {
  0% { width: 0%; }
  100% { width: 100%; }
}

.splash-sub {
  font-size: 11.5px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

/* ==========================================================================
   2. AI NEURAL NETWORK CANVAS (FONDO VIVO) & NEÓN AMBIENTAL
   ========================================================================== */
.ai-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  opacity: 0.55;
}

.ambient-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -2;
  opacity: 0.3;
  pointer-events: none;
  animation: floatGlow 12s ease-in-out infinite alternate;
}

.glow-red {
  top: -150px;
  left: -100px;
  background: var(--web10x-red);
}

.glow-green {
  bottom: -150px;
  right: -100px;
  background: var(--whatsapp-green);
  animation-delay: -5s;
}

@keyframes floatGlow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(60px, 40px) scale(1.15); }
}

/* ==========================================================================
   ESTRUCTURA Y GLASS CARD BASE
   ========================================================================== */
.app-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 28px 24px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.app-container.loaded {
  opacity: 1;
  transform: translateY(0);
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  transition: var(--transition-smooth);
}

.glass-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   CABECERA PRINCIPAL
   ========================================================================== */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  margin-bottom: 24px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo-container img {
  max-height: 48px;
  max-width: 160px;
  object-fit: contain;
}

.default-logo {
  font-family: var(--font-tech);
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.default-logo span {
  color: var(--web10x-red);
  text-shadow: 0 0 15px var(--web10x-red-glow);
}

.header-titles h1 {
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 600;
  color: #fff;
}

.subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.role-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--whatsapp-green);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--whatsapp-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 16px var(--whatsapp-green); }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* ==========================================================================
   BANNER DE INFORMACIÓN / ACCIONES
   ========================================================================== */
.info-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px 28px;
  margin-bottom: 32px;
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.08) 0%, rgba(20, 20, 26, 0.8) 50%);
  border-left: 4px solid var(--whatsapp-green);
}

.banner-icon {
  font-size: 40px;
}

.banner-content h3 {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.banner-content p {
  font-size: 13.5px;
  color: var(--text-muted);
  max-width: 800px;
}

.banner-actions {
  margin-left: auto;
}

/* ==========================================================================
   BOTONES
   ========================================================================== */
button {
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--whatsapp-green) 0%, #1da851 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.3);
  font-weight: 600;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(37, 211, 102, 0.55);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-danger {
  background: rgba(230, 36, 41, 0.15);
  color: #ff5c60;
  border: 1px solid rgba(230, 36, 41, 0.3);
}

.btn-danger:hover {
  background: var(--web10x-red);
  color: #fff;
  box-shadow: 0 4px 15px var(--web10x-red-glow);
}

.w-100 {
  width: 100%;
}

/* ==========================================================================
   SECCIÓN DE INSTANCIAS Y GRID
   ========================================================================== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 0 8px;
}

.section-header h2 {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 600;
  color: #fff;
}

.count-badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 24px;
}

/* TARJETA DE INSTANCIA */
.session-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
  min-height: 240px;
  position: relative;
  overflow: hidden;
}

.session-card.status-working {
  border-color: rgba(37, 211, 102, 0.35);
}

.session-card.status-working::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--whatsapp-green);
  box-shadow: 0 0 10px var(--whatsapp-green);
}

.session-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.session-title {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  word-break: break-all;
}

.status-pill {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

.status-working .status-pill {
  background: rgba(37, 211, 102, 0.15);
  color: var(--whatsapp-green);
  border: 1px solid rgba(37, 211, 102, 0.3);
}

.status-starting .status-pill {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-stopped .status-pill,
.status-failed .status-pill {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.session-body {
  margin-bottom: 24px;
}

.phone-display {
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.meta-info {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.meta-tag {
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.session-footer {
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.session-footer button {
  flex: 1;
}

/* ==========================================================================
   MODALES (QR Y AJUSTES)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-fast);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  width: 100%;
  max-width: 500px;
  padding: 32px;
  transform: scale(0.95);
  transition: var(--transition-smooth);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title-wrap h3 {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  font-size: 24px;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 8px;
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.qr-instructions {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.qr-instructions ol {
  margin-left: 20px;
  margin-top: 8px;
}

.qr-instructions li {
  margin-bottom: 6px;
}

.qr-display-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  margin-bottom: 20px;
  box-shadow: 0 0 35px rgba(37, 211, 102, 0.25);
  position: relative;
}

.qr-display-box img {
  max-width: 240px;
  max-height: 240px;
  object-fit: contain;
}

.qr-status-text {
  color: #333;
  font-weight: 500;
  margin-top: 12px;
}

.qr-footer {
  text-align: center;
}

.timer-badge {
  display: inline-block;
  background: rgba(37, 211, 102, 0.15);
  color: var(--whatsapp-green);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.security-note {
  font-size: 12px;
  color: var(--text-dim);
}

/* ==========================================================================
   FORMULARIOS Y SWITCHES
   ========================================================================== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
}

.form-group input:focus {
  outline: none;
  border-color: var(--whatsapp-green);
}

.input-readonly {
  opacity: 0.7;
  cursor: not-allowed;
}

.form-group small {
  display: block;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 6px;
}

.toggle-group {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--whatsapp-green);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.toggle-label strong {
  display: block;
  font-size: 14px;
  color: #fff;
}

.toggle-label p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   ESTADOS DE CARGA Y SPINNERS
   ========================================================================== */
.loading-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: var(--whatsapp-green);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
  .main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
  
  .info-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .banner-actions {
    margin-left: 0;
    width: 100%;
  }
  
  .banner-actions button {
    width: 100%;
  }
}
