/* =========================================
   1. GLOBAL & SCROLLBAR
   ========================================= */
/* Custom Scrollbar Modern */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Scrollbar Tebal untuk Data Customer Table */
#view-customer .overflow-auto::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

#view-customer .overflow-auto::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-radius: 7px;
}

#view-customer .overflow-auto::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 7px;
  border: 2px solid #e2e8f0;
}

#view-customer .overflow-auto::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

body {
  overflow-x: hidden;
  font-family: "Inter", sans-serif;
}

/* =========================================
   2. UTILITIES (Warna & Animasi)
   ========================================= */
.hidden-section {
  display: none !important;
}

/* Warna Primary (Biru) - PENTING: Agar tombol tidak putih/invisible */
.bg-primary {
  background-color: #2563eb !important;
  /* Tailwind Blue-600 */
  color: white !important;
}

.bg-primary:hover {
  background-color: #1d4ed8 !important;
  /* Tailwind Blue-700 */
}

.text-primary {
  color: #2563eb !important;
}

/* Animasi Fade In halus */
.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================
   3. LAYOUT DASHBOARD
   ========================================= */
#main-content {
  background-color: #f8fafc;
  transition: background-color 0.3s ease;
  height: 100vh;
  overflow-y: auto;
}

.view-section:not(.hidden-section) {
  animation: fadeIn 0.3s ease-out;
}

#view-home {
  display: block;
  padding-bottom: 10rem;
  width: 100%;
  max-width: 100%;
}

/* =========================================
   4. PREVIEW AREA (ESTIMATE & INVOICE)
   ========================================= */

/* Container Preview Estimate (Halaman Penuh tapi di bawah Navbar) */
#view-estimate-preview {
  background-color: #525659;
  /* Abu Gelap PDF Reader */
  width: 100%;
  /* Tinggi layar dikurangi Navbar, agar scroll ada di dalam container ini */
  min-height: calc(100vh - 64px);
  padding: 40px 0 60px 0;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;

  position: relative;
  z-index: 0;
  /* Agar tidak menutupi navbar */
}

/* Container Modal Invoice (Pop-up) */
#modal-content {
  background-color: #525659;
  width: 100%;

  /* Batasi tinggi agar scrollbar muncul di dalam modal */
  height: calc(90vh - 60px);
  overflow-y: auto;

  padding: 30px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

/* =========================================
   5. KERTAS A4 (OPTIMIZED MARGIN)
   ========================================= */
.sheet {
  background-color: white;
  width: 210mm;
  height: 297mm;
  /* Tinggi Fix A4 */

  /* MARGIN HEMAT & OPTIMAL: 
     Atas: 10mm (1cm)
     Bawah: 15mm (1.5cm)
     Kiri/Kanan: 19mm (1.9cm)
  */
  padding: 10mm 19mm 10mm 19mm;

  margin: 0 auto;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
  /* Efek bayangan kertas */
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;

  /* Font default kertas */
  font-size: 10pt;
}

/* =========================================
   6. PRINT SETTINGS (WAJIB)
   ========================================= */
/* =========================================
   6. PRINT SETTINGS (NATIVE BROWSER)
   ========================================= */
/* Aturan print sekarang ditangani via JS (Popup Window) */
@media print {

  /* Force browser to print background colors and images */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Opsional: Sembunyikan elemen jika user menekan Ctrl+P di halaman utama */
  body {}
}

/* Helper untuk mencegah page break di tengah elemen penting (tanda tangan) */
.avoid-break {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}

/* =========================================
   7. MOBILE RESPONSIVE
   ========================================= */
@media screen and (max-width: 768px) {

  /* Sidebar - hidden by default on mobile, toggle with button */
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    height: 100vh;
    width: 16rem;
  }

  #sidebar.show-mobile {
    transform: translateX(0);
  }

  /* Main content fills screen on mobile */
  #main-content {
    width: 100%;
    margin-left: 0 !important;
  }

  /* Dashboard cards - 1 column on mobile */
  #view-home .grid.lg\\:grid-cols-5 {
    grid-template-columns: 1fr !important;
  }

  #view-home .grid.lg\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }

  /* Tables - horizontal scroll */
  .overflow-x-auto {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 600px;
  }

  /* Smaller text on mobile */
  h1 {
    font-size: 1.25rem !important;
  }

  h2 {
    font-size: 1.125rem !important;
  }

  /* Cards - smaller padding */
  .p-6 {
    padding: 1rem !important;
  }

  /* Stats cards - smaller text for numbers */
  #view-home .text-xl {
    font-size: 1rem !important;
  }

  /* Mobile header adjustments */
  #dashboard-view>.flex>nav {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  /* Show mobile menu button */
  #mobile-menu-btn {
    display: flex !important;
  }

  /* Modals - full width on mobile */
  .max-w-4xl,
  .max-w-2xl,
  .max-w-xl,
  .max-w-lg {
    max-width: 95vw !important;
    margin: 0.5rem;
  }

  /* Edit drawer - full width on mobile */
  #edit-invoice-drawer {
    width: 100vw !important;
    max-width: 100vw !important;
  }

  /* Form grids - 1 column on mobile */
  .grid.grid-cols-2 {
    grid-template-columns: 1fr !important;
  }

  /* Settings section on mobile */
  #view-settings .max-w-4xl {
    max-width: 100% !important;
    padding: 1rem !important;
  }
}

/* Mobile overlay for sidebar */
#mobile-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
}

#mobile-sidebar-overlay.show {
  display: block;
}

/* Touch-friendly buttons */
@media (hover: none) and (pointer: coarse) {

  button,
  a,
  select,
  input[type="button"],
  input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
  }
}