/* ---------- GENERAL PAGE THEME ---------- */
body {
    background-color: #f8f9fa;  /* soft white-grey background */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
    margin: 0;
    padding: 0;
}

header {
    background-color: #e5e7eb;  /* light grey header */
    color: #111;
    padding: 1rem 2rem;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid #d1d5db;
}

/* ---------- LINKS ---------- */
a {
    color: #2563eb;  /* blue accent for links */
    text-decoration: none;
}
a:hover {
    color: #1e40af;
}

/* ---------- BUTTONS ---------- */
button, .btn {
    background-color: #4b5563;  /* neutral grey button */
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s;
}
button:hover, .btn:hover {
    background-color: #374151;  /* darker grey on hover */
}

/* ---------- CARD STYLING ---------- */
.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ---------- PRINT FORMATS (from your existing setup) ---------- */
@media print {
    body * { visibility: hidden; }
    .print-container.active, .print-container.active * { visibility: visible; }
    .print-container.active {
        position: absolute;
        left: 0; top: 0;
        width: 190mm;
        padding: 15px;
        font-family: Arial, sans-serif;
        font-size: 19pt;
    }
    .no-print { display: none !important; }
}

/* Keep your QR, modal, and grid styling as before */
.print-container { display: none; }
.print-container.active { display: block; }
.hidden-qr { display: none; }

.qr-code-row {
    display: flex; justify-content: space-around; align-items: flex-start;
    gap: 2px;
}

.qr-code-item { display: flex; flex-direction: column; align-items: center; text-align: center; }
.qr-code-item img { width: 175px; height: 180px; }

.modal-backdrop {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); z-index: 50;
    justify-content: center; align-items: center;
}
.modal-backdrop.active { display: flex; }
.modal-content { background: white; padding: 2rem; border-radius: 0.5rem; position: relative; width: 400px; }
.modal-close { position: absolute; top: 0.5rem; right: 0.5rem; background: none; border: none; font-size: 1.5rem; cursor: pointer; }
.blur-content { filter: blur(4px); pointer-events: none; }



/* ---------- SUPPLY CHAIN ANIMATED BACKGROUND (SVG) ---------- */
:root {
    --scn-opacity: 0.55;
    --scn-opacity-dark: 0.35;
    --scn-opacity-subtle: 0.30;
}
.scn-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    /* subtle pattern behind content */
    opacity: var(--scn-opacity);
}
.scn-bg svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ---------- SCANNER OVERLAY (graphical) ---------- */
.scan-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1rem;
}

.scan-box {
    position: relative;
    width: min(520px, 90vw);
    height: 200px;
    border-radius: 16px;
    background: rgba(17, 24, 39, 0.75); /* gray-900 @ 75% */
    box-shadow: 0 10px 30px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.08);
    overflow: hidden;
}

.scan-grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
    background-size: 20px 20px, 20px 20px;
    filter: blur(0.2px);
}

.scan-bar {
    position: absolute;
    left: 0;
    right: 0;
    top: -20%;
    height: 28%;
    background: linear-gradient(to bottom, rgba(74,222,128,0) 0%, rgba(74,222,128,0.45) 40%, rgba(74,222,128,0.55) 60%, rgba(74,222,128,0) 100%);
    box-shadow: 0 0 25px 8px rgba(74,222,128,0.25);
    animation: scanSweep 1.9s linear infinite;
}

.scan-icon {
    position: absolute;
    width: 200px;
    height: 200px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.9;
    fill: rgba(255,255,255,0.85);
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

.scan-text {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    text-align: center;
    padding: 16px 12px;
    background: linear-gradient(to top, rgba(0,0,0,0.45), rgba(0,0,0,0));
}

.scan-dots {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}
.scan-dots span { opacity: 0.2; animation: dots 1.4s infinite; }
.scan-dots span:nth-child(1) { animation-delay: 0s; }
.scan-dots span:nth-child(2) { animation-delay: 0.2s; }
.scan-dots span:nth-child(3) { animation-delay: 0.4s; }

.scan-sub {
    margin-top: 4px;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.8);
}

@keyframes scanSweep {
    0% { top: -28%; }
    100% { top: 100%; }
}

@keyframes dots {
    0%, 20% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* Soft radial gradient wash for extra depth */
.scn-bg::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
      radial-gradient(1200px 800px at 20% 15%, rgba(37, 99, 235, 0.08), transparent 55%),
      radial-gradient(900px 700px at 85% 80%, rgba(16, 185, 129, 0.08), transparent 60%),
      radial-gradient(700px 500px at 60% 30%, rgba(245, 158, 11, 0.05), transparent 55%);
}

