/* ===== Template page (templates.html) — scoped under .tpl-page ===== */
body.tpl-page {
  background: #f5f6f8;
}

.tpl-page {
  --tpl-primary: #2563eb;
  --tpl-primary-light: #eff6ff;
  --tpl-accent: #f97316;
  --tpl-text-muted: #999;
  --tpl-border: #e5e7eb;
  --tpl-bg-white: #fff;
  --tpl-sidebar-width: 260px;
  --tpl-radius: 8px;
  --tpl-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --tpl-shadow-hover: 0 4px 12px rgba(0,0,0,.1);
}

.tpl-page .nav-link[aria-current="page"] {
  color: var(--primary);
  background: rgba(37,99,235,.06);
}

.tpl-page .tpl-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  padding: calc(var(--header-h) + 48px) 20px 48px;
  text-align: center;
  border-bottom: 1px solid var(--tpl-border);
}

.tpl-page .tpl-hero > *:not(.page-bg) {
  position: relative;
  z-index: 1;
}

.tpl-page .tpl-hero h1 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.tpl-page .tpl-hero p {
  font-size: 1rem;
  opacity: .85;
  margin-bottom: 24px;
  color: var(--text-muted);
}

.tpl-page .search-box {
  display: flex;
  max-width: 520px;
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--tpl-shadow);
}

.tpl-page .search-box input {
  flex: 1;
  padding: 12px 16px;
  border: none;
  outline: none;
  font-size: .95rem;
}

.tpl-page .search-box button {
  padding: 12px 24px;
  background: var(--tpl-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 500;
}

.tpl-page .main-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.tpl-page .sidebar {
  width: var(--tpl-sidebar-width);
  flex-shrink: 0;
  background: var(--tpl-bg-white);
  border-radius: var(--tpl-radius);
  box-shadow: var(--tpl-shadow);
  overflow: hidden;
}

.tpl-page .sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--tpl-border);
}

.tpl-page .sidebar-section:last-child {
  border-bottom: none;
}

.tpl-page .sidebar-title {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.tpl-page .color-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tpl-page .color-chip {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all .2s;
  position: relative;
}

.tpl-page .color-chip:hover {
  transform: scale(1.15);
}

.tpl-page .color-chip.active {
  border-color: var(--tpl-primary);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--tpl-primary);
}

.tpl-page .color-chip .tip {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .7rem;
  white-space: nowrap;
  display: none;
}

.tpl-page .color-chip:hover .tip {
  display: block;
}

.tpl-page .cat-list {
  list-style: none;
}

.tpl-page .cat-list li {
  margin-bottom: 2px;
}

.tpl-page .cat-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: .88rem;
  transition: all .15s;
  color: inherit;
}

.tpl-page .cat-list a:hover {
  background: var(--tpl-primary-light);
  color: var(--tpl-primary);
}

.tpl-page .cat-list a.active {
  background: var(--tpl-primary-light);
  color: var(--tpl-primary);
  font-weight: 600;
}

.tpl-page .cat-list .num {
  font-size: .78rem;
  color: var(--tpl-text-muted);
  background: #f3f4f6;
  padding: 1px 8px;
  border-radius: 10px;
}

.tpl-page .cat-list a:hover .num,
.tpl-page .cat-list a.active .num {
  background: var(--tpl-primary);
  color: #fff;
}

.tpl-page .content {
  flex: 1;
  min-width: 0;
}

.tpl-page .toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--tpl-bg-white);
  border-radius: var(--tpl-radius);
  box-shadow: var(--tpl-shadow);
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.tpl-page .breadcrumb {
  font-size: .85rem;
  color: var(--tpl-text-muted);
}

.tpl-page .breadcrumb span {
  color: var(--text);
}

.tpl-page .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  color: var(--tpl-text-muted);
}

.tpl-page .sort-btn {
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: .85rem;
  border: none;
  background: none;
}

.tpl-page .sort-btn:hover,
.tpl-page .sort-btn.active {
  color: var(--tpl-primary);
  background: var(--tpl-primary-light);
}

