/* ============================================================================
   CUSTOMS SCAN — hover tooltip (Shipment Register, root index.html)
   ============================================================================
   Hovering a container cell flagged "selected for customs scan"
   (td.customs-scan-flagged, painted amber by css/enhancements.css) shows a
   small orange chip pinned to the TOP-RIGHT of the cell reading
   "Selected for Customs Scan". The native title attribute (who/when) is kept —
   this chip is the instant, styled label on top of it.

   Deliberately its OWN file: css/enhancements.css is edited by parallel
   sessions (drift landmine) — this file is append-only and conflict-free.

   Placement notes (hard-won register facts):
   - selection overlays own td::after → this chip uses ::before, so a flagged
     cell that is ALSO selected keeps both visuals;
   - the chip floats ABOVE the cell's top-right corner (owner: never cover the
     container number). .table-container is overflow:hidden and the sticky
     thead stacks above the body, so for the FIRST data row the chip flips to
     just BELOW the cell instead — still never covering it;
   - td paint (.customs-scan-flagged) is a background-image layer and the chip
     floats outside it, so neither fights the user's own cell colours.
   ============================================================================ */

@font-face {
    font-family: 'JetBrains Mono';
    src: local('JetBrains Mono Medium'), local('JetBrains Mono'),
         url('../fonts/jetbrains-mono/JetBrainsMono-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

#tableBody td.customs-scan-flagged {
    position: relative;
}

#tableBody td.customs-scan-flagged:hover::before {
    content: 'Selected for Customs Scan';
    position: absolute;
    bottom: calc(100% + 3px);   /* floats above the cell — never covers it */
    right: 0;
    z-index: 40;
    pointer-events: none;
    white-space: nowrap;
    background: #ea580c;                 /* solid orange — same in both themes */
    color: #ffffff;
    border: 1px solid #9a3412;
    border-radius: 3px;
    padding: 3px 8px;
    font-family: 'JetBrains Mono', 'Cascadia Mono', Consolas, 'Courier New', monospace;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.35);
}

/* FIRST data row: above-the-cell would be clipped by .table-container
   (overflow:hidden) / hidden under the sticky thead — flip below the cell. */
#tableBody tr:first-child td.customs-scan-flagged:hover::before {
    bottom: auto;
    top: calc(100% + 3px);
}

/* ── ONE tooltip when the cell ALSO carries a commentary ─────────────────
   Hovering the comment badge opens the comment thread portal (table.js adds
   .with-customs-scan to it for flagged cells, and the strip below labels it).
   While the badge is hovered the chip stands down, so exactly one tooltip is
   ever on screen; hovering the rest of the cell still shows the plain chip. */
#tableBody td.customs-scan-flagged.has-cell-comment:has(.cell-comment-badge:hover):hover::before {
    display: none;
}

/* The merged label: an orange strip at the top of the comment thread portal. */
.cell-comment-tooltip-portal.with-customs-scan::before {
    content: 'Selected for Customs Scan';
    display: block;
    margin: 6px 8px 2px;
    padding: 4px 9px;
    background: #ea580c;
    color: #ffffff;
    border: 1px solid #9a3412;
    border-radius: 3px;
    font-family: 'JetBrains Mono', 'Cascadia Mono', Consolas, 'Courier New', monospace;
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

/* While a select/release write is in flight the cell is striped "busy" —
   suppress the chip so it never labels a state the server hasn't confirmed. */
#tableBody td.customs-scan-flagged.customs-scan-busy:hover::before {
    display: none;
}
