/* --- UTILITIES & ANIMATION --- */

/* Smooth sidebar push transition for main content wrapper */
#main-wrapper {
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}


.modal-scroll::-webkit-scrollbar {
  width: 6px;
}

.modal-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.modal-scroll::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 10px;
}

.modal-scroll::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

.modal-scroll {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  -webkit-overflow-scrolling: touch;
}

/* Disable animations during background refresh */
body.is-bg-refresh .fade-in {
  animation: none !important;
  transform: none !important;
  opacity: 1 !important;
}

.custom-scroll::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.custom-scroll::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.custom-scroll::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}

.custom-scroll::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

/* Premium Thin Scrollbar for Horizontal Navigation */
.custom-scrollbar::-webkit-scrollbar {
  height: 3px; /* Extra thin for horizontal */
  width: 4px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(37, 99, 235, 0.2);
  border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(37, 99, 235, 0.5);
}
.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: rgba(37, 99, 235, 0.2) transparent;
}

#sync-loading {
  transition: opacity 0.3s ease-in-out, visibility 0.3s;
}

#sync-loading.hidden {
  display: flex !important; /* Keep flex for transition */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.fade-in {
  animation: fadeIn 0.15s ease-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

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

.btn-press:active {
  transform: scale(0.98);
}

@keyframes bounceShort {

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

  50% {
    transform: translateY(-3px);
  }
}

.animate-bounce-short {
  animation: bounceShort 0.5s ease-in-out 1;
}

/* PREMIUM UI COMPONENT STYLES */
.sidebar-item-active {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white !important;
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.glass-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

.regio-group-container {
  position: relative;
  padding-left: 1rem;
  border-left: 2px solid #f1f5f9;
}

/* --- CALENDAR GRID --- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background-color: #e2e8f0;
}

.calendar-day {
  background-color: white;
  min-height: 120px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background-color 0.2s;
}

.calendar-day:hover {
  background-color: #f8fafc;
}

.calendar-day.other-month {
  background-color: #f1f5f9;
  color: #94a3b8;
}

.calendar-day.today {
  background-color: #eff6ff;
  border: 1px solid #3b82f6;
}

/* Responsive Grid for Calendar */
@media screen and (max-width: 640px) {
  .calendar-day-cell {
    min-height: 80px !important;
    padding: 4px !important;
  }
  .calendar-day-cell span.text-sm {
    font-size: 10px !important;
  }
}

.no-scrollbar::-webkit-scrollbar {
  display: NONE;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.horizontal-scroll-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* =========================================
   STYLE CETAK & PREVIEW (UPDATED FLEXIBLE)
   ========================================= */

/* 1. TAMPILAN PREVIEW (Layar HP/Laptop) */
#print-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #525659;
  z-index: 99999;
  overflow-y: auto;
  display: none;
  /* FIX: Hide by default */
}

/* Kertas di Layar Preview 
   Kita set min-height cukup tinggi agar terlihat seperti F4 di layar,
   tapi ini hanya visual di layar laptop/HP.
*/
.print-page-wrapper {
  width: 800px;
  max-width: 95vw;
  min-height: auto;
  padding: 30px;
  background-color: white;
  margin: 20px auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
  position: relative;
  color: #1e293b;
  font-family: 'Inter', sans-serif;
}

/* Responsif Kertas di HP */
@media screen and (max-width: 768px) {
  .print-page-wrapper {
    width: 98%;
    margin: 10px auto;
    padding: 20px 15px;
    min-height: auto;
    font-size: 10pt;
  }
}

/* 2. MODE CETAK (Saat Printer Jalan) */
@media print {
  @page {
    size: A4 portrait;
    margin: 15mm;
  }

  body,
  html {
    background-color: white !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* STRATEGI NUCLEAR HIDE: Sembunyikan segalanya selain container laporan */
  body.printing-report > *:not(#print-container) {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
  }

  /* Tampilkan hanya container laporan di posisi nol */
  #print-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    background: white !important;
    z-index: 99999 !important;
    overflow: visible !important;
    visibility: visible !important;
  }

  /* Reset Wrapper untuk Printer */
  .print-page-wrapper {
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    height: auto !important;
    page-break-after: always;
    break-after: page;
  }

  .break-inside-avoid {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}
  .print-page-wrapper:last-child {
    page-break-after: auto;
  }
}

/* Helper Class for Unified PDF Export (Machine Margins) */
.pdf-export-mode .print-page-wrapper {
  padding: 0 !important;
  margin: 0 !important;
  width: 100% !important;
  border: none !important;
  box-shadow: none !important;
}

.pdf-export-mode .print-page-wrapper:first-child {
  padding-top: 0 !important;
}

/* Force elements with break-inside-avoid to stay together during PDF capture */
.pdf-export-mode .break-inside-avoid {
  page-break-inside: avoid !important;
  break-inside: avoid-page !important;
  display: block !important;
  overflow: visible !important;
  /* Prevent clipping during slicing */
}

/* --- 3. LAYOUT DENSITY MODES (Preview & Print) --- */
/* Compact Mode */
body.print-compact .print-page-wrapper {
  padding: 10mm 15mm !important;
  font-size: 9pt !important;
}

body.print-compact h1 {
  font-size: 16pt !important;
  margin-bottom: 2px !important;
}

body.print-compact h2 {
  font-size: 12pt !important;
  margin-bottom: 4px !important;
}

body.print-compact h3 {
  font-size: 10pt !important;
  padding-bottom: 2px !important;
}

body.print-compact p,
body.print-compact td,
body.print-compact li {
  font-size: 9pt !important;
  line-height: 1.3 !important;
}

body.print-compact .mb-4 {
  margin-bottom: 8px !important;
}

body.print-compact .mb-6 {
  margin-bottom: 12px !important;
}

body.print-compact .p-6 {
  padding: 12px !important;
}

body.print-compact .gap-6 {
  gap: 12px !important;
}

/* Relaxed Mode */
/* Relaxed Mode */
body.print-relaxed .print-page-wrapper {
  padding: 20mm 25mm !important;
  font-size: 11pt !important;
}

body.print-relaxed h1 {
  font-size: 20pt !important;
  margin-bottom: 8px !important;
}

body.print-relaxed h2 {
  font-size: 14pt !important;
  margin-bottom: 8px !important;
}

body.print-relaxed h3 {
  font-size: 12pt !important;
  padding-bottom: 6px !important;
}

body.print-relaxed p,
body.print-relaxed td,
body.print-relaxed li {
  font-size: 11pt !important;
  line-height: 1.6 !important;
}

body.print-relaxed .mb-4 {
  margin-bottom: 20px !important;
}

body.print-relaxed .mb-6 {
  margin-bottom: 24px !important;
}

body.print-relaxed .p-6 {
  padding: 20px !important;
}

body.print-relaxed .gap-6 {
  gap: 20px !important;
}

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

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

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

#sync-banner button {
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

#sync-banner button:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.5);
}

/* --- TOAST STYLES --- */
.toast-item {
  animation: slideInUp 0.3s ease-out forwards;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

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

.toast-item.fade-out {
  animation: fadeOutDown 0.3s ease-in forwards;
}

@keyframes fadeOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

/* --- HMS WIZARD TABS & MSI STYLES --- */
.hms-tab-btn {
  position: relative;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: #64748b;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-bottom: 2px solid transparent;
}

.hms-tab-btn:hover {
  color: #3b82f6;
  background-color: #eff6ff;
}

.hms-tab-btn.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

.hms-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: 2px;
}

.hms-tab-btn {
  padding: 1rem 1.5rem;
  font-size: 0.75rem;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.hms-tab-btn.active {
  color: #059669;
  border-bottom-color: #10b981;
  background-color: #f0fdf4;
}

.correction-toggle-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.75rem;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  transition: all 0.2s;
}

.correction-toggle-container:has(input:checked) {
  background-color: #f0fdf4;
  border-color: #4ade80;
}

.msi-syndrome-badge {
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  background-color: #f1f5f9;
  color: #475569;
}

.msi-correction-hit {
  animation: pulse-green 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-green {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .7;
  }
}
/* --- MOBILE RESPONSIVE FIXES --- */
@media screen and (max-width: 640px) {
    #page-title { font-size: 1rem !important; line-height: 1.2; max-width: 180px; white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .qualifier-group { display: flex !important; flex-wrap: wrap !important; gap: 4px !important; }
    .qualifier-btn { padding: 4px 8px !important; font-size: 10px !important; min-width: 32px; }
    .advanced-table-container { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
    .advanced-table-container table { min-width: 450px; }
}

@keyframes pulse-subtle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(0.99); }
}
.animate-pulse-subtle {
  animation: pulse-subtle 3s ease-in-out infinite;
}

