/* ============================================= */
/*  🎨 UX PREMIUM - MEJORAS VISUALES AVANZADAS  */
/* ============================================= */
/* Autor: Placid UX Team                         */
/* Fecha: 2025-12-09                             */
/* ============================================= */

/* ============================================= */
/* 1. GRADIENTES DINÁMICOS DE FONDO             */
/* ============================================= */

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

body.site-modern {
  background: linear-gradient(
    135deg,
    #f8fafc 0%,
    #e8f4f8 25%,
    #f0f9ff 50%,
    #ecfdf5 75%,
    #f8fafc 100%
  );
  background-size: 400% 400%;
  animation: gradientShift 20s ease infinite;
}

body.site-modern.site-modern--dark {
  background: linear-gradient(
    135deg,
    #0f172a 0%,
    #1e293b 25%,
    #0c4a6e 50%,
    #134e4a 75%,
    #0f172a 100%
  );
  background-size: 400% 400%;
  animation: gradientShift 25s ease infinite;
}

/* ============================================= */
/* 2. GLASSMORPHISM CARDS                        */
/* ============================================= */

.form-card,
.chart-card,
.card,
.kpi-card,
.info-card,
.panel {
  background: rgba(255, 255, 255, 0.7) !important;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.5) !important;
  box-shadow: 
    0 4px 30px rgba(0, 0, 0, 0.06),
    0 1px 3px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
}

body.site-modern--dark .form-card,
body.site-modern--dark .chart-card,
body.site-modern--dark .card,
body.site-modern--dark .kpi-card,
body.site-modern--dark .info-card,
body.site-modern--dark .panel {
  background: rgba(30, 41, 59, 0.75) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 
    0 4px 30px rgba(0, 0, 0, 0.3),
    0 1px 3px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
}

/* Hover effect para cards */
.kpi-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: 
    0 12px 40px rgba(49, 199, 178, 0.15),
    0 4px 12px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
}

/* ============================================= */
/* 3. SKELETON LOADING                           */
/* ============================================= */

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(226, 232, 240, 0.6) 0%,
    rgba(248, 250, 252, 0.8) 50%,
    rgba(226, 232, 240, 0.6) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

body.site-modern--dark .skeleton {
  background: linear-gradient(
    90deg,
    rgba(51, 65, 85, 0.6) 0%,
    rgba(71, 85, 105, 0.8) 50%,
    rgba(51, 65, 85, 0.6) 100%
  );
  background-size: 200% 100%;
}

.skeleton-text {
  height: 1em;
  width: 80%;
  margin: 0.5em 0;
}

.skeleton-title {
  height: 1.5em;
  width: 60%;
  margin: 0.5em 0;
}

.skeleton-value {
  height: 2.5em;
  width: 120px;
}

.skeleton-paragraph {
  height: 4em;
  width: 100%;
}

/* ============================================= */
/* 4. PROGRESS INDICATOR                         */
/* ============================================= */

.progress-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

body.site-modern--dark .progress-indicator {
  background: rgba(15, 23, 42, 0.95);
}

.progress-indicator.active {
  display: flex;
}

.progress-bar-container {
  width: 100%;
  max-width: 400px;
  height: 6px;
  background: rgba(226, 232, 240, 0.5);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

body.site-modern--dark .progress-bar-container {
  background: rgba(51, 65, 85, 0.5);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #31c7b2, #6b9dfc);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-steps {
  display: flex;
  gap: 24px;
  font-size: 13px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted, #64748b);
  transition: color 0.3s ease;
}

.progress-step.active {
  color: #31c7b2;
  font-weight: 600;
}

.progress-step.completed {
  color: #10b981;
}

.progress-step .step-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  background: var(--muted, #e2e8f0);
  color: white;
  transition: all 0.3s ease;
}

.progress-step.active .step-icon {
  background: #31c7b2;
  animation: pulse 1s ease infinite;
}

.progress-step.completed .step-icon {
  background: #10b981;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ============================================= */
/* 5. TOAST NOTIFICATIONS                        */
/* ============================================= */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.5);
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  max-width: 360px;
}

