/* =========================================================
   看看别人创建的应用：模板宫格 + 弹窗预览（v9.29，两页共用）
   设计取自 SCADA 对接网页，风格适配本站：圆角 12px、主色 var(--color-primary)、
   字体/阴影跟随所在页面 token。
   ========================================================= */

/* ---------- 宫格 ---------- */
.tpl-grid {
  margin-top: 40px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;
}
.tpl-more { margin-top: 34px; text-align: center; }
.tpl-status { margin-top: 20px; text-align: center; color: var(--color-text-tertiary); font-size: 14px; }
.tpl-status[hidden] { display: none; }
.tpl-status button { margin-left: 12px; }
.tpl-card[aria-busy="true"] .tpl-mask { opacity: 1; }
.tpl-more-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
  padding: 10px 22px;
  border: 1px solid rgba(31, 95, 224, 0.35);
  border-radius: 999px;
  transition: background-color 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
}
.tpl-more-link:hover { background: rgba(31, 95, 224, 0.07); border-color: var(--color-primary); }

.tpl-card {
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.tpl-card:hover {
  border-color: rgba(31, 95, 224, 0.45);
  box-shadow: var(--shadow-float);
  transform: translateY(-3px);
}
.tpl-card:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }
.tpl-thumb { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #f2f3f5; }
.tpl-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
  transition: transform 0.35s var(--ease-out);
}
.tpl-card:hover .tpl-thumb img { transform: scale(1.07); }
/* 封面占位符：浅灰底 + 图片图标 +「应用截图」 */
.tpl-ph {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.35s var(--ease-out);
}
.tpl-card:hover .tpl-ph { transform: scale(1.07); }
.tpl-ph span { font-size: 12px; color: var(--color-text-tertiary); }
.tpl-mask {
  position: absolute;
  inset: 0;
  background: rgba(31, 35, 41, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s var(--ease-out);
}
.tpl-card:hover .tpl-mask, .tpl-card:focus-visible .tpl-mask { opacity: 1; }
.tpl-mask span {
  background: #fff;
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  padding: 8px 18px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}
.tpl-info { padding: 12px 14px 14px; }
.tpl-name { font-size: 15px; font-weight: 600; color: var(--color-text-primary); }
.tpl-desc {
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-text-tertiary);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 弹窗预览 ---------- */
.tpl-modal-mask {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tpl-modal-mask[hidden] { display: none; }
.tpl-modal {
  width: 92vw;
  max-width: 1440px;
  height: 88vh;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}
.tpl-modal:fullscreen { width: 100vw; max-width: none; height: 100vh; border-radius: 0; }
.tpl-modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-line);
  flex-shrink: 0;
}
.tpl-modal-head h3 { font-size: 17px; font-weight: 600; }
.tpl-modal-badge {
  font-size: 12px;
  color: var(--color-primary);
  background: rgba(31, 95, 224, 0.1);
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 500;
}
.tpl-modal-actions { margin-left: auto; display: flex; gap: 8px; }
.tpl-btn {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: #fff;
  border: 1px solid var(--color-line-strong);
  border-radius: 8px;
  transition: border-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
}
.tpl-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.tpl-btn-primary {
  color: #fff;
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.tpl-btn-primary:hover { color: #fff; filter: brightness(1.06); }
.tpl-modal-body {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #f7f8fc;
  overflow: hidden;
}
.tpl-modal-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-top: 1px solid var(--color-line);
  flex-shrink: 0;
}
.tpl-modal-note { font-size: 13px; color: var(--color-text-tertiary); }

/* 加载 / 失败态 */
.tpl-demo-loading, .tpl-demo-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--color-text-secondary);
  font-size: 14px;
}
.tpl-demo-error[hidden], .tpl-demo-loading[hidden] { display: none; }
.tpl-demo-error-icon { font-size: 34px; }
.tpl-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(31, 95, 224, 0.18);
  border-top-color: var(--color-primary);
  animation: tpl-spin 0.8s linear infinite;
}
@keyframes tpl-spin { to { transform: rotate(360deg); } }

.tpl-demo-frame { position: absolute; inset: 0; background: #fff; }
.tpl-demo-iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- 响应式 ---------- */
@media (max-width: 1023px) {
  .tpl-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 32px; }
}
@media (max-width: 767px) {
  .tpl-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .tpl-info { padding: 10px 12px 12px; }
  .tpl-name { font-size: 13.5px; }
  .tpl-desc { font-size: 11.5px; }
  .tpl-modal { width: 96vw; height: 90vh; border-radius: 12px; }
  .tpl-modal-head { padding: 10px 14px; }
  .tpl-modal-head h3 { font-size: 15px; }
  .tpl-modal-badge { display: none; }
  .tpl-modal-foot { padding: 10px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .tpl-thumb img, .tpl-ph, .tpl-mask, .tpl-card { transition: none; }
  .tpl-spinner { animation: none; }
}
