/* ==========================================================================
   Template Page Styles - Arcix Design System
   Compatible with Arcix Dark & Light Themes
   ========================================================================== */

/* Page Wrapper */
.template-page {
  position: relative;
  min-height: calc(100vh - 200px);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 130px 24px 80px;
  background-color: var(--bg);
  overflow: hidden;
}

/* Subtle Ambient Glow */
.ambient-glow {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: 720px;
  height: 480px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.015) 45%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  filter: blur(50px);
}

html.light .ambient-glow {
  background: radial-gradient(circle, rgba(0, 0, 0, 0.04) 0%, rgba(0, 0, 0, 0.01) 45%, transparent 70%);
}

/* Main Container */
.template-container {
  position: relative;
  z-index: 1;
  max-width: 1140px;
  width: 100%;
  margin: 0 auto;
}

/* Header Section */
.template-header {
  text-align: center;
  margin-bottom: 44px;
}

.template-header .badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: 999px;
  margin-bottom: 16px;
}

html.light .template-header .badge {
  background: rgba(0, 0, 0, 0.04);
}

.page-title {
  font-size: clamp(32px, 4.5vw, 48px);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--fg);
  margin: 0 0 12px;
  line-height: 1.15;
}

.page-subtitle {
  font-size: clamp(15px, 2vw, 17px);
  color: var(--muted);
  max-width: 620px;
  margin: 0 auto 28px;
  line-height: 1.6;
}

/* Top Download All Action Bar */
.header-actions-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}

.download-all-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 32px;
  border-radius: 999px;
  background: var(--fg);
  color: #0a0a0a;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

html.light .download-all-button {
  background: #111;
  color: #fff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
}

.download-all-button:hover {
  opacity: 0.94;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.download-all-button:active {
  transform: translateY(0) scale(0.98);
}

.download-all-button .count-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.12);
  color: inherit;
}

html.light .download-all-button .count-badge {
  background: rgba(255, 255, 255, 0.2);
}

/* Templates Grid Layout */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  width: 100%;
}

/* Template Card */
.template-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.25s ease,
              box-shadow 0.25s ease;
  overflow: hidden;
}

.template-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

html.light .template-card:hover {
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.08);
}

/* Card Glow Accent */
.template-card-glow {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 60px;
  background: radial-gradient(ellipse at top, rgba(255, 255, 255, 0.08), transparent 70%);
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

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

/* Folder Icon Wrapper */
.template-icon-wrapper {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  background: var(--secondary);
  border: 1px solid var(--border);
  color: var(--fg);
  transition: transform 0.25s ease, background-color 0.25s ease;
}

.template-card:hover .template-icon-wrapper {
  transform: scale(1.06);
}

.folder-icon {
  width: 32px;
  height: 32px;
  stroke: currentColor;
  stroke-width: 1.8;
  display: block;
}

/* Template Info */
.template-info {
  margin-bottom: 28px;
  width: 100%;
}

.template-name {
  font-size: 19px;
  font-weight: 600;
  color: var(--fg);
  margin: 0;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

/* Download Button on Each Card */
.template-actions {
  width: 100%;
  display: flex;
  justify-content: center;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.download-button:hover {
  background: var(--fg);
  color: #111;
  border-color: var(--fg);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

html.light .download-button:hover {
  background: #111;
  color: #fff;
  border-color: #111;
}

.download-button:active {
  transform: translateY(0) scale(0.98);
}

.download-icon {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
  transition: transform 0.2s ease;
}

.download-button:hover .download-icon {
  transform: translateY(2px);
}

/* Active downloading state */
.download-button.is-downloading,
.download-all-button.is-downloading {
  opacity: 0.8;
  pointer-events: none;
}

/* Pulsing highlight effect during Download All */
@keyframes cardPulse {
  0% {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    border-color: var(--border);
  }
  50% {
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.6);
  }
  100% {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    border-color: var(--border);
  }
}

.template-card.pulse-download {
  animation: cardPulse 0.9s ease;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translate(-50%, 70px);
  background: rgba(20, 20, 20, 0.94);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 14px 28px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.toast-icon {
  width: 18px;
  height: 18px;
  stroke: #4ade80;
  stroke-width: 2.2;
}

html.light .toast {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .templates-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}

@media (max-width: 680px) {
  .template-page {
    padding-top: 110px;
    padding-bottom: 60px;
  }

  .templates-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .template-card {
    padding: 24px 20px;
  }

  .download-all-button {
    width: 100%;
    max-width: 320px;
  }
}