body.site-modern--dark .toast {
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.hiding {
  transform: translateX(120%);
  opacity: 0;
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 13px;
  color: var(--muted, #64748b);
}

.toast-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
  font-size: 18px;
  line-height: 1;
}

.toast-close:hover {
  opacity: 1;
}

/* Toast variants */
.toast.success {
  border-left: 4px solid #10b981;
}

.toast.error {
  border-left: 4px solid #ef4444;
}

.toast.warning {
  border-left: 4px solid #f59e0b;
}

.toast.info {
  border-left: 4px solid #3b82f6;
}

/* ============================================= */
/* 6. INLINE ERROR MESSAGES                      */
/* ============================================= */

.field-error {
  display: none;
  font-size: 12px;
  color: #ef4444;
  margin-top: 4px;
  padding-left: 4px;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.field.has-error .field-error {
  display: block;
}

.field.has-error input,
.field.has-error select {
  border-color: #ef4444 !important;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* ============================================= */
/* 7. SCROLL REVEAL ANIMATIONS                   */
/* ============================================= */

[data-reveal] {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-reveal].reveal-in {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered delays */
[data-reveal]:nth-child(1) { transition-delay: 0ms; }
[data-reveal]:nth-child(2) { transition-delay: 100ms; }
[data-reveal]:nth-child(3) { transition-delay: 200ms; }
[data-reveal]:nth-child(4) { transition-delay: 300ms; }
[data-reveal]:nth-child(5) { transition-delay: 400ms; }

/* ============================================= */
/* 8. TOOLTIPS                                   */
/* ============================================= */

[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::before,
[data-tooltip]::after {
  position: absolute;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  pointer-events: none;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.95);
  color: white;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  max-width: 250px;
  white-space: normal;
  text-align: center;
}

[data-tooltip]::after {
  content: '';
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 6px solid transparent;
  border-top-color: rgba(15, 23, 42, 0.95);
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Tooltip abajo */
[data-tooltip-pos="bottom"]::before {
  bottom: auto;
  top: calc(100% + 10px);
  transform: translateX(-50%) translateY(-4px);
}

[data-tooltip-pos="bottom"]::after {
  bottom: auto;
  top: calc(100% + 2px);
  transform: translateX(-50%) translateY(-4px);
  border-top-color: transparent;
  border-bottom-color: rgba(15, 23, 42, 0.95);
}

[data-tooltip-pos="bottom"]:hover::before,
[data-tooltip-pos="bottom"]:hover::after {
  transform: translateX(-50%) translateY(0);
}

/* ============================================= */
/* 9. PARTICLE EFFECTS (Canvas container)        */
/* ============================================= */

#particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* Confetti burst container */
#confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9998;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--color, #31c7b2);
  animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(-100vh) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg);
  }
}

/* ============================================= */
/* 10. CONTADOR ANIMADO (styling)                */
/* ============================================= */

.kpi-value.counting {
  background: linear-gradient(90deg, #31c7b2, #6b9dfc, #31c7b2);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: countingGradient 1s ease;
}

@keyframes countingGradient {
  0% { background-position: 100% 0; }
  100% { background-position: 0% 0; }
}

.kpi-value.count-complete {
  animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popIn {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ============================================= */
/* 11. ENHANCED BUTTON STATES                    */
/* ============================================= */

.btn-calculate {
  position: relative;
  overflow: hidden;
}

.btn-calculate::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s ease;
}

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

.btn-calculate.loading {
  pointer-events: none;
  opacity: 0.8;
}

.btn-calculate.loading .btn-icon {
  animation: spin 1s linear infinite;
}

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

/* ============================================= */
/* 12. RESPONSIVE ADJUSTMENTS                    */
/* ============================================= */

@media (max-width: 768px) {
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
  
  .toast {
    max-width: 100%;
  }
  
  .progress-steps {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }
  
  [data-tooltip]::before {
    max-width: 200px;
    font-size: 11px;
  }
}

/* ============================================= */
/* 13. REDUCED MOTION                            */
/* ============================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  body.site-modern {
    animation: none;
    background-size: 100% 100%;
  }
}
