/* ============================================================================
   SIAP - Centralized Custom CSS Keyframes & Micro-Interactions
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. Animated Gradient Mesh & Floating Shapes (Login & Portal)
   ---------------------------------------------------------------------------- */
@keyframes gradientMesh {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.bg-animated-mesh {
    background-size: 260% 260%;
    animation: gradientMesh 14s ease infinite;
}

@keyframes floatSlow {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
    50%      { transform: translate3d(14px, -22px, 0) rotate(6deg); }
}

@keyframes floatMedium {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
    50%      { transform: translate3d(-16px, -16px, 0) rotate(-8deg); }
}

@keyframes floatCard {
    0%, 100% { transform: translateY(0px); }
    50%      { transform: translateY(-10px); }
}

.animate-float-slow   { animation: floatSlow 9s ease-in-out infinite; }
.animate-float-medium { animation: floatMedium 7s ease-in-out infinite; }
.animate-float-card   { animation: floatCard 4.2s ease-in-out infinite; }

/* ----------------------------------------------------------------------------
   2. Page & Card Entrance (Staggered Fade-Up)
   ---------------------------------------------------------------------------- */
@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-slide-up {
    animation: fadeInUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.reveal-up {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.52s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.52s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.reveal-up.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Smooth hover elevation for dashboard cards */
.card-interactive {
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.25s ease,
                border-color 0.25s ease;
}

.card-interactive:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 26px -10px rgba(15, 23, 42, 0.12);
}

/* ----------------------------------------------------------------------------
   3. Error Shake, Toast & Modal Scale-Up Animations
   ---------------------------------------------------------------------------- */
@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-7px); }
    30%, 60%, 90% { transform: translateX(7px); }
}

