/* Custom Styles for IT Asset Repair Tracking System */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

body {
  font-family: 'Sarabun', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #f8fafc;
  color: #1e293b;
  overflow-x: hidden;
}

/* Ensure text wrapping everywhere so nothing overflows horizontally */
p, span, div, td, th {
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Responsive Table Container */
.table-responsive-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

/* Badge Glow / Pill effects */
.badge-priority-Critical {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}
.badge-priority-High {
  background-color: #ffedd5;
  color: #9a3412;
  border: 1px solid #fdba74;
}
.badge-priority-Medium {
  background-color: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
}
.badge-priority-Low {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* Status Badges */
.badge-status-Open {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}
.badge-status-InProgress {
  background-color: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}
.badge-status-PendingParts {
  background-color: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #e9d5ff;
}
.badge-status-PendingQuotation,
.badge-status-รอใบเสนอราคา {
  background-color: #fef9c3;
  color: #854d0e;
  border: 1px solid #fef08a;
}
.badge-status-PendingPriceSummary,
.badge-status-รอสรุปราคา {
  background-color: #ffedd5;
  color: #9a3412;
  border: 1px solid #fed7aa;
}
.badge-status-PRCreated,
.badge-status-เปิดPR {
  background-color: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}
.badge-status-SenttoExternalVendor {
  background-color: #ffedd5;
  color: #c2410c;
  border: 1px solid #fed7aa;
}
.badge-status-Resolved {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.badge-status-Closed {
  background-color: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.badge-status-Cancelled {
  background-color: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

/* Smooth fade transition */
.fade-in {
  animation: fadeIn 0.25s ease-in-out;
}

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

/* Modal Backdrop */
.modal-backdrop {
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
}

/* Printable Work Order Sheet */
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 10mm;
  }

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

  /* Hide everything except #printPreviewModal */
  body > *:not(#printPreviewModal) {
    display: none !important;
    visibility: hidden !important;
  }

  /* Make sure #printPreviewModal and children are visible and flow normally */
  #printPreviewModal {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    backdrop-filter: none !important;
    overflow: visible !important;
    visibility: visible !important;
    box-shadow: none !important;
    z-index: auto !important;
  }

  #printModalHeader,
  .no-print {
    display: none !important;
    visibility: hidden !important;
  }

  .no-print-bg {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
  }

  /* The actual sheet rendered to paper */
  #printVoucherSheet {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #0f172a !important;
    box-shadow: none !important;
    border: none !important;
    visibility: visible !important;
    font-size: 11px !important;
    line-height: 1.35 !important;
  }

  #printVoucherSheet,
  #printVoucherSheet * {
    visibility: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  #printVoucherSheet .grid,
  #printVoucherSheet table,
  #printVoucherSheet tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
}

/* ================= SCANNER VIEW & ANIMATION ================= */
#barcodeReader {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  position: relative !important;
}

#barcodeReader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 0.75rem;
}

#qr-shaded-region {
  border-color: rgba(99, 102, 241, 0.4) !important;
}

.scanner-laser-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, #ef4444 20%, #f43f5e 50%, #ef4444 80%, transparent 100%);
  box-shadow: 0 0 8px 1px rgba(239, 68, 68, 0.8), 0 0 16px 2px rgba(244, 63, 94, 0.4);
  animation: scanLaserAnim 2.2s ease-in-out infinite alternate;
}

@keyframes scanLaserAnim {
  0% {
    top: 5%;
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
  100% {
    top: 95%;
    opacity: 0.4;
  }
}

