/* ============================================================
   MK SYSTEM — Animaciones y Micro-interacciones
   ============================================================ */

/* ── Keyframes base ─────────────────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(16px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.94);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(0);
  }
}

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

  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  25% {
    transform: translateY(-6px);
  }

  75% {
    transform: translateY(-2px);
  }
}

@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ripple {
  from {
    transform: scale(0);
    opacity: 0.8;
  }

  to {
    transform: scale(4);
    opacity: 0;
  }
}

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

  100% {
    background-position: 200% 0;
  }
}

/* ── Clases de animación ─────────────────────────────────────── */
.animate-fadeIn {
  animation: fadeIn 0.25s ease forwards;
}

.animate-fadeInUp {
  animation: fadeInUp 0.3s ease forwards;
}

.animate-fadeInDown {
  animation: fadeInDown 0.3s ease forwards;
}

.animate-scaleIn {
  animation: scaleIn 0.25s ease forwards;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-bounce {
  animation: bounce 0.6s ease;
}

/* ── Page transition ──────────────────────────────────────────── */
.page-enter {
  animation: fadeInUp 0.3s ease forwards;
}

/* ── Stagger children ─────────────────────────────────────────── */
.stagger>* {
  opacity: 0;
  animation: fadeInUp 0.3s ease forwards;
}

.stagger>*:nth-child(1) {
  animation-delay: 0ms;
}

.stagger>*:nth-child(2) {
  animation-delay: 50ms;
}

.stagger>*:nth-child(3) {
  animation-delay: 100ms;
}

.stagger>*:nth-child(4) {
  animation-delay: 150ms;
}

.stagger>*:nth-child(5) {
  animation-delay: 200ms;
}

.stagger>*:nth-child(6) {
  animation-delay: 250ms;
}

.stagger>*:nth-child(7) {
  animation-delay: 300ms;
}

.stagger>*:nth-child(8) {
  animation-delay: 350ms;
}

.stagger>*:nth-child(9) {
  animation-delay: 400ms;
}

.stagger>*:nth-child(10) {
  animation-delay: 450ms;
}

/* ── Loader / spinner ─────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(26, 86, 219, .2);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3.5px;
}

.spinner-white {
  border-color: rgba(255, 255, 255, .3);
  border-top-color: #fff;
}

.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  gap: var(--sp-4);
  color: var(--t-muted);
  font-size: var(--fs-sm);
}

/* ── Hover lift ───────────────────────────────────────────────── */
.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* ── Hover scale ──────────────────────────────────────────────── */
.hover-scale {
  transition: transform var(--transition-base);
}

.hover-scale:hover {
  transform: scale(1.03);
}

/* ── Ripple effect en botones ─────────────────────────────────── */
.btn {
  position: relative;
  overflow: hidden;
}

.btn .ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .3);
  transform: scale(0);
  animation: ripple 0.6s linear;
  pointer-events: none;
}

/* ── Número animado (counter) ─────────────────────────────────── */
.animated-number {
  display: inline-block;
  animation: countUp 0.4s ease forwards;
}

/* ── Drag indicator ───────────────────────────────────────────── */
.dragging {
  opacity: 0.6;
  transform: scale(1.02);
  box-shadow: var(--shadow-xl) !important;
  cursor: grabbing !important;
}

.drag-over {
  border: 2px dashed var(--c-primary) !important;
  background: var(--c-primary-light) !important;
}

/* ── Status indicator (animated dot) ─────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-gray-400);
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--c-success);
}

.status-dot.away {
  background: var(--c-warning);
}

.status-dot.busy {
  background: var(--c-danger);
}

.status-dot.offline {
  background: var(--c-gray-400);
}

.status-dot.online::after {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--c-success);
  animation: pulse 2s ease-in-out infinite;
}

/* ── Chart animation ──────────────────────────────────────────── */
.chart-container {
  position: relative;
  opacity: 0;
  animation: fadeInUp 0.4s ease 0.1s forwards;
}

/* ── Loading bar (top) ────────────────────────────────────────── */
@keyframes loadingBar {
  0% {
    width: 0%;
    left: 0;
  }

  50% {
    width: 60%;
    left: 20%;
  }

  100% {
    width: 0%;
    left: 100%;
  }
}