.animate-shake {
    animation: shakeError 0.48s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes toastIn {
    0%   { opacity: 0; transform: translateY(-10px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-8px) scale(0.96); }
}

.animate-toast-in {
    animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-toast-out {
    animation: toastOut 0.25s ease-in forwards;
}

@keyframes modalScaleIn {
    0%   { opacity: 0; transform: scale(0.93) translateY(8px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes modalScaleOut {
    0%   { opacity: 1; transform: scale(1) translateY(0); }
    100% { opacity: 0; transform: scale(0.94) translateY(6px); }
}

.modal-panel-in {
    animation: modalScaleIn 0.26s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-panel-out {
    animation: modalScaleOut 0.18s ease-in forwards;
}

/* ----------------------------------------------------------------------------
   4. Sidebar & Navigation Micro-Interactions
   ---------------------------------------------------------------------------- */
.sidebar-link {
    position: relative;
    transition: background-color 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
}

.sidebar-link .sidebar-link-inner {
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-link:hover .sidebar-link-inner {
    transform: translateX(4px);
}

.sidebar-link-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 3.5px;
    border-radius: 0 4px 4px 0;
    background: rgba(255, 255, 255, 0.9);
}

@keyframes softBounceBadge {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55); }
    50%      { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}

.animate-pending-badge {
    animation: softBounceBadge 2s ease-in-out infinite;
}

/* Status Badge Hover Scale */
.badge-micro {
    transition: transform 0.18s ease, filter 0.18s ease;
}

.badge-micro:hover {
    transform: scale(1.06);
}

/* ----------------------------------------------------------------------------
   5. Pegawai: Blinking Clock Colon, Shimmer Button, Pulse Ring, GPS Radar & SVG Check
   ---------------------------------------------------------------------------- */
@keyframes colonBlink {
    0%, 49%  { opacity: 1; }
    50%, 100% { opacity: 0.25; }
}

.clock-colon {
    display: inline-block;
    animation: colonBlink 1s steps(1, end) infinite;
}

@keyframes shimmerSweep {
    0%   { transform: translateX(-120%) skewX(-20deg); }
    100% { transform: translateX(260%) skewX(-20deg); }
}

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

.btn-shimmer::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 45%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    animation: shimmerSweep 2.8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pulseRing {
    0%   { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.5); }
    70%  { box-shadow: 0 0 0 12px rgba(20, 184, 166, 0); }
    100% { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0); }
}

.btn-pulse-ring {
    animation: pulseRing 2.2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes gpsRadarWave {
    0%   { transform: scale(0.45); opacity: 0.9; }
    100% { transform: scale(2.4); opacity: 0; }
}

.gps-radar-wave {
    animation: gpsRadarWave 1.8s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.gps-radar-wave-delay {
    animation: gpsRadarWave 1.8s cubic-bezier(0.16, 1, 0.3, 1) 0.9s infinite;
}

/* Animated SVG Checkmark Stroke Draw */
@keyframes drawCircle {
    from { stroke-dashoffset: 166; }
    to   { stroke-dashoffset: 0; }
}

@keyframes drawCheck {
    from { stroke-dashoffset: 48; }
    to   { stroke-dashoffset: 0; }
}

.svg-check-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: drawCircle 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.svg-check-path {
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: drawCheck 0.4s cubic-bezier(0.65, 0, 0.45, 1) 0.35s forwards;
}

/* Daily Work Hours Progress Bar */
.work-progress-fill {
    transition: width 1.1s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ----------------------------------------------------------------------------
   6. Admin & Superadmin: Live Highlight, Row Flash, Slow Spin & Heartbeat
   ---------------------------------------------------------------------------- */
@keyframes softHighlightFade {
    0%   { background-color: rgba(16, 185, 129, 0.16); }
    100% { background-color: transparent; }
}

.row-live-highlight {
    animation: softHighlightFade 2.2s ease-out forwards;
}

@keyframes rowFlashGreen {
    0%   { background-color: rgba(16, 185, 129, 0.28); }
    65%  { background-color: rgba(16, 185, 129, 0.12); }
    100% { background-color: transparent; }
}

.row-flash-success {
    animation: rowFlashGreen 2.4s ease-out forwards;
}

.table-row-smooth {
    transition: background-color 0.2s ease, transform 0.2s ease;
}

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

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

.animate-slow-spin {
    animation: slowSpin 12s linear infinite;
}

@keyframes heartbeatPulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    20%      { transform: scale(1.22); opacity: 1; }
    35%      { transform: scale(1); opacity: 0.9; }
    50%      { transform: scale(1.16); opacity: 1; }
    70%      { transform: scale(1); opacity: 0.85; }
}

.animate-heartbeat {
    animation: heartbeatPulse 2.2s ease-in-out infinite;
}

/* ----------------------------------------------------------------------------
   7. Login Split-Screen SVG Keyframes
   ---------------------------------------------------------------------------- */
.svg-clock-minute {
    transform-box: fill-box;
    transform-origin: center bottom;
    animation: slowSpin 12s linear infinite;
}

.svg-clock-hour {
    transform-box: fill-box;
    transform-origin: center bottom;
    animation: slowSpin 48s linear infinite;
}

@keyframes gpsRipple {
    0%   { transform: scale(0.75); opacity: 0.85; }
    100% { transform: scale(2.15); opacity: 0; }
}

.svg-gps-ring {
    transform-box: fill-box;
    transform-origin: center;
    animation: gpsRipple 2.4s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

.svg-gps-ring-delay {
    transform-box: fill-box;
    transform-origin: center;
    animation: gpsRipple 2.4s cubic-bezier(0.22, 1, 0.36, 1) 1.2s infinite;
}

@keyframes barWave {
    0%, 100% { transform: scaleY(0.55); }
    50%      { transform: scaleY(1); }
}

.svg-bar {
    transform-box: fill-box;
    transform-origin: bottom center;
    animation: barWave 2.8s ease-in-out infinite;
}
.svg-bar-1 { animation-delay: 0s; }
.svg-bar-2 { animation-delay: 0.35s; }
.svg-bar-3 { animation-delay: 0.7s; }
.svg-bar-4 { animation-delay: 1.05s; }

@keyframes badgePulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0px rgba(45, 212, 191, 0.4)); }
    50%      { transform: scale(1.08); filter: drop-shadow(0 0 12px rgba(45, 212, 191, 0.85)); }
}

.svg-check-pulse {
    transform-box: fill-box;
    transform-origin: center;
    animation: badgePulse 2.4s ease-in-out infinite;
}

@keyframes shieldGlow {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.35)); transform: scale(1); }
    50%      { filter: drop-shadow(0 0 22px rgba(251, 191, 36, 0.85)); transform: scale(1.04); }
}

.svg-shield-glow {
    transform-box: fill-box;
    transform-origin: center;
    animation: shieldGlow 3.2s ease-in-out infinite;
}

.svg-gear-cw {
    transform-box: fill-box;
    transform-origin: center;
    animation: slowSpin 16s linear infinite;
}

.svg-gear-ccw {
    transform-box: fill-box;
    transform-origin: center;
    animation: slowSpinReverse 12s linear infinite;
}

@keyframes nodePulse {
    0%, 100% { opacity: 0.45; transform: scale(0.9); }
    50%      { opacity: 1; transform: scale(1.25); }
}

