/* ============================================================
   NEXUS WISP — Animaciones, Efectos y Componentes Especiales
   ============================================================ */

/* === KEYFRAMES GLOBALES === */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes scaleOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.94); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(32px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(32px); }
}
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes spin-anim {
  to { transform: rotate(360deg); }
}
@keyframes pulse-mono {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--primary-soft); }
  50%       { box-shadow: 0 0 0 8px transparent; }
}
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-6px); }
}
@keyframes meshDrift {
  0%   { background-position: 0% 0%, 100% 10%, 40% 100%; }
  50%  { background-position: 85% 40%, 15% 80%, 70% 20%; }
  100% { background-position: 25% 90%, 90% 25%, 10% 55%; }
}
@keyframes progressShrink {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}
@keyframes rippleEffect {
  from { transform: scale(0); opacity: 0.5; }
  to   { transform: scale(4); opacity: 0; }
}
@keyframes orb-drift-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(30px, -20px) scale(1.08); }
  66%       { transform: translate(-20px, 15px) scale(0.95); }
}
@keyframes orb-drift-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40%       { transform: translate(-25px, 20px) scale(1.06); }
  70%       { transform: translate(18px, -10px) scale(0.97); }
}
@keyframes countUp {
  from { opacity: 0; transform: translateY(8px) scale(0.85); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* === UTILIDADES DE ANIMACIÓN === */
.animate-in       { animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both; }
.animate-in-fast  { animation: fadeInUp 0.22s ease both; }
.animate-scale-in { animation: scaleIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both; }
.animate-modal    { animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both; }
.animate-float    { animation: float 3s ease-in-out infinite; }

/* Stagger helpers para listas */
.stagger > *:nth-child(1)  { animation-delay: 0ms; }
.stagger > *:nth-child(2)  { animation-delay: 60ms; }
.stagger > *:nth-child(3)  { animation-delay: 120ms; }
.stagger > *:nth-child(4)  { animation-delay: 180ms; }
.stagger > *:nth-child(5)  { animation-delay: 240ms; }
.stagger > *:nth-child(6)  { animation-delay: 300ms; }

/* === SPINNER === */
.spinner-inline {
  width: 13px; height: 13px; display: inline-block;
  border: 2px solid rgba(128,128,128,0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin-anim 0.65s linear infinite;
  flex-shrink: 0;
}
.spinner-lg {
  width: 28px; height: 28px;
  border: 3px solid var(--border-glass);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin-anim 0.7s linear infinite;
}

/* === STATUS INDICATORS === */
.status-square {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary); display: inline-block;
  animation: pulse-mono 2s infinite;
}
.inline-status { display: inline-flex; align-items: center; gap: 0.3rem; }

/* === GLOBAL WORKING BAR === */
.global-working-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 260;
  background: var(--primary); color: var(--primary-text);
  font-size: 0.79rem; font-weight: 700; text-align: center;
  padding: 0.42rem 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  animation: slideInUp 0.25s ease;
}

/* === MODAL MEJORADO === */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: grid; place-items: center; z-index: 110; padding: 1rem;
  animation: fadeIn 0.2s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
}
body:has(.modal-backdrop) {
  overflow: hidden;
}
.modal-box {
  background: var(--glass-modal);
  backdrop-filter: blur(32px) saturate(140%); -webkit-backdrop-filter: blur(32px) saturate(140%);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl, 8px);
  max-width: 600px; width: 100%; padding: 0;
  box-shadow: var(--elevation-modal), 0 0 0 1px var(--specular-top) inset;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
}
:root[data-theme="light"] .modal-box {
  background: rgba(255, 255, 255, 0.92) !important;
}
.modal-box:not(:has(.modal-body)) {
  padding: 1.5rem 1.75rem;
  overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border-glass);
  flex-shrink: 0;
}
.modal-title-wrap {
  display: flex; align-items: center; gap: 0.65rem;
}
.modal-accent-bar {
  width: 4px; height: 20px; background: var(--primary);
  border-radius: var(--radius-full, 9999px);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.02em; }
.modal-close-x { padding: 0.35rem !important; min-height: unset !important; }
.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}
.modal-footer {
  display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.55rem;
  padding: 0.9rem 1.5rem;
  border-top: 1px solid var(--border-glass);
  background: var(--glass-elevated);
  flex-shrink: 0;
}
.modal-actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.6rem; }

