/* Custom styles & Print rules for RADHA FASHION Billing & POS */

/* --- WYSIWYG PRINT ENGINE (Mobile Screen to Print 1:1 Match) --- */
@media print {
  @page {
    margin: 0;
  }

  body.print-mode-a4 {
    margin: 6mm 8mm !important;
  }

  html, body {
    height: auto !important;
    min-height: 100% !important;
    overflow: visible !important;
    position: static !important;
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide all interactive app chrome: sidebar, topbar, bottom nav, modals except print target */
  #mainSidebar,
  #mobileDrawerBackdrop,
  #mobileBottomNav,
  header,
  main,
  #view-dashboard,
  #view-create-bill,
  #view-invoices,
  #view-inventory,
  #view-customers,
  #view-settings,
  #toastContainer,
  .no-print,
  #productModal,
  #customerModal,
  #thermalPrinterModal,
  #scannerModal,
  #billBarcodeModal,
  #priceCheckModal,
  #hostingerSqlModal,
  #settingsPasswordModal,
  #pcAppGuideModal,
  #signatureDrawModal {
    display: none !important;
  }

  /* 1. When printing A4 Invoice */
  body.print-mode-a4 #invoiceModal {
    display: block !important;
    position: static !important;
    overflow: visible !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
  }

  body.print-mode-a4 #invoiceModal > div {
    position: static !important;
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  body.print-mode-a4 #invoiceModal header,
  body.print-mode-a4 #invoiceModal .sm\:hidden,
  body.print-mode-a4 #thermalPrintWrapper {
    display: none !important;
  }

  body.print-mode-a4 #invoicePrintSheet {
    display: block !important;
    visibility: visible !important;
    position: static !important;
    width: 100% !important;
    max-width: 210mm !important;
    margin: 0 auto !important;
    padding: 6mm 8mm !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body.print-mode-a4 #invoicePrintSheet * {
    visibility: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 2. When printing 58mm Thermal POS Receipt */
  body.print-mode-thermal-58 #invoiceModal,
  body.print-mode-thermal-80 #invoiceModal {
    display: block !important;
    position: static !important;
    overflow: visible !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
  }

  body.print-mode-thermal-58 #invoiceModal > div,
  body.print-mode-thermal-80 #invoiceModal > div {
    position: static !important;
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  body.print-mode-thermal-58 #invoiceModal header,
  body.print-mode-thermal-80 #invoiceModal header,
  body.print-mode-thermal-58 #invoiceModal .sm\:hidden,
  body.print-mode-thermal-80 #invoiceModal .sm\:hidden,
  body.print-mode-thermal-58 #invoicePrintSheet,
  body.print-mode-thermal-80 #invoicePrintSheet,
  body.print-mode-thermal-58 #thermalPrintWrapper > div:first-child,
  body.print-mode-thermal-80 #thermalPrintWrapper > div:first-child {
    display: none !important;
  }

  body.print-mode-thermal-58 #thermalPrintWrapper,
  body.print-mode-thermal-80 #thermalPrintWrapper {
    display: flex !important;
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
  }

  body.print-mode-thermal-58 #thermalPrintSheet {
    display: block !important;
    visibility: visible !important;
    position: static !important;
    width: 54mm !important;
    max-width: 58mm !important;
    margin: 0 auto !important;
    padding: 2mm 3mm !important;
    box-shadow: none !important;
    border: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 3. When printing 80mm Thermal POS Receipt */
  body.print-mode-thermal-80 #thermalPrintSheet {
    display: block !important;
    visibility: visible !important;
    position: static !important;
    width: 74mm !important;
    max-width: 80mm !important;
    margin: 0 auto !important;
    padding: 3mm 4mm !important;
    box-shadow: none !important;
    border: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12px !important;
    line-height: 1.25 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body.print-mode-thermal-58 #thermalPrintSheet *,
  body.print-mode-thermal-80 #thermalPrintSheet * {
    visibility: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Exclude Counter Slip by default when printing bill (ONLY print bill) */
  body.print-mode-thermal-58 #thCounterSlipSection,
  body.print-mode-thermal-58 #thCounterSlipSection *,
  body.print-mode-thermal-58 #thCounterSlip,
  body.print-mode-thermal-58 .th-counter-slip-section,
  body.print-mode-thermal-80 #thCounterSlipSection,
  body.print-mode-thermal-80 #thCounterSlipSection *,
  body.print-mode-thermal-80 #thCounterSlip,
  body.print-mode-thermal-80 .th-counter-slip-section {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Only if user explicitly enabled include-counter in settings */
  body.print-mode-thermal-58.print-include-counter #thCounterSlipSection,
  body.print-mode-thermal-58.print-include-counter #thCounterSlipSection *,
  body.print-mode-thermal-58.print-include-counter #thCounterSlip,
  body.print-mode-thermal-58.print-include-counter .th-counter-slip-section,
  body.print-mode-thermal-80.print-include-counter #thCounterSlipSection,
  body.print-mode-thermal-80.print-include-counter #thCounterSlipSection *,
  body.print-mode-thermal-80.print-include-counter #thCounterSlip,
  body.print-mode-thermal-80.print-include-counter .th-counter-slip-section {
    display: block !important;
    visibility: visible !important;
    height: auto !important;
  }

  /* 4. When printing Counter Slip Only */
  body.print-mode-counter-slip #thermalCounterSlipPrintSheet,
  body.print-mode-counter-slip #thermalCounterSlipPrintSheet * {
    visibility: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  body.print-mode-counter-slip #thermalCounterSlipPrintSheet {
    display: block !important;
    position: static !important;
    width: 54mm !important;
    max-width: 58mm !important;
    margin: 0 auto !important;
    padding: 2mm !important;
    border: none !important;
    box-shadow: none !important;
    color: #000000 !important;
    background: #ffffff !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
  }

  /* 5. When printing Barcode / QR Labels */
  body.print-mode-labels #barcodeLabelModal {
    display: block !important;
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
  body.print-mode-labels #labelPrintSheet,
  body.print-mode-labels #labelPrintSheet * {
    visibility: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  body.print-mode-labels #labelPrintSheet {
    display: block !important;
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
  }
}