.tpl-page .btn-outline {
  border: 1px solid var(--tpl-border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: .85rem;
}

.tpl-page .btn-outline:hover {
  border-color: var(--tpl-primary);
  color: var(--tpl-primary);
}

.tpl-page .template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.tpl-page .template-card {
  background: var(--tpl-bg-white);
  border-radius: var(--tpl-radius);
  box-shadow: var(--tpl-shadow);
  overflow: hidden;
  transition: all .25s;
}

.tpl-page .template-card:hover {
  box-shadow: var(--tpl-shadow-hover);
  transform: translateY(-2px);
}

.tpl-page .template-card .thumb {
  position: relative;
  overflow: hidden;
  background: #f0f2f5;
  aspect-ratio: 460/547;
}

.tpl-page .template-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tpl-page .template-card .thumb .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  opacity: .3;
  user-select: none;
  background: #e8eaed;
}

.tpl-page .template-card .thumb .badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: .75rem;
  color: #fff;
}

.tpl-page .template-card .thumb .badge.hot {
  background: #ef4444;
}

.tpl-page .template-card .thumb .badge.new {
  background: #10b981;
}

.tpl-page .template-card .info {
  padding: 12px;
}

.tpl-page .template-card .info h3 {
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpl-page .template-card .info .meta-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.tpl-page .template-card .info .template-code {
  font-size: .85rem;
  color: var(--tpl-primary);
  font-weight: 600;
  background: var(--tpl-primary-light);
  padding: 2px 8px;
  border-radius: 4px;
}

.tpl-page .template-card .info .cat-tag {
  font-size: .75rem;
  color: var(--tpl-text-muted);
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 4px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpl-page .template-card .info .card-actions {
  display: flex;
  gap: 8px;
}

.tpl-page .template-card .info .btn-demo,
.tpl-page .template-card .info .btn-select {
  flex: 1;
  padding: 6px 0;
  border-radius: 4px;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all .15s;
  border: none;
}

.tpl-page .template-card .info .btn-demo {
  background: #fff;
  border: 1px solid var(--tpl-primary);
  color: var(--tpl-primary);
}

.tpl-page .template-card .info .btn-demo:hover {
  background: var(--tpl-primary-light);
}

.tpl-page .template-card .info .btn-select {
  background: var(--tpl-accent);
  color: #fff;
}

.tpl-page .template-card .info .btn-select:hover {
  background: #ea580c;
}

.tpl-page .loading-tip,
.tpl-page .empty-tip {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.tpl-page .pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 24px;
  padding: 16px 0;
}

.tpl-page .pagination a,
.tpl-page .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: .88rem;
  transition: all .15s;
}

.tpl-page .pagination a {
  background: var(--tpl-bg-white);
  border: 1px solid var(--tpl-border);
  color: inherit;
}

.tpl-page .pagination a:hover {
  border-color: var(--tpl-primary);
  color: var(--tpl-primary);
}

.tpl-page .pagination .cur {
  background: var(--tpl-primary);
  color: #fff;
  border-color: var(--tpl-primary);
}

.tpl-page .pagination .dot {
  border: none;
  background: none;
}

@media (max-width: 968px) {
  .tpl-page .tpl-hero {
    padding: calc(var(--header-h) + 24px) 16px 24px;
  }

  .tpl-page .tpl-hero h1 {
    font-size: 1.2rem;
  }

  .tpl-page .main-wrap {
    flex-direction: column;
    align-items: center;
  }

  .tpl-page .content {
    width: 100%;
  }

  .tpl-page .sidebar {
    width: 100%;
    display: none;
  }

  .tpl-page .sidebar.show {
    display: block;
  }

  .tpl-page .template-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 540px) {
  .tpl-page .template-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .tpl-page .template-card .info {
    padding: 8px;
  }

  .tpl-page .template-card .info h3 {
    font-size: .8rem;
  }
}

@media (max-width: 380px) {
  .tpl-page .template-grid {
    grid-template-columns: 1fr;
  }
}
