/* ===================================
   UX OPTIMIZATION STYLES
   Loading states, Skeletons, Toasts, etc
   =================================== */

/* LOADING STATES */
.loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* SKELETON SCREENS */
.skeleton-table {
  width: 100%;
}

.skeleton-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
  padding: 1rem;
  background: var(--dark-secondary);
  border-radius: 8px;
}

.skeleton-cell {
  flex: 1;
  height: 20px;
  background: var(--dark-tertiary);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.skeleton-shimmer::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.1),
      transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  to {
    left: 100%;
  }
}

/* GLOBAL PROGRESS BAR */
.global-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.global-progress-bar.active {
  opacity: 1;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg,
      var(--primary-color),
      var(--primary-light));
  transition: width 0.3s ease;
  box-shadow: 0 0 10px var(--primary-color);
}

/* TOAST NOTIFICATIONS STACK */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  pointer-events: none !important;
}

/* Soporte para el sistema de toast actual (UIManager) */
.toast span {
  color: #ffffff !important;
  font-weight: 500;
  font-size: 0.95rem;
}

.toast i {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* .toast.show se mantiene por compatibilidad */
.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-success {
  border-left-color: var(--success-color);
}

.toast-error {
  border-left-color: var(--danger-color);
}

.toast-warning {
  border-left-color: var(--warning-color);
}

.toast-info {
  border-left-color: var(--primary-color);
}

.toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.toast-success .toast-icon {
  color: var(--success-color);
}

.toast-error .toast-icon {
  color: var(--danger-color);
}

.toast-warning .toast-icon {
  color: var(--warning-color);
}

.toast-info .toast-icon {
  color: var(--primary-color);
}

.toast-content {
  flex: 1;
}

.toast-message {
  color: #ffffff !important;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
}

.toast-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.toast-action-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--primary-color);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toast-action-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.toast-dismiss {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.toast-dismiss:hover {
  background: var(--dark-tertiary);
  color: var(--text-primary);
}

/* Mobile toast adjustments */
@media (max-width: 768px) {
  .toast-container {
    top: auto;
    bottom: 20px;
    left: 20px;
    right: 20px;
    max-width: none;
  }

  .toast {
    transform: translateY(120%);
  }

  .toast-show {
    transform: translateY(0);
  }

  .toast-hide {
    transform: translateY(120%);
  }
}

/* RIPPLE EFFECT */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
  width: 300px;
  height: 300px;
}

/* SMOOTH TRANSITIONS */
* {
  scroll-behavior: smooth;
}

.page-transition {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* BUTTON LOADING STATE */
button.loading {
  position: relative;
}

button.loading .btn-text {
  opacity: 0;
}

button.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* MICRO-INTERACTIONS */
.btn,
.quick-card,
.card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:active,
.quick-card:active,
.card:active {
  transform: scale(0.98);
}

/* FOCUS VISIBLE */
*:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* CONFETTI ANIMATION */
@keyframes confetti-fall {
  to {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  background: var(--success-color);
  animation: confetti-fall 3s linear forwards;
  z-index: 10001;
}