/* ==============================================================================
   CIMORY MDS RETAIL OPS DASHBOARD - MODERN DESIGN SYSTEM
   ============================================================================== */

/* Global Cloak Fix */
[x-cloak] {
  display: none !important;
}

@layer base {
  [x-cloak] {
    display: none !important;
  }
}

/* Global Viewport & Mobile Auto-Zoom Lock */
html {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
}

body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
  position: relative !important;
  -webkit-overflow-scrolling: touch;
}

/* Prevent mobile browser from auto-zooming into inputs */
@media screen and (max-width: 768px) {
  input[type="text"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important; /* 16px is required by iOS/Android to prevent auto-zoom */
  }
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

.dark ::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.4);
  border-radius: 4px;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.7);
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.5);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.8);
}

/* Glassmorphism & Header */
.glass-nav {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.glass-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.dark .glass-card {
  background: rgba(30, 41, 59, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(51, 65, 85, 0.7);
}

/* HTML5 Date Input Polish */
input[type="date"] {
  cursor: pointer;
  position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.7;
  padding: 2px;
  transition: opacity 0.15s ease;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

.dark input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
}

/* Loading Shimmer Animation */
@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(200%);
  }
}

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

.animate-shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 1.8s infinite;
}

.dark .animate-shimmer::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}

/* Progress Bar Top Animation (GPU-Accelerated 60fps) */
@keyframes loading-progress {
  0% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(0%);
  }
  100% {
    transform: translateX(100%);
  }
}

.animate-loading-bar {
  animation: loading-progress 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  will-change: transform;
}

/* Pulse Glow */
@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
    border-color: rgba(99, 102, 241, 0.5);
  }
  50% {
    box-shadow: 0 0 35px rgba(56, 189, 248, 0.7);
    border-color: rgba(56, 189, 248, 0.9);
  }
}

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

/* Skeleton Loading Helpers */
.skeleton-box {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.5rem;
}

.dark .skeleton-box {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Leaflet Map Styling */
.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  padding: 4px;
}

.dark .leaflet-popup-content-wrapper {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

.dark .leaflet-popup-content-wrapper p,
.dark .leaflet-popup-content-wrapper span,
.dark .leaflet-popup-content-wrapper div {
  color: #f8fafc;
}

.dark .leaflet-popup-content-wrapper .text-slate-900,
.dark .leaflet-popup-content-wrapper p.font-bold {
  color: #ffffff !important;
}

.dark .leaflet-popup-content-wrapper .text-slate-600,
.dark .leaflet-popup-content-wrapper .text-slate-500 {
  color: #94a3b8 !important;
}

.dark .leaflet-popup-content-wrapper .border-slate-200 {
  border-color: #334155 !important;
}

.dark .leaflet-popup-tip {
  background: #0f172a;
}

/* Reset Leaflet Div Icon Bawaan agar tidak kotak putih */
.leaflet-div-icon,
.custom-map-pin-container,
.numbered-pin-wrapper {
  background: transparent !important;
  border: none !important;
}

/* Leaflet Enhanced Pin Styling & Route Badges */
.custom-map-pin {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: block;
}

.custom-map-pin:hover {
  transform: scale(1.3);
  z-index: 1000 !important;
}

.numbered-route-pin {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 50% !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  font-size: 11px !important;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4) !important;
  border: 2px solid #ffffff !important;
  transition: all 0.2s ease !important;
  user-select: none !important;
  box-sizing: border-box !important;
}

.numbered-route-pin:hover {
  transform: scale(1.25);
  z-index: 2000 !important;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.7) !important;
}

.pulse-target-pin {
  border-radius: 50% !important;
  animation: map-pulse 1.8s infinite !important;
  box-sizing: border-box !important;
}

@keyframes map-pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7); }
  70% { transform: scale(1.15); box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* Modal Transitions */
.modal-enter {
  opacity: 0;
  transform: scale(0.95);
}

.modal-enter-active {
  opacity: 1;
  transform: scale(1);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-leave-active {
  opacity: 0;
  transform: scale(0.95);
  transition: all 0.15s ease-in;
}

/* Responsive & Mobile Touch Optimizations */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.touch-scroll {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

@media (max-width: 640px) {
  /* Mobile padding & font optimizations */
  .glass-card {
    border-radius: 1rem;
  }
  
  /* Table touch horizontal scroll indicator hint */
  .table-responsive-wrapper {
    position: relative;
  }
  
  /* Ensure canvas within cards doesn't clip on small phones */
  #wa-infographic-card {
    min-width: 100%;
    padding: 1rem !important;
  }
}

/* ==============================================================================
   MOBILE PERFORMANCE OVERDRIVE (<= 768px)
   Mematikan shader backdrop-filter berat & memaksa hardware acceleration
   ============================================================================== */
.animate-spin {
  will-change: transform;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

@media screen and (max-width: 768px) {
  /* Matikan filter backdrop-filter blur di HP agar GPU tidak drop fps */
  .glass-card,
  .glass-nav,
  header,
  nav,
  [class*="backdrop-blur"] {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  /* Warna solid bersih & ringan di HP */
  .glass-card {
    background: #ffffff !important;
    border-color: rgba(226, 232, 240, 0.9) !important;
  }
  .dark .glass-card {
    background: #1e293b !important;
    border-color: rgba(51, 65, 85, 0.8) !important;
  }

  header.fixed {
    background: #ffffff !important;
  }
  .dark header.fixed {
    background: #0f172a !important;
  }

  nav.glass-card {
    background: #ffffff !important;
  }
  .dark nav.glass-card {
    background: #0f172a !important;
  }

  /* Matikan animasi box-shadow berat di HP */
  .animate-pulse-glow {
    animation: none !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15) !important;
  }

  /* Optimalkan animasi spinner */
  .animate-spin {
    animation-duration: 0.75s !important;
  }

  /* Off-screen Card Lazy Rendering: Menghemat proses render layout kartu di HP */
  .space-y-6 > .glass-card {
    content-visibility: auto;
    contain-intrinsic-size: 1px 250px;
  }
}

/* ============================================================================== */
/* PRINT STYLESHEET: LAPORAN ABSENSI BULANAN (HR TIMESHEET A4)                     */
/* ============================================================================== */
@media print {
  body * {
    visibility: hidden !important;
  }
  #timesheet-print-area,
  #timesheet-print-area * {
    visibility: visible !important;
  }
  #timesheet-print-area {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 5mm 10mm !important;
    background: #ffffff !important;
    color: #000000 !important;
    display: block !important;
    font-size: 10px !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  @page {
    size: A4 portrait;
    margin: 8mm 10mm;
  }
}
