/* ====================================================
   SaaS Template Picker
   ==================================================== */

.saasTP-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.saasTP-overlay.saasTP-visible {
  opacity: 1;
}

.saasTP-modal {
  width: min(1220px, 100%);
  height: min(860px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #dbe4f0;
  border-radius: 28px;
  background: #f8fbff;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.18);
  transform: translateY(22px) scale(0.985);
  transition: transform 0.26s ease;
}

.saasTP-overlay.saasTP-visible .saasTP-modal {
  transform: translateY(0) scale(1);
}

.saasTP-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.saasTP-hdr-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.saasTP-hdr-h {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.03em;
}

.saasTP-hdr-sub {
  margin-top: 4px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  color: #64748b;
}

.saasTP-hdr-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.saasTP-search {
  min-width: 260px;
  padding: 12px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: #fff;
  color: #0f172a;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.saasTP-search:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.saasTP-search::placeholder {
  color: #94a3b8;
}

.saasTP-close {
  width: 42px;
  height: 42px;
  border: 1px solid #dbe4f0;
  border-radius: 14px;
  background: #fff;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.18s ease;
}

.saasTP-close span {
  line-height: 0;
}

.saasTP-close:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

.saasTP-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.saasTP-sidebar {
  width: 230px;
  min-width: 210px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 14px;
  background: #f1f5f9;
  border-right: 1px solid #e2e8f0;
}

.saasTP-sidebar-title {
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  font-family: 'Inter', system-ui, sans-serif;
}

.saasTP-ind-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.saasTP-ind-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: #334155;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease;
}

.saasTP-ind-btn:hover {
  background: rgba(255, 255, 255, 0.7);
}

.saasTP-ind-btn.active,
.saasTP-ind-btn[aria-selected="true"] {
  border-color: rgba(37, 99, 235, 0.18);
  background: #ffffff;
  color: #1d4ed8;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.08);
}

.saasTP-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #f8fbff 0%, #f1f5f9 100%);
}

.saasTP-grid {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.saasTP-card {
  position: relative;
  border: 1px solid #dbe4f0;
  border-radius: 22px;
  background: #ffffff;
  cursor: pointer;
  outline: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.saasTP-card:hover {
  transform: translateY(-4px);
  border-color: #bfd3ee;
  box-shadow: 0 24px 44px rgba(15, 23, 42, 0.10);
}

.saasTP-card.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), 0 24px 44px rgba(15, 23, 42, 0.12);
}

.saasTP-card:focus-visible {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.saasTP-card-img,
.saasTP-card-placeholder {
  width: 100%;
  aspect-ratio: 16 / 11;
  display: block;
  object-fit: cover;
  background: #e2e8f0;
}

.saasTP-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 36px;
  font-weight: 800;
}

.saasTP-card-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.saasTP-card-check {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  opacity: 0;
  transform: scale(0.85);
  transition: all 0.18s ease;
}

.saasTP-card.selected .saasTP-card-check {
  opacity: 1;
  transform: scale(1);
}

.saasTP-card-body {
  padding: 16px;
}

.saasTP-card-label {
  margin-bottom: 4px;
  color: #0f172a;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.2;
  font-weight: 800;
}

.saasTP-card-tag {
  color: #64748b;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
}

.saasTP-card-actions {
  margin-top: 14px;
}

.saasTP-card-preview-btn {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid #d6e4f8;
  border-radius: 12px;
  background: #f8fbff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.18s ease;
}

.saasTP-card-preview-btn:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.saasTP-loading-state,
.saasTP-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 240px;
  color: #64748b;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  text-align: center;
}

.saasTP-spin {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(37, 99, 235, 0.15);
  border-top-color: #2563eb;
  border-radius: 999px;
  animation: saasTPSpin 0.8s linear infinite;
}

@keyframes saasTPSpin {
  to {
    transform: rotate(360deg);
  }
}

.saasTP-load-more-wrap {
  padding: 0 22px 18px;
}

.saasTP-load-more {
  width: 100%;
  min-height: 48px;
  border: 1px dashed #bfdbfe;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  color: #1d4ed8;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.18s ease;
}

.saasTP-load-more:hover {
  background: #eff6ff;
}