/* === TOAST REDISEÑADO === */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: 0.6rem;
  z-index: 230; pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 0.65rem;
  background: var(--glass-modal);
  backdrop-filter: blur(24px) saturate(130%); -webkit-backdrop-filter: blur(24px) saturate(130%);
  border: 1px solid var(--border-glass);
  border-left: 3px solid var(--toast-accent, var(--primary));
  border-radius: var(--radius-md, 6px);
  color: var(--text-main); padding: 0.85rem 1rem;
  box-shadow: var(--elevation-card);
  min-width: 280px; max-width: 400px;
  position: relative; overflow: hidden;
}
.toast-animated { animation: slideInRight 0.3s cubic-bezier(0.16,1,0.3,1) both; }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; min-width: 0; }
.toast-title { font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 0.1rem; }
.toast-message { font-size: 0.79rem; color: var(--text-secondary); line-height: 1.4; }
.toast-close {
  flex-shrink: 0; border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; padding: 0.1rem; border-radius: var(--radius-sm, 4px);
  transition: color 0.15s ease; align-self: flex-start;
}
.toast-close:hover { color: var(--text-main); }
.toast-progress {
  position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: var(--toast-accent, var(--primary)); opacity: 0.6;
  transform-origin: left;
  animation: progressShrink linear forwards;
  border-radius: 0 0 var(--radius-md, 6px) var(--radius-md, 6px);
}

/* === SKELETON LOADING === */
.skeleton-line, .skeleton-box {
  background: linear-gradient(90deg,
    var(--glass-elevated) 25%,
    var(--glass-highlight) 50%,
    var(--glass-elevated) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm, 4px);
}
.skeleton-line { height: 14px; width: 100%; margin-bottom: 0.5rem; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-box  { height: 80px; width: 100%; }

/* === GLASS SHIMMER (hover especial) === */
.glass-shimmer::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.08) 50%, transparent 60%);
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
  pointer-events: none;
  border-radius: inherit;
}

/* === RIPPLE EN BOTONES === */
.btn-ripple { overflow: hidden; position: relative; }
.btn-ripple .ripple {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transform: scale(0);
  pointer-events: none;
  animation: rippleEffect 0.5s ease-out;
}

/* === ORBES DECORATIVOS PARA LOGIN === */
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(60px); pointer-events: none; opacity: 0.35;
}
.orb-1 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  top: -80px; left: -80px;
  animation: orb-drift-1 12s ease-in-out infinite;
}
.orb-2 {
  width: 240px; height: 240px;
  background: radial-gradient(circle, var(--bg-mesh-1, rgba(255,255,255,0.3)) 0%, transparent 70%);
  bottom: -60px; right: -60px;
  animation: orb-drift-2 15s ease-in-out infinite;
}
.orb-3 {
  width: 160px; height: 160px;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  bottom: 20%; left: 10%;
  opacity: 0.18;
  animation: orb-drift-1 20s ease-in-out infinite reverse;
}

/* === TEXT GRADIENT === */
.text-gradient {
  background: linear-gradient(135deg, var(--text-main) 0%, var(--primary) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.text-muted-label {
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
}

/* === CHIPS / TAGS === */
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.72rem; font-weight: 700;
  background: var(--glass-elevated); border: 1px solid var(--border-glass);
  color: var(--text-secondary); cursor: default;
  transition: all 0.14s ease;
}
.chip:hover, .chip.active {
  background: var(--primary-soft); border-color: var(--primary);
  color: var(--primary);
}
.chip-variable {
  font-family: "JetBrains Mono", monospace; font-size: 0.7rem;
  cursor: pointer;
}
.chip-variable:hover { transform: translateY(-1px); }

/* === CARD-HEADER MEJORADO === */
.card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem;
}
.section-subtitle {
  color: var(--text-muted); font-size: 0.82rem; margin-top: 0.18rem; line-height: 1.4;
}

