/* Template gallery — 118px previews + modal carousel */

:root {
  --tpl-preview-min-height: 100px;
  --tpl-modal-width: 2000px;
}

.tpl-card-v2-preview { cursor: zoom-in; }

/* Template strip — evenly fills section width */
.tpl-gallery-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}
@media (min-width: 640px) {
  .tpl-gallery-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
}
@media (min-width: 960px) {
  .tpl-gallery-strip { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
}
@media (min-width: 1200px) {
  .tpl-gallery-strip { gap: 20px; }
}

.tpl-card-compact {
  width: 100%;
  min-width: 0;
  border: 1.5px solid var(--color-border-tertiary, rgba(0, 0, 0, 0.12));
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-background-primary, #fff);
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.tpl-card-compact.on {
  border-color: #dbfb37;
  box-shadow: 0 0 0 2px #dbfb3744;
}
.tpl-card-compact .tpl-card-v2-preview {
  width: 100%;
  height: auto !important;
  aspect-ratio: 118 / 90;
  min-height: var(--tpl-preview-min-height);
  position: relative;
  overflow: hidden;
  background: #f4f4f4;
}
@media (min-width: 960px) {
  .tpl-card-compact .tpl-card-v2-preview { min-height: 130px; }
}
@media (min-width: 1200px) {
  .tpl-card-compact .tpl-card-v2-preview { min-height: 150px; }
}
.tpl-card-compact-name {
  font-family: 'Sora', sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  padding: 6px 4px 4px;
  color: var(--color-text-primary, #282828);
  line-height: 1.2;
}
@media (min-width: 960px) {
  .tpl-card-compact-name { font-size: 12px; padding: 8px 6px 6px; }
}
.tpl-card-compact.on .tpl-card-compact-name {
  color: #3a4a00;
  background: #dbfb3722;
}
.tpl-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid rgba(0, 54, 62, 0.1);
  margin-top: auto;
  min-height: 40px;
}
.tpl-card-preview-btn,
.tpl-card-select-btn {
  width: 100%;
  border: none;
  font-family: 'Lexend', sans-serif;
  font-size: 10px;
  font-weight: 400;
  line-height: 1.2;
  padding: 10px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}
@media (min-width: 960px) {
  .tpl-card-preview-btn,
  .tpl-card-select-btn { font-size: 11px; padding: 11px 6px; }
}
@media (min-width: 1200px) {
  .tpl-card-preview-btn,
  .tpl-card-select-btn { font-size: 12px; padding: 11px 8px; }
}
.tpl-card-preview-btn {
  background: #fff;
  color: var(--go7-secondary, #00363e);
  border-right: 1px solid rgba(0, 54, 62, 0.1);
}
.tpl-card-preview-btn:hover { background: rgba(224, 239, 235, 0.45); }
.tpl-card-preview-btn .ti { font-size: 14px; }
.tpl-card-select-btn {
  background: var(--go7-secondary, #00363e);
  color: var(--go7-primary, #dbfb37);
}
.tpl-card-select-btn:hover { background: var(--go7-secondary-dark, #006f80); }
.tpl-card-compact.on .tpl-card-select-btn {
  background: var(--go7-secondary, #00363e);
  color: var(--go7-primary, #dbfb37);
}
/* Legacy single simulate button (if present) */
.btn-simulate-compact {
  width: 100%;
  border: none;
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
  background: #282828;
  color: #dbfb37;
  font-family: 'Lexend', sans-serif;
  font-size: 10px;
  font-weight: 500;
  padding: 7px 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: auto;
}
@media (min-width: 960px) {
  .btn-simulate-compact { font-size: 11px; padding: 9px 6px; }
}
.btn-simulate-compact:hover { background: #3a3a3a; }
.tpl-card-compact.on .btn-simulate-compact {
  background: #dbfb37;
  color: #3a4a00;
}

/* Mini rendered preview — scales to card width */
.tpl-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.tpl-mini-outer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
}
.tpl-mini-inner {
  transform-origin: top left;
  pointer-events: none;
}
.tpl-thumb-zoom {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 9px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 2;
}
.tpl-card-v2-preview:hover .tpl-thumb-zoom { opacity: 1; }

/* Modal */
.tpl-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.tpl-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}
.tpl-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(var(--tpl-modal-width), 98vw);
  height: min(96vh, 980px);
  background: #1e1e1e;
  border-radius: 16px;
  border: 1px solid #3d3d3d;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.tpl-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid #3d3d3d;
  flex-shrink: 0;
}
.tpl-modal-header h3 {
  margin: 0;
  font-family: 'Sora', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}
.tpl-modal-close {
  background: transparent;
  border: 1px solid #3d3d3d;
  border-radius: 8px;
  color: #e8e8e8;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.tpl-modal-close:hover { border-color: #dbfb37; color: #dbfb37; }

.tpl-carousel-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  padding: 12px 52px;
}
.tpl-carousel-viewport {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.tpl-carousel-track {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.tpl-carousel-slide {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.tpl-carousel-slide-caption {
  flex-shrink: 0;
  margin: 10px 0 0;
  text-align: center;
  font-size: 11px;
  color: #a0a0a0;
}
.tpl-carousel-render-wrap {
  flex: 1;
  min-height: 0;
  background: #2a2a2a;
  border-radius: 10px;
  overflow: auto;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.tpl-carousel-render-outer {
  overflow: hidden;
  flex-shrink: 0;
}
.tpl-carousel-render-inner {
  transform-origin: top left;
}

.tpl-carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #3d3d3d;
  background: rgba(30, 30, 30, 0.95);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tpl-carousel-arrow:hover { border-color: #dbfb37; color: #dbfb37; }
.tpl-carousel-arrow--prev { left: 10px; }
.tpl-carousel-arrow--next { right: 10px; }

.tpl-carousel-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 20px 16px;
  border-top: 1px solid #3d3d3d;
  flex-shrink: 0;
}
.tpl-carousel-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tpl-carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: #555;
  cursor: pointer;
}
.tpl-carousel-dot.on { background: #dbfb37; transform: scale(1.15); }
.tpl-modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.tpl-modal-actions button {
  font-family: 'Lexend', sans-serif;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  padding: 10px 20px;
  cursor: pointer;
}
#tpl-modal-select {
  background: transparent;
  border: 1px solid #3d3d3d;
  color: #e8e8e8;
}
#tpl-modal-select:hover { border-color: #dbfb37; color: #dbfb37; }
#tpl-modal-simulate {
  background: #dbfb37;
  border: none;
  color: #3a4a00;
}
#tpl-modal-simulate:hover { background: #c8e030; }

@media (max-width: 640px) {
  .tpl-carousel-body { padding: 8px 40px; }
  .tpl-carousel-arrow { width: 32px; height: 32px; font-size: 18px; }
  .tpl-modal-actions { flex-direction: column; }
  .tpl-modal-actions button { width: 100%; }
  .tpl-gallery-strip { justify-content: center; }
}