@keyframes pulse-green-glow {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.animate-pulse-green {
  animation: pulse-green-glow 1s ease-out;
}

/* --- LIVE SCHEDULE HIGHLIGHT --- */
@keyframes pulse-day-bg {
  0% { background-color: white; }
  50% { background-color: #dbeafe; box-shadow: inset 0 0 15px rgba(37, 99, 235, 0.2); }
  100% { background-color: white; }
}

.pulse-day-update {
  animation: pulse-day-bg 2.5s ease-in-out infinite !important;
  border: 2px solid #3b82f6 !important;
  z-index: 10;
  border-radius: 12px !important;
}

.pulse-day-update::after {
  content: 'BARU';
  position: absolute;
  top: -5px;
  right: -5px;
  background: #3b82f6;
  color: white;
  font-size: 7px;
  font-weight: 900;
  padding: 2px 4px;
  border-radius: 4px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  animation: fadeIn 0.3s ease-out;
}

/* ANIMASI KHUSUS JADWAL & PASIEN */
@keyframes blink-rose {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.98); background-color: #be123c; }
}

.label-blink {
  animation: blink-rose 1.5s infinite;
}

/* Custom Scrollbar for Form Modals */
#modal-content::-webkit-scrollbar {
  width: 6px;
}
#modal-content::-webkit-scrollbar-track {
  background: transparent;
}
#modal-content::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 10px;
}
#modal-content::-webkit-scrollbar-thumb:hover {
  background: #cbd5e1;
}