/* === UTILITY CLASSES === */
.flex-center   { display: flex; align-items: center; justify-content: center; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.flex-start    { display: flex; align-items: center; }
.gap-xs  { gap: 0.3rem; }
.gap-sm  { gap: 0.5rem; }
.gap-md  { gap: 0.75rem; }
.gap-lg  { gap: 1.25rem; }
.w-full  { width: 100%; }
.mt-sm   { margin-top: 0.5rem; }
.mt-md   { margin-top: 1rem; }
.mt-lg   { margin-top: 1.5rem; }
.mb-sm   { margin-bottom: 0.5rem; }
.mb-md   { margin-bottom: 1rem; }

/* === INLINE BADGE INDICATOR === */
.dot-indicator {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; margin-right: 0.3rem;
}
.dot-activo    { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.dot-suspendido { background: var(--primary); }
.dot-prorroga  { background: #f59e0b; }
.dot-manual    { background: #ef4444; }

/* === WINBOX HEADER (conexion router) === */
.winbox-header {
  background: var(--glass-card);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md, 6px);
  border-left: 3px solid var(--primary);
  padding: 0.9rem 1.1rem; margin-bottom: 1rem;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem;
  box-shadow: var(--elevation-card);
  animation: fadeInUp 0.3s ease;
}

/* === COBRO RESULTS === */
.cobro-results-list {
  max-height: 200px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.4rem;
  margin-top: 0.5rem; margin-bottom: 0.85rem;
}
.cobro-client-option {
  background: var(--glass-elevated);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm, 4px);
  padding: 0.65rem 0.8rem;
  cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  gap: 0.5rem; text-align: left; width: 100%;
  color: var(--text-main); font-family: inherit;
  transition: all 0.14s ease;
}
.cobro-client-option:hover {
  border-color: var(--primary); background: var(--glass-highlight);
  transform: translateX(2px);
}

/* === CODE PREVIEW (terminal) === */
.code-preview {
  background: rgba(0,0,0,0.6); color: #a8ff78;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md, 6px);
  white-space: pre-wrap; font-size: 0.78rem; font-family: "JetBrains Mono", monospace;
  line-height: 1.6; overflow-x: auto;
  box-shadow: inset 0 2px 12px rgba(0,0,0,0.5);
}
[data-theme="light"] .code-preview { background: rgba(5,10,20,0.88); }

/* === GLASS SUBROW === */
.glass-subrow {
  background: var(--glass-elevated);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm, 4px);
  box-shadow: 0 4px 12px -4px rgba(0,0,0,0.2), inset 0 1px 0 var(--specular-top);
  padding: 0.85rem 1rem;
  display: flex; flex-direction: column; gap: 0.45rem;
  animation: fadeInUp 0.25s ease;
}

/* === NOTIF / TEMA DROPDOWN === */
.notif-dropdown, .tema-dropdown {
  position: absolute; z-index: 90;
  background: var(--glass-modal);
  backdrop-filter: blur(28px) saturate(140%); -webkit-backdrop-filter: blur(28px) saturate(140%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg, 10px);
  box-shadow: var(--elevation-modal);
  animation: fadeInDown 0.22s cubic-bezier(0.16,1,0.3,1);
  overflow: hidden;
}
.notif-dropdown {
  right: 0; top: calc(100% + 8px);
  width: 320px; max-width: calc(100vw - 2rem);
  max-height: 380px; overflow-y: auto;
  padding: 0.5rem;
}
.tema-dropdown {
  right: 0; top: calc(100% + 8px);
  width: 240px; max-width: calc(100vw - 2rem);
  padding: 0.9rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.notif-item {
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm, 4px);
  border-bottom: 1px solid var(--border-glass);
  font-size: 0.8rem; transition: background 0.14s ease;
}
.notif-item:hover { background: var(--glass-elevated); }
.notif-item:last-child { border-bottom: none; }

/* === SEED PICKER === */
.seed-picker-wrap {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: 32px;
  padding: 0.22rem 0.6rem;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm, 4px);
  background: var(--glass-elevated);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); cursor: pointer;
  transition: border-color 0.14s ease;
}
.seed-picker-wrap:hover { border-color: var(--border-strong); }
.seed-color-input {
  width: 22px; height: 22px; padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm, 4px);
  background: transparent; cursor: pointer;
}

/* === RESPONSIVE TOAST === */
@media (max-width: 720px) {
  .toast-container {
    bottom: calc(70px + 0.75rem); left: 0.75rem; right: 0.75rem;
    align-items: stretch;
  }
  .toast { min-width: 0; max-width: 100%; }
}
