/**
 * PVTKNS Modern UI Enhancement Suite
 * - Page Entrance Animations
 * - Shining & Shimmer Effects
 * - Interactive Micro-Animations
 * - Comprehensive Multi-Device & Mobile Notch Support
 */

/* ==========================================================================
   1. KEYFRAME ANIMATIONS
   ========================================================================== */

/* Smooth page and component entrance */
@keyframes pvtknsFadeInUp {
  0% {
    opacity: 0;
    transform: translate3d(0, 14px, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes pvtknsFadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes pvtknsScaleUp {
  0% {
    opacity: 0;
    transform: scale3d(0.97, 0.97, 1);
  }
  100% {
    opacity: 1;
    transform: scale3d(1, 1, 1);
  }
}

/* Diagonal light-sweep reflection */
@keyframes pvtknsShimmer {
  0% {
    transform: translateX(-150%) skewX(-20deg);
  }
  50%, 100% {
    transform: translateX(250%) skewX(-20deg);
  }
}

/* Card diagonal shimmer sweep */
@keyframes pvtknsCardSweep {
  0% {
    transform: translateX(-150%) skewX(-25deg);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: translateX(250%) skewX(-25deg);
    opacity: 0;
  }
}

/* Subtle breathing glow for active indicators & badges */
@keyframes pvtknsGlowPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.45);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(234, 179, 8, 0);
  }
}

@keyframes pvtknsEmeraldPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
}

/* Floating animation for icons/badges */
@keyframes pvtknsFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

/* ==========================================================================
   2. PAGE & ELEMENT ENTRANCE ANIMATIONS
   ========================================================================== */

.page-enter, main, .main-content {
  animation: pvtknsFadeInUp 0.38s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: opacity, transform;
}

.fade-in {
  animation: pvtknsFadeIn 0.3s ease-out forwards;
}

.scale-in {
  animation: pvtknsScaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Staggered entrance for list/card items */
.stagger-item:nth-child(1) { animation-delay: 0.04s; }
.stagger-item:nth-child(2) { animation-delay: 0.08s; }
.stagger-item:nth-child(3) { animation-delay: 0.12s; }
.stagger-item:nth-child(4) { animation-delay: 0.16s; }
.stagger-item:nth-child(5) { animation-delay: 0.20s; }
.stagger-item:nth-child(6) { animation-delay: 0.24s; }

/* ==========================================================================
   3. SHINING & SHIMMER EFFECTS
   ========================================================================== */

/* Shimmer light streak for buttons */
.btn-shine {
  position: relative;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-shine::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    60deg,
    transparent 20%,
    rgba(255, 255, 255, 0.4) 45%,
    rgba(255, 255, 255, 0.7) 50%,
    rgba(255, 255, 255, 0.4) 55%,
    transparent 80%
  );
  transform: translateX(-150%) skewX(-20deg);
  transition: none;
  pointer-events: none;
}

.btn-shine:hover::after,
.btn-shine:focus-visible::after {
  animation: pvtknsShimmer 1.4s ease-in-out infinite;
}

/* Subtle continuous ambient shimmer for primary CTA buttons */
.btn-shine-ambient::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    60deg,
    transparent 25%,
    rgba(255, 255, 255, 0.3) 48%,
    rgba(255, 255, 255, 0.6) 50%,
    rgba(255, 255, 255, 0.3) 52%,
    transparent 75%
  );
  animation: pvtknsShimmer 3.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  pointer-events: none;
}

/* Card glass & top-border sheen */
.card-shine {
  position: relative;
  background-clip: padding-box;
}

.card-shine::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.6) 0%,
    rgba(255, 255, 255, 0.15) 30%,
    rgba(16, 185, 129, 0.1) 70%,
    rgba(250, 204, 21, 0.25) 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* Glowing golden border for hero elements & active status */
.gold-glow {
  box-shadow: 0 0 26px -2px rgba(250, 204, 21, 0.45), 0 6px 18px -2px rgba(6, 78, 59, 0.18);
}

.emerald-glow {
  box-shadow: 0 0 26px -2px rgba(16, 185, 129, 0.45), 0 6px 18px -2px rgba(6, 78, 59, 0.18);
}

.badge-pulse {
  animation: pvtknsGlowPulse 2.4s infinite;
}

.badge-emerald-pulse {
  animation: pvtknsEmeraldPulse 2.4s infinite;
}

/* Floating animation helper */
.icon-float {
  animation: pvtknsFloat 3s ease-in-out infinite;
}

/* ==========================================================================
   4. MICRO-INTERACTIONS & CARD ELEVATION
   ========================================================================== */

/* Enhanced card styles with increased shadows and shining effects */
.card {
  position: relative;
  box-shadow: 0 14px 34px -6px rgba(15, 23, 42, 0.12), 0 8px 18px -3px rgba(20, 83, 45, 0.14), 0 2px 6px -1px rgba(0, 0, 0, 0.05) !important;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s ease !important;
  transform: translateZ(0);
  overflow: hidden;
}

/* Top shining gradient beam for cards */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2.5px;
  background: linear-gradient(90deg, transparent 0%, rgba(250, 204, 21, 0.85) 30%, rgba(16, 185, 129, 0.85) 70%, transparent 100%);
  opacity: 0.55;
  transition: opacity 0.25s ease, height 0.25s ease;
  pointer-events: none;
  z-index: 1;
}