.svg-node {
    transform-box: fill-box;
    transform-origin: center;
    animation: nodePulse 2.6s ease-in-out infinite;
}
.svg-node-2 { animation-delay: 0.65s; }
.svg-node-3 { animation-delay: 1.3s; }
.svg-node-4 { animation-delay: 1.95s; }

@keyframes dashFlow {
    to { stroke-dashoffset: -28; }
}

.svg-network-line {
    stroke-dasharray: 6 8;
    animation: dashFlow 2.5s linear infinite;
}

.glass-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* ----------------------------------------------------------------------------
   8. Animated Character Illustrations (Orang Bergerak di Dashboard Role)
   ---------------------------------------------------------------------------- */
@keyframes charBob {
    0%, 100% { transform: translateY(0px); }
    50%      { transform: translateY(-5px); }
}

.char-bob {
    animation: charBob 3.2s ease-in-out infinite;
}

@keyframes charWaveArm {
    0%, 100% { transform: rotate(0deg); }
    20%      { transform: rotate(-20deg); }
    40%      { transform: rotate(10deg); }
    60%      { transform: rotate(-16deg); }
    80%      { transform: rotate(4deg); }
}

.char-wave-arm {
    transform-box: fill-box;
    transform-origin: bottom left;
    animation: charWaveArm 2.6s ease-in-out infinite;
}

@keyframes charBlink {
    0%, 44%, 48%, 100% { transform: scaleY(1); }
    46%                { transform: scaleY(0.12); }
}

.char-blink {
    transform-box: fill-box;
    transform-origin: center;
    animation: charBlink 4.2s ease-in-out infinite;
}

@keyframes charHeadNod {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(4deg); }
}

.char-head-nod {
    transform-box: fill-box;
    transform-origin: bottom center;
    animation: charHeadNod 3.6s ease-in-out infinite;
}

@keyframes charTapArm {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(-12deg); }
}

.char-tap-arm {
    transform-box: fill-box;
    transform-origin: top left;
    animation: charTapArm 2.1s ease-in-out infinite;
}

@keyframes charTypeLeft {
    0%, 100% { transform: translateY(0px); }
    50%      { transform: translateY(-3px); }
}

@keyframes charTypeRight {
    0%, 100% { transform: translateY(-3px); }
    50%      { transform: translateY(0px); }
}

.char-type-left  { animation: charTypeLeft 0.55s ease-in-out infinite; }
.char-type-right { animation: charTypeRight 0.55s ease-in-out infinite; }

@keyframes popFloat {
    0%, 100% { transform: translateY(0px) scale(1); opacity: 0.9; }
    50%      { transform: translateY(-7px) scale(1.06); opacity: 1; }
}

.char-pop-float       { animation: popFloat 3.4s ease-in-out infinite; }
.char-pop-float-delay { animation: popFloat 3.4s ease-in-out 1.4s infinite; }

/* OTP 6-Digit Input Micro-Interactions */
.otp-digit {
    transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.2s ease,
                border-color 0.2s ease,
                background-color 0.2s ease;
}

.otp-digit:focus {
    transform: translateY(-2px) scale(1.04);
}

.otp-digit.otp-filled {
    background-color: #f8fafc;
}

.otp-digit-pegawai:focus    { border-color: #10b981; box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.22); }
.otp-digit-admin:focus      { border-color: #6366f1; box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.22); }
.otp-digit-superadmin:focus { border-color: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.26); }

/* Face ID Scanner Laser Line & Oval Pulse */
@keyframes faceLaserScan {
    0%   { top: 10%; opacity: 0.2; }
    15%  { opacity: 1; }
    50%  { top: 86%; opacity: 1; }
    85%  { opacity: 1; }
    100% { top: 10%; opacity: 0.2; }
}

.face-laser-line {
    position: absolute;
    left: 12%;
    right: 12%;
    height: 3px;
    border-radius: 9999px;
    background: linear-gradient(90deg, transparent, #34d399, #a7f3d0, #34d399, transparent);
    box-shadow: 0 0 14px rgba(52, 211, 153, 0.9), 0 0 28px rgba(16, 185, 129, 0.6);
    animation: faceLaserScan 2.3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes faceOvalPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45), inset 0 0 16px rgba(52, 211, 153, 0.12); }
    50%      { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0), inset 0 0 24px rgba(52, 211, 153, 0.28); }
}

.face-oval-guide {
    animation: faceOvalPulse 2.4s ease-in-out infinite;
}

/* ----------------------------------------------------------------------------
   9. Accessibility: Respect Reduced Motion Preferences
   ---------------------------------------------------------------------------- */
@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;
    }
    .reveal-up {
        opacity: 1 !important;
        transform: none !important;
    }
}