.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 9999;
  background: var(--c-primary);
  animation: loadingBar 1.5s ease-in-out infinite;
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

/* ── Card hover gradient ──────────────────────────────────────── */
.card-interactive {
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card-interactive::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(26, 86, 219, .03) 0%, transparent 100%);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.card-interactive:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: rgba(26, 86, 219, .2);
}

.card-interactive:hover::before {
  opacity: 1;
}

/* ── Notification badge pulse ──────────────────────────────────── */
@keyframes badgePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(224, 36, 36, .5);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(224, 36, 36, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(224, 36, 36, 0);
  }
}

.badge-pulse {
  animation: badgePulse 2s infinite;
}

/* ── Entrada de tabla filas ────────────────────────────────────── */
.table tbody tr {
  animation: fadeIn 0.2s ease;
}

/* ── Suavizar todo (prefers-reduced-motion) ───────────────────── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── 3D Card Flip ─────────────────────────────────────────────── */
.flip-container {
  perspective: 1200px;
  width: 100%;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  min-height: 700px;
}

.flip-container.flipped .flip-card-inner {
  transform: rotateX(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1.5px solid #e8d5e8;
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 10px 30px rgba(109, 53, 103, 0.08);
  box-sizing: border-box;
}

.flip-card-front {
  visibility: visible;
  transition: visibility 0s;
}

.flip-container.flipped .flip-card-front {
  visibility: hidden;
  transition: visibility 0s 0.4s;
}

.flip-card-back {
  transform: rotateX(180deg);
  background: #fff;
  visibility: hidden;
  transition: visibility 0s 0.4s;
}

.flip-container.flipped .flip-card-back {
  visibility: visible;
  transition: visibility 0s;
}

/* ── Premium Plan Cards ───────────────────────────────────────── */
.plan-card {
  position: relative;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
  user-select: none;
}

.plan-card:hover {
  transform: translateY(-3px) scale(1.012) !important;
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.35) !important;
  box-shadow: 0 10px 24px rgba(58, 20, 66, 0.25) !important;
}

.plan-card.active-plan {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.08) 100%) !important;
  border: 2px solid rgba(255, 255, 255, 0.9) !important;
  box-shadow: 0 14px 40px rgba(58, 20, 66, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
  transform: translateY(-3px) scale(1.012) !important;
}

.plan-card.active-plan .plan-icon-box {
  background: linear-gradient(135deg, #ffd6f9 0%, #b88aaa 100%) !important;
  color: #3a1442 !important;
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15) !important;
}

/* ── Left Panel Horizontal Flip ────────────────────────────────── */
.left-flip-container {
  perspective: 1500px;
  width: 100%;
  height: 100%;
}

.left-flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.85s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.left-flip-container.flipped .left-flip-card-inner {
  transform: rotateY(180deg);
}

.left-flip-card-front, .left-flip-card-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 64px;
  box-sizing: border-box;
}

.left-flip-card-front {
  z-index: 2;
  transform: rotateY(0deg);
}

.left-flip-card-back {
  transform: rotateY(180deg);
  z-index: 1;
  background: linear-gradient(160deg, #3a1442 0%, #6d3567 55%, #b88aaa 100%) !important;
  color: #fff;
  overflow-y: auto;
}

/* Custom thin scrollbar for calculators and list modules */
.custom-scroll::-webkit-scrollbar {
  width: 6px;
}
.custom-scroll::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
}
.custom-scroll::-webkit-scrollbar-thumb {
  background: rgba(109, 53, 103, 0.2);
  border-radius: 4px;
}
.custom-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(109, 53, 103, 0.4);
}

/* Prevent WebKit composited child layers leaking through 3D backfaces */
#right-features-list-container,
#back-features-summary-container,
.feature-calc-item {
  backface-visibility: hidden !important;
  -webkit-backface-visibility: hidden !important;
}

.flip-container.flipped #right-features-list-container {
  visibility: hidden !important;
  transition: visibility 0s 0.4s;
}

.flip-container:not(.flipped) #back-features-summary-container {
  visibility: hidden !important;
  transition: visibility 0s 0.4s;
}