/* Hover light sweep shimmer on cards */
.card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    60deg,
    transparent 20%,
    rgba(255, 255, 255, 0.08) 45%,
    rgba(255, 255, 255, 0.28) 50%,
    rgba(255, 255, 255, 0.08) 55%,
    transparent 80%
  );
  transform: translateX(-150%) skewX(-25deg);
  pointer-events: none;
  z-index: 2;
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    transform: translateY(-4px) translateZ(0) !important;
    box-shadow: 0 24px 50px -8px rgba(15, 23, 42, 0.18), 0 14px 28px -4px rgba(20, 83, 45, 0.22), 0 4px 10px -1px rgba(0, 0, 0, 0.07) !important;
  }

  .card:hover::before {
    opacity: 1;
    height: 3.5px;
  }

  .card:hover::after {
    animation: pvtknsCardSweep 1.1s ease-in-out;
  }

  .interactive-lift {
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .interactive-lift:hover {
    transform: translateY(-3px);
  }
}

/* Tactile mobile tap feedback */
button:active:not(:disabled),
a:active:not([disabled]),
.clickable:active {
  transform: scale(0.975);
}

/* Enhanced table row micro-hover */
tbody tr {
  transition: background-color 0.15s ease;
}

/* ==========================================================================
   5. COMPREHENSIVE ALL-DEVICE & RESPONSIVE SUPPORT
   ========================================================================== */

/* Smooth native scrolling */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

/* Eliminate 300ms mobile touch delay */
button,
a,
input,
select,
textarea,
label {
  touch-action: manipulation;
}

/* iOS tap highlight cleanup */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Safe area insets utilities */
.safe-pt {
  padding-top: max(0.5rem, env(safe-area-inset-top));
}
.safe-pb {
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}
.safe-pl {
  padding-left: max(0.75rem, env(safe-area-inset-left));
}
.safe-pr {
  padding-right: max(0.75rem, env(safe-area-inset-right));
}

/* Mobile table horizontal scroll indicator shadow */
.table-scroll-container {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background:
    /* Shadow Cover */
    linear-gradient(white 30%, rgba(255, 255, 255, 0)),
    linear-gradient(rgba(255, 255, 255, 0), white 70%) 0 100%,
    /* Shadow */
    radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0)),
    radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0)) 0 100%;
  background-repeat: no-repeat;
  background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
  background-attachment: local, local, scroll, scroll;
}

/* Mobile glass bottom dock enhancement */
.mobile-dock-shine {
  background: rgba(6, 78, 59, 0.96) !important;
  backdrop-filter: blur(20px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
  box-shadow: 0 -8px 24px -2px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(250, 204, 21, 0.3) !important;
}

/* Form input focus shine */
input:focus,
select:focus,
textarea:focus {
  transition: all 0.2s ease;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2), 0 2px 8px rgba(6, 78, 59, 0.08) !important;
}

/* Custom modern scrollbars for desktop */
@media (min-width: 1024px) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  ::-webkit-scrollbar-track {
    background: #f1f5f9;
  }
  ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
  }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   7. MOBILE RESPONSIVENESS & TOUCH ENHANCEMENTS
   ========================================================================== */

/* Prevent horizontal page overflow blowouts while preserving smooth vertical scrolling */
html {
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-text-size-adjust: 100%;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

body {
  max-width: 100%;
  overflow-x: clip;
  overflow-y: visible;
  min-height: 100%;
  position: relative;
}

/* Touch manipulation: removes 300ms double-tap delay on mobile */
a, button, input, select, textarea, [role="button"] {
  touch-action: manipulation;
}

/* Smooth momentum scrolling for tables - allows simultaneous vertical page scroll and horizontal table pan */
.overflow-x-auto, .table-responsive, .report-table-scroll {
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-x pan-y !important;
  overscroll-behavior: auto !important;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
}

/* Scroll hint indicator for horizontally scrollable tables */
.table-scroll-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 9999px;
}

@media (min-width: 1024px) {
  .table-scroll-hint {
    display: none;
  }
}

/* Mobile responsive bottom sheet modal behavior (< 640px) */
@media (max-width: 639.98px) {
  .mobile-bottom-sheet-backdrop {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .mobile-bottom-sheet {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 88vh !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 1.5rem !important;
    border-top-right-radius: 1.5rem !important;
    margin-bottom: 0 !important;
    padding-bottom: max(1rem, env(safe-area-inset-bottom)) !important;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease !important;
  }

  .mobile-bottom-sheet.open {
    transform: translateY(0) !important;
  }

  /* Sheet handle bar */
  .mobile-sheet-handle {
    display: block;
    width: 38px;
    height: 4px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 9999px;
    margin: 0.375rem auto 0.5rem auto;
  }
}

@media (min-width: 640px) {
  .mobile-sheet-handle {
    display: none;
  }
}

/* Mobile active tap state */
@media (hover: none) {
  button:active, a.card:active, .btn-touch:active {
    transform: scale(0.97) !important;
    transition: transform 0.1s ease !important;
  }
}

/* ==========================================================================
   8. UNIVERSAL ALL-DEVICE SUPPORT ENHANCEMENTS
   ========================================================================== */

/* Universal container boundary enforcement across all pages */
.card, .page-enter, main, section, form {
  max-width: 100%;
}

/* Responsive table scrolling safeguards on mobile/tablet */
.overflow-x-auto {
  max-width: 100%;
  scrollbar-width: thin;
}

/* Mobile dialog & modal responsive sizing */
@media (max-width: 639.98px) {
  dialog, .modal-content, [role="dialog"] {
    max-width: calc(100vw - 1.25rem) !important;
  }
}