/* Per-page variants (apply on <body>) */
.bg-plain .scn-bg { display: none !important; }
.bg-subtle .scn-bg { opacity: var(--scn-opacity-subtle) !important; }

/* Animated dashed flow along routes */
.route {
    stroke-dasharray: 6 12;
    stroke-dashoffset: 0;
}
.anim-flow { animation: scn-flow 12s linear infinite; }
@keyframes scn-flow {
    from { stroke-dashoffset: 0; }
    to   { stroke-dashoffset: -400; }
}

/* Moving trucks horizontally */
.anim-truck-right { animation: scn-right 40s linear infinite; will-change: transform; }
.anim-truck-left  { animation: scn-left  46s linear infinite; will-change: transform; }
@keyframes scn-right {
    from { transform: translateX(0); }
    to   { transform: translateX(1800px); }
}
@keyframes scn-left {
    from { transform: translateX(0); }
    to   { transform: translateX(-1800px); }
}

/* Vertical movement for pallets/boxes */
.anim-box-up   { animation: scn-up   28s linear infinite; will-change: transform; }
.anim-box-down { animation: scn-down 32s linear infinite; will-change: transform; }
@keyframes scn-up   { from { transform: translateY(0); } to { transform: translateY(-1100px); } }
@keyframes scn-down { from { transform: translateY(0); } to { transform: translateY(1100px); } }

/* Parallax panning for route layers */
.layer-far  { animation: scn-pan1 120s linear infinite; will-change: transform; }
.layer-mid  { animation: scn-pan2  90s linear infinite; will-change: transform; }
.layer-near { /* keep static; only icons move for clarity */ }
@keyframes scn-pan1 { from { transform: translate3d(0,0,0); } to { transform: translate3d(-60px,-30px,0); } }
@keyframes scn-pan2 { from { transform: translate3d(0,0,0); } to { transform: translate3d(50px,-40px,0); } }

/* Silhouettes (plane/ship/warehouse) slow glide */
.silhouette { opacity: 0.12; animation: scn-glide 160s linear infinite; filter: blur(0.2px); }
@keyframes scn-glide { from { transform: translate3d(0,0,0); } to { transform: translate3d(-800px,-200px,0); } }

/* Accessibility: reduce motion when requested */
@media (prefers-reduced-motion: reduce) {
    .anim-flow,
    .anim-truck-right,
    .anim-truck-left,
    .anim-box-up,
    .anim-box-down,
    .layer-far,
    .layer-mid,
    .silhouette {
        animation: none !important;
    }
}

/* Small screens: keep it lighter */
@media (max-width: 640px) {
    .layer-far, .silhouette { display: none; }
    /* slightly slower near-layer actors */
    .anim-truck-right { animation-duration: 52s; }
    .anim-truck-left  { animation-duration: 58s; }
    .anim-box-up      { animation-duration: 34s; }
    .anim-box-down    { animation-duration: 38s; }
}

/* Dark mode tweaks */
@media (prefers-color-scheme: dark) {
    .scn-bg { opacity: var(--scn-opacity-dark); }
}

/* ---------- FORMS: INPUTS, SELECTS, ACCESSIBILITY ---------- */
/* Ensure selects and options are readable across browsers and themes */
select,
input,
textarea {
    color: #111827; /* gray-900 */
}

select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #ffffff; /* solid background so text stays visible */
}

select:disabled,
input:disabled,
textarea:disabled {
    color: #6b7280; /* gray-500 */
}

/* Native dropdown options (best-effort, varies by browser) */
option {
    color: #111827; /* gray-900 */
    background: #ffffff;
}

/* Focus ring for accessibility (matches Tailwind focus styles) */
select:focus,
input:focus,
textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.35); /* blue-500 ring */
    border-color: #3b82f6;
}

@media (prefers-color-scheme: dark) {
    /* Keep the site using the same light theme even when the OS is in dark mode */
    body { color: #333; }
    select,
    input,
    textarea {
        background-color: #ffffff; /* force light background */
        color: #111827; /* gray-900 text */
        border-color: #d1d5db; /* gray-300 border */
    }
    option {
        background: #ffffff; /* keep dropdown options light */
        color: #111827;
    }
}



/* ---------- UID LABELS & DATAMATRIX VIEW & PRINT (FINAL VERSION) ---------- */
.uid-scroll-container {
    position: relative;
    max-width: 100%;
    height: 160px;              /* slightly taller for text visibility */
    overflow-x: auto;           /* enable horizontal scroll */
    overflow-y: hidden;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9fafb;
    padding: 6mm;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
.uid-scroll-container::-webkit-scrollbar {
    height: 8px;
}
.uid-scroll-container::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 3px;
}
.uid-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* ---------- SCREEN VIEW: Horizontal Layout with extra spacing ---------- */
.uid-matrix-row {
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-start;
    align-items: flex-start;
    flex-wrap: nowrap !important;
    gap: 35mm !important;       /* 🔹 extra spacing between UIDs */
    white-space: nowrap !important;
}

.uid-matrix-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 45mm;                /* 🔹 more width for long UID text */
    text-align: center;
    vertical-align: top;
}

