/* Invoice templates: the template gallery (/product/templates) and the
   sample invoice downloads on the industry pages. Loaded only by those two
   components (templates/components/template_gallery.php and
   sample_invoice_download.php), not with styles.css on every page. */

.it-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.it-hint {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  font-size: 15px;
  color: var(--pewter);
}

/* ── Colour picker ─────────────────────────────────────────────────── */
.it-colors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: var(--space-4) auto 0;
  max-width: 640px;
}
.it-colors[hidden] { display: none; }
.it-swatch {
  position: relative;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(13, 27, 42, 0.12);
  transition: transform var(--transition-fast);
}
.it-swatch:hover { transform: scale(1.08); }
.it-swatch[aria-checked="true"] {
  box-shadow: 0 0 0 2px var(--white-canvas), 0 0 0 4px var(--carbon);
}
.it-swatch:focus-visible {
  outline: 2px solid var(--billr-blue);
  outline-offset: 4px;
}
.it-swatch--custom {
  overflow: hidden;
  background: conic-gradient(#C44A4A, #E84B8A, #7B32B8, #2760D0, #359350, #FF9500, #C44A4A);
}
.it-swatch--custom input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
}
.it-swatch--custom:focus-within {
  outline: 2px solid var(--billr-blue);
  outline-offset: 4px;
}

/* ── Cards ─────────────────────────────────────────────────────────── */
.it-grid { margin-top: var(--space-5); }
.it-card {
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
}
.it-frame {
  --it-scale: 0.3;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 794 / 1123;
  margin-bottom: var(--space-4);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--cloud-gray);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: zoom-in;
  box-shadow: 0 8px 24px rgba(13, 27, 42, 0.08);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.it-frame:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(13, 27, 42, 0.12);
}
.it-frame:focus-visible {
  outline: 2px solid var(--billr-blue);
  outline-offset: 3px;
}
.it-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  transition: opacity var(--transition-fast);
}
.it-live {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}
.it-live .it-doc {
  width: 794px;
  transform: scale(var(--it-scale));
  transform-origin: top left;
}
.it-card.is-live .it-live { opacity: 1; }
.it-card.is-live .it-frame img { opacity: 0; }
.it-pdf {
  margin-top: auto;
  align-self: flex-start;
  padding: 8px 0 0;
  border: 0;
  background: none;
  color: var(--billr-blue);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.it-pdf:hover { text-decoration: underline; }
.it-pdf[disabled] { color: var(--slate); cursor: progress; }
.it-pdf[hidden] { display: none; }

.it-status {
  min-height: 1.5em;
  margin-top: var(--space-3);
  text-align: center;
  font-size: 14px;
  color: var(--pewter);
}

/* ── Enlarged view ─────────────────────────────────────────────────── */
html.it-dialog-open { overflow: hidden; }
.it-dialog {
  width: min(900px, calc(100vw - 32px));
  max-width: none;
  height: calc(100dvh - 48px);
  max-height: none;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--light-ash);
  color: var(--carbon);
  box-shadow: 0 24px 64px rgba(13, 27, 42, 0.3);
}
.it-dialog[open] { display: flex; flex-direction: column; }
.it-dialog::backdrop { background: rgba(13, 27, 42, 0.6); }
.it-dialog-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--white-canvas);
  border-bottom: 1px solid var(--cloud-gray);
}
.it-dialog-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.it-icon {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--cloud-gray);
  border-radius: 50%;
  background: var(--white-canvas);
  color: var(--carbon);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.it-icon:hover { background: var(--light-ash); }
.it-icon:focus-visible { outline: 2px solid var(--billr-blue); outline-offset: 2px; }
.it-dialog-pdf { flex: none; }
.it-dialog-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: var(--space-4);
}
.it-dialog-doc {
  margin: 0 auto;
  overflow: hidden;
  transition: opacity var(--transition-fast);
}
.it-dialog-doc .it-doc {
  width: 794px;
  transform-origin: top left;
  background: #fff;
}
.it-dialog.is-loading .it-dialog-doc { opacity: 0.4; }

@media (max-width: 600px) {
  .it-dialog { width: 100vw; height: 100dvh; border-radius: 0; }
  .it-dialog-bar { flex-wrap: wrap; padding: var(--space-2) var(--space-3); }
  .it-dialog-title { order: -1; flex-basis: 100%; text-align: left; }
  .it-dialog-pdf { margin-left: auto; padding: 8px 14px; font-size: 14px; }
  .it-dialog-body { padding: var(--space-2); }
}

/* ── Industry page download block ──────────────────────────────────── */
.it-download-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--space-7);
  align-items: center;
}
.it-download-preview { margin: 0; }
.it-download-preview img {
  display: block;
  width: 100%;
  max-width: 440px;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--cloud-gray);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: 0 24px 48px rgba(13, 27, 42, 0.1), 0 8px 16px rgba(13, 27, 42, 0.05);
}
.it-download-body .heading-lg { margin: var(--space-2) 0 var(--space-3); }
.it-download-actions { margin-top: var(--space-5); }
.it-download-actions[hidden] { display: none; }
.it-select {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: 15px;
  font-weight: 600;
  color: var(--carbon);
}
.it-select select {
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--pale-silver);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  font-weight: 400;
  color: var(--carbon);
}
.it-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.it-buttons .btn[disabled] { opacity: 0.6; cursor: progress; }
.it-download .it-status { text-align: left; }
.it-note {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--light-ash);
  font-size: 15px;
  line-height: 1.55;
  color: var(--graphite);
}
.it-note a { color: var(--billr-blue); font-weight: 600; }

@media (max-width: 860px) {
  .it-download-grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
  .it-download-preview { order: 2; }
  .it-download-preview img { max-width: 360px; }
}
@media (max-width: 480px) {
  .it-buttons .btn { flex: 1 1 100%; justify-content: center; }
}
