/* Basic paystub generator page-specific styles.
   Moved from late inline CSS to a head-loaded stylesheet to prevent initial unstyled layout flash. */

/* ── Template Selector Bar ───────────────────────────────────────── */
.template-selector-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.template-selector-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.template-selector-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.template-selector-cards {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.template-selector-cards::-webkit-scrollbar { display: none; }

/* ── Individual template card ────────────────────────────────────── */
.template-card {
  flex-shrink: 0;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 6px 6px 5px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 96px;
}
.template-card:hover {
  border-color: var(--green);
  box-shadow: 0 2px 8px rgba(121,192,6,0.15);
  transform: translateY(-1px);
}
.template-card.active {
  border-color: var(--green);
  background: #f6faf2;
  box-shadow: 0 0 0 3px rgba(121,192,6,0.18);
}
.template-card-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}
.template-card.active .template-card-name {
  color: var(--green-dark);
}

/* ── Thumbnail image container ───────────────────────────────────── */
.template-card-preview {
  width: 80px;
  height: 60px;
  border-radius: 4px;
  border: 1px solid #e0e8d0;
  overflow: hidden;
  position: relative;
  background: #f8f8f8;
}
.template-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  background: #fff;
  transition: opacity 0.2s;
}
.template-card:hover .template-thumb-img {
  opacity: 0.88;
}

/* Zoom icon overlay */
.template-thumb-zoom {
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  background: rgba(24,32,14,0.65);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
  cursor: zoom-in;
  z-index: 2;
}
.template-card:hover .template-thumb-zoom {
  opacity: 1;
}

/* ── Lightbox ────────────────────────────────────────────────────── */
.tpl-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.tpl-lightbox.open {
  opacity: 1;
  pointer-events: auto;
}
.tpl-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10,20,5,0.82);
  backdrop-filter: blur(4px);
}
.tpl-lightbox-panel {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  width: 90%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tpl-lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tpl-lightbox-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.tpl-lightbox-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tpl-lightbox-select-btn {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.15s;
}
.tpl-lightbox-select-btn:hover { background: var(--green-dark); }
.tpl-lightbox-select-btn.selected {
  background: var(--green-dark);
}
.tpl-lightbox-close {
  background: #f2f4f0;
  border: none;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}
.tpl-lightbox-close:hover { background: #e0e8d0; }
.tpl-lightbox-body {
  overflow-y: auto;
  flex: 1;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #f6faf2;
}
.tpl-lightbox-img {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  display: block;
}
.tpl-lightbox-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  flex-shrink: 0;
}
.tpl-lightbox-wm-note {
  font-size: 11px;
  color: var(--text-3);
  font-style: italic;
}


/* ── Basic generator generic preview (representative preview; final PDF uses selected template) ── */
.basic-generic-preview {
  --basic-accent: #404040;
  --basic-soft: #f3f4f5;
  --basic-mid: #d9dde1;
  width: 100%;
  max-width: 610px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #cfd3d7;
  color: #1e252a;
  font-family: Arial, Helvetica, sans-serif;
  padding: 14px;
  box-sizing: border-box;
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.bgp-topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  background: linear-gradient(90deg, var(--basic-accent), color-mix(in srgb, var(--basic-accent) 72%, #ffffff));
  color: #fff;
  border-radius: 3px;
  margin-bottom: 8px;
}
.bgp-title {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 15px;
  line-height: 1.1;
}
.bgp-subtitle {
  margin-top: 3px;
  font-size: 8px;
  opacity: .78;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.bgp-datebox {
  display: grid;
  gap: 4px;
  min-width: 150px;
  font-size: 8px;
}
.bgp-datebox div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.4);
  padding-bottom: 2px;
}
.bgp-datebox span { opacity: .72; text-transform: uppercase; }
.bgp-datebox strong { font-size: 9px; font-weight: 700; }
.bgp-note {
  border: 1px solid var(--basic-mid);
  background: var(--basic-soft);
  color: #28333a;
  font-size: 8px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 2px;
  margin-bottom: 10px;
}
.bgp-info-grid,
.bgp-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.bgp-info-card,
.bgp-summary-card,
.bgp-notes {
  border: 1px solid var(--basic-mid);
  background: #fff;
  min-height: 74px;
}
.bgp-section-title {
  background: var(--basic-soft);
  color: var(--basic-accent);
  border-bottom: 1px solid var(--basic-mid);
  font-weight: 800;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 5px 7px;
}
.bgp-lines {
  padding: 7px;
  font-size: 9px;
  line-height: 1.35;
}
.bgp-two-col {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 2px 8px;
  padding: 7px;
  font-size: 8.5px;
  line-height: 1.28;
}
.bgp-two-col span {
  color: #576068;
  text-transform: uppercase;
  font-size: 7px;
  letter-spacing: .04em;
}
.bgp-two-col strong {
  font-size: 8.5px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bgp-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  border: 1px solid var(--basic-mid);
  font-size: 8.5px;
  background: #fff;
}
.bgp-table th {
  background: var(--basic-soft);
  color: var(--basic-accent);
  font-size: 7.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--basic-mid);
  border-right: 1px solid var(--basic-mid);
  padding: 5px 6px;
  text-align: left;
}
.bgp-table th:not(:first-child),
.bgp-table td:not(:first-child) { text-align: right; }
.bgp-table th:last-child,
.bgp-table td:last-child { border-right: 0; }
.bgp-table td {
  border-right: 1px solid #e3e6e8;
  border-bottom: 1px solid #e6e8ea;
  padding: 5px 6px;
  font-size: 8.5px;
}
.bgp-muted-row td {
  background: #f8f9f9;
  font-weight: 700;
}
.bgp-summary-card {
  margin-top: 10px;
  min-height: 145px;
}
.bgp-summary-lines {
  grid-template-columns: 1fr auto;
}
.bgp-net {
  margin: 5px 7px 7px;
  border: 1px solid var(--basic-accent);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 10px;
}
.bgp-net span {
  background: var(--basic-accent);
  color: #fff;
  padding: 6px 8px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.bgp-net strong {
  padding: 6px 8px;
  color: var(--basic-accent);
}
.bgp-notes {
  margin-top: 10px;
  min-height: 54px;
}
.bgp-notes > div:last-child {
  padding: 7px;
  font-size: 8px;
  line-height: 1.35;
  color: #4b545b;
}
body[data-doc-type="basic_stub"] .gen-lightbox-body {
  overflow: auto;
  justify-content: flex-start;
  align-items: flex-start;
}
body[data-doc-type="basic_stub"] .gen-lightbox-body .doc-preview,
body[data-doc-type="basic_stub"] .gen-lightbox-body .basic-generic-preview {
  width: 980px;
  max-width: none;
}
body[data-doc-type="basic_stub"] .gen-lightbox-body .basic-generic-preview {
  transform-origin: top left;
}
@media (max-width: 767px) {
  .bgp-info-grid,
  .bgp-bottom-grid { grid-template-columns: 1fr; }
  .basic-generic-preview { padding: 10px; }
  .bgp-topbar { flex-direction: column; }
  .bgp-datebox { min-width: 0; }
  body[data-doc-type="basic_stub"] .gen-lightbox-body .doc-preview,
  body[data-doc-type="basic_stub"] .gen-lightbox-body .basic-generic-preview { width: 780px; }
}

@media (max-width: 640px) {
  .template-selector-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .template-card { width: 84px; }
  .template-card-preview { width: 70px; height: 52px; }
  .tpl-lightbox-panel { width: 96%; max-height: 92vh; }
}