.uid-matrix-item img {
    width: 10mm !important;
    height: 10mm !important;
    object-fit: contain !important;
}


.uid-text {
    margin-top: 4mm;
    font-size: 10pt;
    font-family: monospace;
    color: #333;
    word-wrap: break-word;
    white-space: normal;        /* 🔹 allow wrapping */
    line-height: 1.2;
}

/* ---------- GLOBAL MOBILE RESPONSIVENESS ---------- */
img, video { max-width: 100%; height: auto; }

/* Small screens: make modals and long rows fit the viewport */
@media (max-width: 640px) {
  .modal-content {
    width: 92vw;
    max-width: 92vw;
    padding: 1rem;
  }

  /* Reduce height of UID scroll area and padding on small screens */
  .uid-scroll-container {
    height: 120px;
    padding: 3mm;
  }

  /* Allow QR rows to wrap nicely and reduce image sizes */
  .qr-code-row {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }
  .qr-code-item img {
    width: 120px;
    height: 120px;
  }

  /* Make UID matrix spacing tighter and allow wrapping for narrow screens */
  .uid-matrix-row {
    gap: 8mm !important;
    flex-wrap: wrap !important;
  }
  .uid-matrix-item {
      width: auto;
      min-width: 10mm;
  }
}
/* Tables: use wrapper for horizontal scroll to keep header/body aligned */
/* Responsive table container: fixed height + scroll (GLOBAL) */
.table-responsive {
    /* Default max height for scrollable tables; can be overridden per instance */
    --table-max-h: 420px;
    --table-header-bg: #f3f4f6; /* gray-100 */
    --table-header-bg-2: #f8fafc; /* slate-50 */
    --table-header-text: #111827; /* gray-900 */
    --table-row-hover: #f1f5f9; /* slate-100 */
    --table-row-stripe: #fafafa; /* neutral-50 */
    --table-border: #e5e7eb; /* gray-200 */

    position: relative;
    max-height: var(--table-max-h);
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;

    background: #ffffff;
    border: 1px solid var(--table-border);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.table-responsive > table {
    width: 100%;
    min-width: 640px;
    border-collapse: separate; /* needed for sticky header with borders */
    border-spacing: 0;
}
/* Keep headers visible while scrolling */
.table-responsive thead th {
    position: sticky;
    top: 0;
    background: linear-gradient(var(--table-header-bg-2), var(--table-header-bg));
    color: var(--table-header-text);
    z-index: 2;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 0 var(--table-border);
}
/* Sort indicators */
th.sort-asc::after,
th.sort-desc::after {
    content: '';
    display: inline-block;
    margin-left: 6px;
    opacity: 0.6;
    font-size: 10px;
}
th.sort-asc::after { content: '▲'; }
th.sort-desc::after { content: '▼'; }
/* Optional: maintain header bottom border when sticky */
.table-responsive thead th,
.table-responsive tbody td,
.table-responsive tbody th {
    border-bottom: 1px solid var(--table-border);
}
/* Rounded header corners inside the wrapper */
.table-responsive thead th:first-child { border-top-left-radius: 8px; }
.table-responsive thead th:last-child { border-top-right-radius: 8px; }

/* Zebra striping & hover states for better readability */
.table-responsive tbody tr:nth-child(even) td { background: var(--table-row-stripe); }
.table-responsive tbody tr:hover td { background: var(--table-row-hover); }

/* Denser cell layout already set globally; keep consistent */
table th, table td { padding: 0.5rem 0.5rem !important; font-size: 12px !important; }

/* Subtle scroll edge hints (horizontal) */
.table-responsive::before,
.table-responsive::after {
    content: "";
    position: absolute;
    top: 0; bottom: 0;
    width: 18px;
    pointer-events: none;
    z-index: 1;
}
.table-responsive::before {
    left: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0.9), rgba(255,255,255,0));
}
.table-responsive::after {
    right: 0;
    background: linear-gradient(270deg, rgba(255,255,255,0.9), rgba(255,255,255,0));
}

