/* assets/css/custom.css
   Custom Components, Signature Canvas, Stamp Engine & Paper Previews
   Smart Receipt & Digital Invoice Engine - 100% Precision Multi-Device Responsive
*/

/* 1. Universal Layout & Zero Overflow Engine */
html {
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-tap-highlight-color: transparent;
}

/* Universal text break & word wrapping to prevent container collision */
.break-words-safe,
.break-words {
  overflow-wrap: break-word !important;
  word-break: break-word !important;
  word-wrap: break-word !important;
}

/* Responsive Table Wrapper with Touch Momentum Scrolling */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Touch-friendly interactive elements on touch screens */
@media (max-width: 768px) {
  button, 
  a.btn-touch,
  input[type="button"], 
  input[type="submit"], 
  input[type="reset"],
  select,
  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="date"] {
    touch-action: manipulation;
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Paper Previews on Screen */
.paper-preview-container {
  background: #e2e8f0;
  min-height: 480px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
  border-radius: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .paper-preview-container {
    padding: 16px 8px;
    min-height: auto;
    border-radius: 8px;
  }
}

.paper-sheet {
  background: #ffffff;
  box-shadow:
    0 10px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.1);
  transition: all 0.25s ease;
  margin: 0 auto;
  position: relative;
  box-sizing: border-box;
}

/* Paper Screen Formats */
.format-thermal-80 .paper-sheet {
  width: 320px;
  max-width: 100%;
  padding: 16px;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
}

.format-thermal-58 .paper-sheet {
  width: 240px;
  max-width: 100%;
  padding: 12px;
  font-family: "Courier New", Courier, monospace;
  font-size: 11px;
}

.format-invoice-a5 .paper-sheet {
  width: 720px;
  max-width: 100%;
  padding: 20px 24px;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}

.format-invoice-a4 .paper-sheet {
  width: 794px;
  max-width: 100%;
  min-height: 1050px;
  padding: 36px 40px;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}

@media (max-width: 640px) {
  .format-invoice-a5 .paper-sheet {
    padding: 16px 14px;
    min-height: auto;
  }
  .format-invoice-a4 .paper-sheet {
    padding: 20px 16px;
    min-height: auto;
  }
}

/* Signature Pad Canvas */
.signature-canvas-container {
  position: relative;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
  touch-action: none;
}
.signature-canvas {
  display: block;
  width: 100%;
  height: 130px;
  cursor: crosshair;
}

/* Realistic Digital Stamp Component */
.stamp-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border: 3px double #dc2626;
  border-radius: 8px;
  color: #dc2626;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  transform: rotate(-12deg);
  opacity: 0.88;
  user-select: none;
  background: rgba(254, 226, 226, 0.15);
  text-shadow: 0 0 1px rgba(220, 38, 38, 0.4);
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.2);
  position: relative;
}

.stamp-badge.stamp-lunas {
  border-color: #059669;
  color: #059669;
  background: rgba(209, 250, 229, 0.2);
}

.stamp-badge.stamp-paid {
  border-color: #2563eb;
  color: #2563eb;
  background: rgba(219, 234, 254, 0.2);
}

.stamp-badge.stamp-void {
  border-color: #991b1b;
  color: #991b1b;
  background: rgba(254, 202, 202, 0.3);
  text-decoration: line-through;
}

/* Photorealistic Digital Stamp Overlay (Authentic Physical Stamp Impression) */
.stamp-overlay-img {
  position: absolute;
  width: 68px;
  height: 68px;
  left: 50%;
  top: 50%;
  transform: translate(-65%, -50%) rotate(-8deg);
  mix-blend-mode: multiply;
  opacity: 0.92;
  filter: contrast(1.08) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.05));
  pointer-events: none;
  user-select: none;
  z-index: 5;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

@media (min-width: 640px) {
  .stamp-overlay-img {
    width: 76px;
    height: 76px;
    transform: translate(-68%, -50%) rotate(-8deg);
  }
}

/* Thermal Stamp Overlay for POS 80mm & Mini 58mm */
.stamp-overlay-img.thermal-stamp-overlay {
  width: 38px !important;
  height: 38px !important;
  transform: translate(-60%, -50%) rotate(-8deg) !important;
  opacity: 0.92 !important;
}

body.format-thermal-58 .stamp-overlay-img.thermal-stamp-overlay {
  width: 32px !important;
  height: 32px !important;
  transform: translate(-58%, -50%) rotate(-8deg) !important;
}

/* Subtle Shimmer Animation for Live Preview */
@keyframes pulseSubtle {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}
.live-indicator {
  animation: pulseSubtle 2s infinite ease-in-out;
}

/* Toast Notification Floating Container */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast-item {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -4px rgba(0, 0, 0, 0.1);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 640px) {
  .toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
  }
  .toast-item {
    min-width: 100%;
    max-width: 100%;
  }
}

/* Professional SweetAlert2 Responsive Styling */
.swal2-container {
  z-index: 99999 !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 10px !important;
}
.swal2-popup {
  font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
  border-radius: 1.25rem !important;
  padding: 1.5rem 1.25rem !important;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25) !important;
  max-width: calc(100vw - 24px) !important;
}
.swal2-title {
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  color: #1e293b !important;
  padding-top: 0.5rem !important;
}
.swal2-html-container {
  font-size: 0.85rem !important;
  color: #475569 !important;
  line-height: 1.5 !important;
  margin-top: 0.5rem !important;
}
.swal2-actions {
  margin-top: 1.25rem !important;
  gap: 0.5rem !important;
  flex-wrap: wrap !important;
}
.swal2-styled.swal2-confirm,
.swal2-styled.swal2-cancel {
  border-radius: 0.75rem !important;
  padding: 0.625rem 1.25rem !important;
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em !important;
  transition: all 0.2s ease !important;
}
.swal2-styled.swal2-confirm:hover {
  filter: brightness(1.08) !important;
  transform: translateY(-1px) !important;
}
.swal2-styled.swal2-cancel:hover {
  filter: brightness(0.95) !important;
  transform: translateY(-1px) !important;
}
.swal2-toast {
  border-radius: 0.875rem !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
  padding: 0.75rem 1rem !important;
}
.swal2-toast .swal2-title {
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  padding: 0 !important;
}

/* 11. Type-to-Sign Typography Classes & Buttons */
.font-sig-greatvibes {
  font-family: 'Great Vibes', cursive;
}
.font-sig-dancing {
  font-family: 'Dancing Script', cursive;
}
.font-sig-alexbrush {
  font-family: 'Alex Brush', cursive;
}
.font-sig-caveat {
  font-family: 'Caveat', cursive;
}
.font-sig-sacramento {
  font-family: 'Sacramento', cursive;
}
.sig-font-btn {
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease-in-out;
}
.sig-font-btn.active {
  border-color: #6366f1 !important;
  background-color: #eef2ff !important;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25) !important;
}
.sig-color-btn {
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease-in-out;
}
.sig-color-btn.active {
  box-shadow: 0 0 0 2px #6366f1 !important;
  transform: scale(1.1);
}

