/* =========================================================
   Lightbox — a full-size image without leaving the page
   Proof is looked at in the middle of doing something else: verifying a fuel
   reading, reading a ticket, checking a receipt against a request. A link with
   target="_blank" throws that away — the reviewer lands on a bare image in a new
   tab, then has to find their way back and remember where they were.

   Loaded from layouts/base.html so every page has it. The markup lives in
   components/lightbox.html and the behaviour in js/components/lightbox.js;
   before this it was copied into three templates with two different ids, and
   .tg-lightbox-card was only ever defined in hr/employees.css — so on the ticket
   form the dialog had no panel, no width limit and no shadow.
   ========================================================= */

.tg-lightbox{
  position: fixed;
  inset: 0;
  z-index: 2000;

  display: none;
  align-items: center;
  justify-content: center;

  padding: 18px;

  background: rgba(0, 0, 0, .55);
}

.tg-lightbox.is-open{
  display: flex;
}

.tg-lightbox-card{
  display: flex;
  flex-direction: column;

  /* Sized by what is in it. A fixed 960px box put a portrait employee photo in
     the middle of a wide grey panel, and a receipt shot the same way; the card
     now takes the image's own width, bounded by the viewport. The header still
     needs room for a title and a close button, hence the floor. */
  width: auto;
  min-width: min(320px, 92vw);
  max-width: min(960px, 96vw);
  max-height: 92vh;

  border-radius: 16px;
  background: var(--panel);
  overflow: hidden;

  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

.tg-lightbox-top{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  flex: 0 0 auto;
  padding: 12px 14px;

  border-bottom: 1px solid var(--border);
}

.tg-lightbox-title{
  font-weight: 900;
  overflow-wrap: anywhere;
}

.tg-lightbox-close{
  flex: 0 0 auto;

  padding: 8px 10px;

  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 10px);
  background: var(--panel);

  font-weight: 900;
  cursor: pointer;
}

.tg-lightbox-close:hover{
  background: var(--bg-soft, #f8fafc);
}

.tg-lightbox-body{
  /* The image scrolls inside the card; the page behind it does not move. */
  flex: 1 1 auto;
  padding: 14px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.tg-lightbox-img{
  display: block;

  /* Its own size, up to the space available — this is what makes the card
     dynamic. width:100% forced every image to the card's width and every card to
     960px, so a tall photo came out stretched and a small one blown up. */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 78vh;
  margin: 0 auto;

  border-radius: var(--radius-sm, 10px);
  transition: transform .15s ease;
}

.tg-lightbox-img.is-zoomed{
  cursor: zoom-out;
}

/* `display: block` above outranks the UA stylesheet's rule for [hidden], so
   without this the img stays laid out when a PDF is showing — and an <img> with
   no src renders as a broken-image icon above the document. */
.tg-lightbox-img[hidden]{
  display: none;
}

.tg-lightbox-meta{
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--muted, #64748b);
}

@media (max-width: 640px){
  .tg-lightbox{
    padding: 10px;
  }

  .tg-lightbox-card{
    width: 100%;
    max-height: 94vh;
  }
}

/* A thumbnail that opens the lightbox. Square, cropped, and obviously
   clickable — the proof strips were each rolling their own inline styles. */
.tg-proof-thumb{
  display: inline-block;

  width: 44px;
  height: 44px;

  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft, #f8fafc);
  overflow: hidden;

  cursor: zoom-in;
}

.tg-proof-thumb img{
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tg-proof-thumb:hover{
  border-color: #f7941d;
}

.tg-proof-strip{
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* A PDF in the same card as an image. Source documents — a customer purchase
   order, a vendor proforma — are almost always PDFs, and the browser's own
   viewer is better than anything worth building, so it gets a frame and room
   to work in. */
.tg-lightbox-pdf{
  display: block;
  width: min(860px, 100%);
  height: 78vh;
  margin: 0 auto;

  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 10px);
  background: var(--bg-soft, #f8fafc);
}

.tg-lightbox-pdf[hidden]{
  display: none;
}

/* Always present on a PDF: a browser that will not render one inline otherwise
   leaves a blank grey panel and no way through to the file. */
.tg-lightbox-download{
  display: inline-block;
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 700;
}

.tg-lightbox-download[hidden]{
  display: none;
}

@media (max-width: 640px){
  .tg-lightbox-pdf{
    height: 70vh;
  }
}