/* Scrollbar styling (WebKit) */
.table-responsive::-webkit-scrollbar { height: 10px; width: 10px; }
.table-responsive::-webkit-scrollbar-track { background: #f3f4f6; border-radius: 8px; }
.table-responsive::-webkit-scrollbar-thumb {
    background-color: #cbd5e1; /* slate-300 */
    border-radius: 8px;
    border: 2px solid #f3f4f6;
}
.table-responsive::-webkit-scrollbar-thumb:hover { background-color: #94a3b8; /* slate-400 */ }

/* On small screens, cap height to a portion of the viewport for better UX */
@media (max-width: 640px) {
  .table-responsive { max-height: min(60vh, var(--table-max-h)); }
}

/* Height utility modifiers for tables (override --table-max-h) */
.table-h-320 { --table-max-h: 320px; }
.table-h-420 { --table-max-h: 420px; }
.table-h-600 { --table-max-h: 600px; }

/* Cell helpers (mostly useful on tight layouts) */
.cell-break { word-break: break-word; white-space: normal; }
.cell-nowrap { white-space: nowrap; }

/* Narrow table modifier: allow tables to shrink below global 640px when needed */
.table-responsive.table-narrow > table {
    min-width: 0;
}

/* Tighten the first column (Item) and keep number columns compact */
.table-tight-item th:first-child,
.table-tight-item td:first-child {
    max-width: 14ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.table-tight-item th:nth-child(2),
.table-tight-item td:nth-child(2) {
    width: 6ch;
    white-space: nowrap;
}
.table-tight-item th:nth-child(3),
.table-tight-item td:nth-child(3) {
    width: 6ch;
    white-space: nowrap;
}

/* Realtime Activity table column sizing: keep width fixed, avoid horizontal scroll */
.table-activity th:nth-child(1),
.table-activity td:nth-child(1) {
    /* Time */
    width: 9ch;
    white-space: nowrap;
}
.table-activity th:nth-child(2),
.table-activity td:nth-child(2) {
    /* Event */
    width: 12ch;
    white-space: nowrap;
}
.table-activity th:nth-child(5),
.table-activity td:nth-child(5) {
    /* Qty */
    width: 6ch;
    white-space: nowrap;
    text-align: right;
}
.table-activity td:nth-child(3) {
    /* Details (item/link + id) */
    max-width: 26ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.table-activity td:nth-child(4) {
    /* Location */
    max-width: 18ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .table-activity td:nth-child(3) { max-width: 18ch; }
  .table-activity td:nth-child(4) { max-width: 14ch; }
}

@media print {
  /* Hide interface elements */
  .no-print,
  header,
  form,
  button,
  .btn {
    display: none !important;
  }

  /* Show only the active print container */
  .print-container {
    display: none !important;
  }

  .print-container.active {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;          /* auto fit to page width */
    min-height: 29mm !important;
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    background: #fff !important;
    margin: 0 !important;
    padding: 5mm !important;
    overflow: visible !important;
    z-index: 9999 !important;
    page-break-inside: avoid !important;
  }

  /* Auto-fit UIDs on page */
  .uid-matrix-row {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 3mm !important;
    width: 100% !important;
  }

  .uid-matrix-item {
    flex: 0 1 10mm !important;       /* keep 10 mm width per UID */
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
  }

  .uid-matrix-item img {
    width: 10mm !important;
    height: 10mm !important;
    object-fit: contain !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide UID text when printing */
  .uid-text {
    display: none !important;
  }

  @page {
    size: auto;   /* automatically adjusts to printer/page size */
    margin: 0;
  }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }
}


.bid-print-row img {
    width: 50mm !important;
    height: auto !important;
    object-fit: contain !important;
    margin-bottom: 5mm;
}
.bid-print-row p {
    font-size: 14pt;
    font-family: monospace;
    color: #111;
}

.sidebar {
    width: 300px;
    background-color: #f3f4f6;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* ---------- HOME TICKER ANIMATIONS ---------- */
@keyframes flashGreen {
  0%   { background-color: rgba(16,185,129,0.00); }
  20%  { background-color: rgba(16,185,129,0.18); }
  100% { background-color: rgba(16,185,129,0.00); }
}
@keyframes flashRed {
  0%   { background-color: rgba(239,68,68,0.00); }
  20%  { background-color: rgba(239,68,68,0.18); }
  100% { background-color: rgba(239,68,68,0.00); }
}
.flash-up {
  animation: flashGreen 1.2s ease-out;
}
.flash-down {
  animation: flashRed 1.2s ease-out;
}