.nav-item {
  color: #94a3b8;
  cursor: pointer;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
}

.nav-item.active {
  background-color: #f59e0b;
  color: #020617;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.nav-item.active i {
  color: #020617 !important;
}

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

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Toast styling */
.toast-msg {
  pointer-events: auto;
  animation: slideInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* High-contrast crisp typography for ESC/POS Thermal output */
.font-thermal {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  color: #000000 !important;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-rendering: optimizeLegibility;
}

#thermalPrintSheet,
#counterSlipViewSheet {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  color: #000000 !important;
  background-color: #ffffff !important;
  line-height: 1.35;
  letter-spacing: 0.015em;
  font-weight: 700;
}

#thermalPrintSheet,
#thermalPrintSheet p,
#thermalPrintSheet span,
#thermalPrintSheet div,
#thermalPrintSheet b,
#thermalPrintSheet strong,
#thermalPrintSheet h2,
#counterSlipViewSheet,
#counterSlipViewSheet p,
#counterSlipViewSheet span,
#counterSlipViewSheet div,
#counterSlipViewSheet b,
#counterSlipViewSheet strong,
#counterSlipViewSheet h2 {
  color: #000000 !important;
  text-rendering: optimizeLegibility;
}

#thermalPrintSheet .font-mono,
#counterSlipViewSheet .font-mono {
  font-family: ui-monospace, SFMono-Regular, "Courier New", monospace !important;
  letter-spacing: 0.035em;
}

#thSlipLogoImg {
  filter: contrast(250%) grayscale(100%);
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
}

#thInvoiceBarcode {
  display: block;
  margin: 0 auto;
  shape-rendering: crispEdges;
  image-rendering: pixelated;
  image-rendering: -webkit-optimize-contrast;
}

.thermal-divider {
  border-top: 2px solid #000000;
  margin: 8px 0;
}

.thermal-divider-double {
  border-top: 3px double #000000;
  margin: 8px 0;
}

/* --- GLOBAL SMOOTHNESS & 60FPS/120FPS PERFORMANCE ENGINE (Mobile App & PC Web) --- */
* {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

html, body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  touch-action: pan-x pan-y;
}

/* Eliminate 300ms mobile touch delay across all buttons, inputs, tabs & links */
button, a, input, select, label, .cursor-pointer, .nav-item, .mobile-nav-btn {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

/* Butter-smooth momentum scrolling on Android WebView & Mobile Safari/Chrome */
main, .view-panel, .overflow-y-auto, .overflow-x-auto {
  -webkit-overflow-scrolling: touch !important;
  scroll-behavior: smooth;
}

/* Hardware accelerated composition for sticky bars and modals */
#mobileBottomNav, header, .toast-msg {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Performance containment for list rows to prevent layout thrashing */
tr {
  contain: layout style;
}

/* Mobile Off-Canvas Drawer Architecture */
@media (max-width: 767px) {
  #mainSidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 288px !important;
    max-width: 86vw !important;
    transform: translateX(-100%) !important;
    -webkit-transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.2, 0, 0, 1), visibility 0.28s !important;
    will-change: transform;
    z-index: 50 !important;
    visibility: hidden;
    pointer-events: none;
    box-shadow: none !important;
  }

  #mainSidebar.translate-x-0,
  #mainSidebar.drawer-open {
    transform: translateX(0) !important;
    -webkit-transform: translateX(0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
    box-shadow: 10px 0 40px -5px rgba(0, 0, 0, 0.75) !important;
  }

  #mobileDrawerBackdrop {
    display: none;
    transition: opacity 0.24s ease-out;
  }
  #mobileDrawerBackdrop.active,
  #mobileDrawerBackdrop:not(.hidden) {
    display: block !important;
  }
}

@media (min-width: 768px) {
  #mainSidebar {
    position: static !important;
    transform: none !important;
    -webkit-transform: none !important;
    visibility: visible !important;
    pointer-events: auto !important;
    display: flex !important;
    width: 16rem !important;
  }
  #mobileDrawerCloseBtn {
    display: none !important;
  }
  #mobileDrawerBackdrop {
    display: none !important;
  }
}

/* Ensure QR Code and Barcode prints cleanly without clipping */
#thQrCodeBox canvas,
#thQrCodeBox img,
#invA4QrBox canvas,
#invA4QrBox img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Hardware accelerated video rendering for barcode scanner */
#barcodeScannerReader {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: #020617;
  isolation: isolate;
}

#barcodeScannerReader video {
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  border-radius: 12px;
  display: block !important;
  margin: 0 auto;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

#barcodeScannerReader canvas {
  display: none !important;
}

#barcodeScannerReader__scan_region {
  border-radius: 12px;
  overflow: hidden;
  width: 100% !important;
  height: 100% !important;
}