.saasTP-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.saasTP-footer-sel {
  flex: 1;
  color: #64748b;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
}

.saasTP-footer-sel.has-preview {
  color: #0f172a;
}

.saasTP-footer-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.saasTP-footer-cover {
  width: 86px;
  height: 64px;
  flex-shrink: 0;
  border: 1px solid #dbe4f0;
  border-radius: 14px;
  object-fit: cover;
  background: #e2e8f0;
}

.saasTP-footer-cover-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-weight: 800;
}

.saasTP-footer-meta {
  min-width: 0;
}

.saasTP-footer-title {
  color: #0f172a;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saasTP-footer-sub {
  margin-top: 3px;
  color: #64748b;
  font-size: 12px;
}

.saasTP-footer-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.saasTP-footer-thumb {
  width: 34px;
  height: 26px;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  object-fit: cover;
  background: #e2e8f0;
}

.saasTP-footer-thumb.is-cover {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.16);
}

.saasTP-footer-btns {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.saasTP-btn-cancel,
.saasTP-btn-select {
  /* min-height: 46px; */
  padding: 13px 20px;
  border-radius: 14px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.18s ease;
}

.saasTP-btn-cancel {
  border: 1px solid #dbe4f0;
  background: #fff;
  color: #475569;
}

.saasTP-btn-cancel:hover {
  background: #f8fafc;
}

.saasTP-btn-select {
  border: 0;
  background: #2563eb;
  color: #fff;
  box-shadow: 0 14px 26px rgba(37, 99, 235, 0.18);
}

.saasTP-btn-select:not(:disabled):hover {
  background: #1d4ed8;
}

.saasTP-btn-select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.saasTP-details {
  position: fixed;
  inset: 0;
  z-index: 1000000;
  padding: 24px;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.saasTP-details.saasTP-details-visible {
  opacity: 1;
  pointer-events: auto;
}

.saasTP-details-dialog {
  width: min(1240px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #dbe4f0;
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.18);
  outline: none;
  transform: translateY(22px) scale(0.985);
  transition: transform 0.26s ease, opacity 0.26s ease;
  display: flex;
  flex-direction: column;
}

.saasTP-details.saasTP-details-visible .saasTP-details-dialog {
  transform: translateY(0) scale(1);
}

.saasTP-details-close {
  position: absolute;
  top: 12px;
  right: 18px;
  z-index: 3;
  width: 44px;
  height: 44px;
  border: 1px solid #dbe4f0;
  border-radius: 14px;
  background: #fff;
  color: #475569;
  font-size: 24px;
  cursor: pointer;
}

.saasTP-details-close span {
  height: 40px;
}

.saasTP-details-body {
  flex: 1;
  min-height: 100vh;
  overflow: auto;
}

.saasTP-details-shell {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

.saasTP-details-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 80px 12px 32px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.saasTP-details-eyebrow {
  margin-bottom: 12px;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.saasTP-details-head-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.saasTP-details-head-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.saasTP-details-title {
  font-size: 34px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #0f172a;
}

.saasTP-details-sub {
  margin-top: 6px;
  font-size: 14px;
  color: #64748b;
  font-weight: 600;
}

.saasTP-details-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(520px, 580px);
  gap: 26px;
  padding: 28px 32px 32px;
  flex: 1;
  min-height: 0;
}

.saasTP-details-main-media {
  height: 400px;
  overflow-x: hidden;
  overflow-y: auto;
}

.saasTP-details-media,
.saasTP-details-meta {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.saasTP-details-meta {
  min-height: 0;
  overflow: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.saasTP-details-hero-img,
.saasTP-details-hero-empty {
  width: 100%;
  display: block;
  border: 1px solid #dbe4f0;
  border-radius: 22px;
  background: #e2e8f0;
}

.saasTP-details-hero-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 40px;
  font-weight: 800;
}

.saasTP-details-kv {
  display: grid;
  gap: 12px;
}

.saasTP-details-kv-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #f8fbff;
}

.saasTP-details-kv-row .k {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.saasTP-details-kv-row .v {
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.saasTP-details-copy,
.saasTP-details-note {
  color: #475569;
  font-size: 14px;
  line-height: 1.7;
}

.saasTP-details-thumbs-title {
  color: #0f172a;
  font-size: 16px;
  font-weight: 800;
}

.saasTP-details-thumbs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  max-height: 440px;
  overflow: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.saasTP-details-thumb {
  overflow: hidden;
  padding: 0;
  border: 1px solid #dbe4f0;
  border-radius: 18px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s ease;
}

.saasTP-details-thumb:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
}

.saasTP-details-thumb img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #e2e8f0;
}

.saasTP-details-thumb span {
  display: block;
  padding: 12px 14px 14px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.saasTP-details-thumb.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.saasTP-details-thumb.active span {
  color: #1d4ed8;
}

.saasTP-details-link,
.saasTP-details-select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.saasTP-details-link {
  border: 1px solid #dbe4f0;
  background: #fff;
  color: #0f172a;
}

.saasTP-details-select {
  border: 0;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
}

.saasTP-details-link-disabled {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #94a3b8;
  pointer-events: none;
}

.saasTP-details-no-thumbs {
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  background: #f8fafc;
  color: #64748b;
}

.saasTP-grid::-webkit-scrollbar,
.saasTP-ind-list::-webkit-scrollbar,
.saasTP-details-dialog::-webkit-scrollbar,
.saasTP-details-meta::-webkit-scrollbar,
.saasTP-details-thumbs::-webkit-scrollbar {
  width: 6px;
}

.saasTP-grid::-webkit-scrollbar-thumb,
.saasTP-ind-list::-webkit-scrollbar-thumb,
.saasTP-details-dialog::-webkit-scrollbar-thumb,
.saasTP-details-meta::-webkit-scrollbar-thumb,
.saasTP-details-thumbs::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

/* Defensive overrides: ensure kit labels + preview details button remain visible even if theme CSS is aggressive. */
#saasTPOverlay .saasTP-card-body,
#saasTPOverlay .saasTP-card-label,
#saasTPOverlay .saasTP-card-tag,
#saasTPOverlay .saasTP-card-actions {
  display: block;
}

#saasTPOverlay .saasTP-card-preview-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

@media (max-width: 900px) {
  .saasTP-body {
    flex-direction: column;
  }

  .saasTP-panel {
    overflow: auto;
  }

  .saasTP-sidebar {
    width: 100%;
    flex-direction: row;
    min-width: 0;
    padding-bottom: 0;
    border-right: 0;
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 14px;
  }

  .saasTP-ind-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 10px;
  }

  .saasTP-ind-btn {
    width: auto;
    white-space: nowrap;
    margin-bottom: 0;
  }

  .saasTP-details {
    padding: 12px;
  }

  .saasTP-details-dialog {
    width: 100%;
    max-height: calc(100vh - 24px);
  }

  .saasTP-details-head-main,
  .saasTP-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .saasTP-footer-btns {
    width: 100%;
  }

  /* .saasTP-details-link,
  .saasTP-details-select,
  .saasTP-btn-cancel,
  .saasTP-btn-select {
    width: 100%;
  } */

  .saasTP-details-grid {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .saasTP-details-hero-empty {
    height: 340px;
  }

  .saasTP-details-thumbs {
    max-height: 280px;
  }

  .saasTP-details-media.saasTP-details-main-media {
    max-width: 520px;
    margin: 0 auto;
  }
}

@media (max-width: 700px) {
  .saasTP-overlay {
    padding: 10px;
  }

  .saasTP-modal {
    height: calc(100vh - 20px);
    border-radius: 20px;
  }

  .saasTP-hdr {
    padding: 18px;
  }

  .saasTP-hdr-h {
    font-size: 20px;
  }

  .saasTP-search {
    min-width: 0;
    width: 100%;
  }

  .saasTP-grid {
    grid-template-columns: 1fr 1fr;
    padding: 16px;
  }

  .saasTP-details-head {
    padding: 22px 20px 18px;
  }

  .saasTP-details-title {
    font-size: 28px;
  }

  .saasTP-card-preview-btn {
    padding: 0 10px;
  }

  .saasTP-card-body {
    padding: 10px;
  }

  .saasTP-details-head {
    flex-direction: column;
  }

  .saasTP-details-head-actions {
    justify-content: center;
  }
}