/* ─── สไตล์ชีทหน้าแคตตาล็อกแสดงผลเทมเพลต: templates.css ─── */

.tmpl-page-container {
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
  box-sizing: border-box;
  min-height: 80vh;
}

.tmpl-header {
  text-align: center;
  margin-bottom: 2.75rem;
  padding: 0 1rem;
}

.tmpl-header .section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #1d4ed8;
  background: #eff6ff;
  padding: 0.35rem 0.95rem;
  border-radius: 20px;
  margin-bottom: 0.9rem;
  border: 1px solid #dbeafe;
}

.tmpl-header h1 {
  font-size: 2.3rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.85rem 0;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.tmpl-header p {
  color: #64748b;
  font-size: 1.12rem;
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.6;
}

.juristic-session-banner {
  background: #eff6ff;
  border-left: 4px solid #1d4ed8;
  color: #1e40af;
  padding: 1.15rem 1.5rem;
  margin-bottom: 2.5rem;
  font-family: 'Prompt', sans-serif;
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.08);
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE TEMPLATES GRID
   ══════════════════════════════════════════════════════════ */
.templates-grid {
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  align-items: stretch;
  box-sizing: border-box;
}

@media (min-width: 1560px) {
  .templates-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 1.5rem;
  }
}

@media (max-width: 1559px) {
  .templates-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
  }
}

@media (max-width: 1199px) {
  .templates-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }
}

@media (max-width: 899px) {
  .templates-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 599px) {
  .templates-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

/* ══════════════════════════════════════════════════════════
   Uniform Template Card
   ══════════════════════════════════════════════════════════ */
.template-card {
  position: relative;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.04), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
  overflow: hidden;
  box-sizing: border-box;
}

.template-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 30px -6px rgba(15, 23, 42, 0.12), 0 6px 12px -3px rgba(15, 23, 42, 0.06);
  border-color: #cbd5e1;
}

/* Preview Thumbnail */
.card-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
}

.card-thumb a {
  display: block;
  width: 100%;
  height: 100%;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.template-card:hover .card-thumb img {
  transform: scale(1.05);
}

/* Overlay Action Button on Hover */
.card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.template-card:hover .card-overlay {
  opacity: 1;
}

/* Card Body */
.card-body {
  padding: 1.35rem 1.5rem 1.15rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.card-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

/* Color Swatches */
.card-meta {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.card-meta .swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Category Pill */
.category-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  padding: 0.22rem 0.65rem;
  border-radius: 4px;
  white-space: nowrap;
}

.card-body h3 {
  font-size: 1.18rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.4;
}

.card-body h3 a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

.card-body h3 a:hover {
  color: #1d4ed8;
}

.card-body p {
  font-size: 0.9rem;
  color: #64748b;
  margin: 0;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 2.8em;
}

/* Card Footer Actions */
.card-footer {
  padding: 1.15rem 1.5rem 1.35rem;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 0.75rem;
}

.card-footer .btn {
  flex: 1;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  box-sizing: border-box;
  text-align: center;
  border-radius: 4px;
}

.btn-sm {
  padding: 0.45rem 1rem;
  font-size: 0.82rem;
}

.btn-primary {
  background: #15519d;
  color: #ffffff;
  border-color: #15519d;
}

.btn-primary:hover {
  background: #103e7a;
  border-color: #103e7a;
  color: #ffffff;
}

.btn-outline {
  background: #ffffff;
  color: #334155;
  border-color: #cbd5e1;
}

.btn-outline:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE POLISH & MOBILE ADJUSTMENTS
   ══════════════════════════════════════════════════════════ */
@media (max-width: 959px) {
  .tmpl-page-container {
    padding: 2.25rem 1.25rem 4rem;
  }

  .tmpl-header {
    margin-bottom: 2rem;
  }

  .tmpl-header h1 {
    font-size: 2rem;
  }

  .card-body {
    padding: 1.15rem 1.15rem 1rem;
  }

  .card-footer {
    padding: 0.95rem 1.15rem 1.15rem;
    gap: 0.5rem;
  }
}

@media (max-width: 639px) {
  .tmpl-page-container {
    padding: 1.75rem 1rem 3.5rem;
  }

  .tmpl-header h1 {
    font-size: 1.65rem;
    line-height: 1.35;
  }

  .tmpl-header p {
    font-size: 0.95rem;
  }

  .card-footer {
    flex-direction: row;
    gap: 0.5rem;
  }
}

@media (max-width: 380px) {
  .card-footer {
    flex-direction: column;
    gap: 0.5rem;
  }
}