/* ========================================
   TEMPLATES PAGE - Styles
   ======================================== */

/* ===== HERO ===== */
.tpl-hero {
  padding: 140px 0 80px;
  background: linear-gradient(160deg, #F8F7FF 0%, #EDE8FF 60%, #FFF0F5 100%);
  position: relative;
  overflow: hidden;
  text-align: center;
}

.tpl-hero-bg { position: absolute; inset: 0; pointer-events: none; }
.tpl-bg-circle { position: absolute; border-radius: 50%; }
.c1 { width: 500px; height: 500px; background: radial-gradient(circle, rgba(107,70,255,0.12), transparent); top: -100px; left: -100px; }
.c2 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(255,107,157,0.1), transparent); bottom: -50px; right: -80px; }
.c3 { width: 300px; height: 300px; background: radial-gradient(circle, rgba(0,212,255,0.08), transparent); top: 50%; left: 50%; transform: translate(-50%,-50%); }

.tpl-hero-content { position: relative; z-index: 1; }
.tpl-hero-content .section-title { margin-bottom: 20px; }
.tpl-hero-content .section-subtitle { margin: 0 auto 40px; }

.tpl-hero-stats {
  display: inline-flex;
  align-items: center;
  gap: 32px;
  background: white;
  border-radius: var(--radius-full);
  padding: 16px 32px;
  box-shadow: 0 4px 24px rgba(107,70,255,0.1);
  border: 1px solid rgba(107,70,255,0.1);
}

.tpl-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tpl-stat-num { font-size: 1.3rem; font-weight: 800; color: var(--primary); }
.tpl-stat span:last-child { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.tpl-stat-divider { width: 1px; height: 40px; background: var(--border); }

/* ===== FILTER ===== */
.filter-section {
  padding: 40px 0 0;
  border-bottom: 1px solid var(--border);
  background: white;
  position: sticky;
  top: var(--nav-height);
  z-index: 100;
}

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 0;
}

.filter-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }

.filter-tab {
  padding: 10px 20px;
  border-radius: var(--radius-full) var(--radius-full) 0 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.filter-tab:hover { color: var(--primary); background: rgba(107,70,255,0.04); }
.filter-tab.active { color: var(--primary); font-weight: 700; border-bottom-color: var(--primary); }

.filter-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-light);
  border-radius: var(--radius-full);
  padding: 10px 18px;
  border: 1.5px solid var(--border);
  transition: var(--transition);
  min-width: 200px;
  margin-bottom: 10px;
}
.filter-search:focus-within { border-color: var(--primary); background: white; }
.filter-search i { color: var(--text-muted); }
.filter-search input { background: none; border: none; outline: none; font-size: 0.88rem; color: var(--text-primary); font-family: inherit; width: 100%; }
.filter-search input::placeholder { color: var(--text-muted); }

/* ===== TEMPLATES SECTION ===== */
.templates-section { padding-top: 64px; }

.templates-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}

.template-card {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1.5px solid var(--border);
  transition: var(--transition);
}
.template-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 48px rgba(107,70,255,0.15);
  border-color: rgba(107,70,255,0.3);
}
.template-card.hidden { display: none; }

.template-preview {
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.tpl-phone {
  width: 140px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  border-radius: 28px;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.2);
}

.tpl-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.tpl-name { font-size: 0.75rem; font-weight: 700; text-align: center; }

.tpl-link {
  width: 100%; padding: 8px 12px; border-radius: 10px;
  font-size: 0.68rem; font-weight: 600; text-align: center;
  cursor: default;
}

.template-info { padding: 24px; }

.template-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.template-meta h3 { font-size: 1rem; font-weight: 700; }

.tpl-badge {
  padding: 4px 12px; border-radius: var(--radius-full);
  font-size: 0.72rem; font-weight: 700;
}
.tpl-badge.free { background: rgba(38,208,124,0.1); color: #18A05A; }
.tpl-badge.popular { background: rgba(255,107,53,0.1); color: var(--accent-orange); }
.tpl-badge.premium { background: linear-gradient(135deg, rgba(107,70,255,0.1), rgba(255,107,157,0.1)); color: var(--primary); }

.template-info p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 16px; }

.template-actions { display: flex; gap: 10px; }
.template-actions .btn { flex: 1; justify-content: center; }

/* ===== USE CASES ===== */
.usecase-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  margin-top: 56px;
}

.usecase-card {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1.5px solid var(--border);
  transition: var(--transition);
}
.usecase-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.usecase-device { padding: 24px; }
.usecase-screen {
  border-radius: 20px;
  padding: 24px 20px;
  min-height: 200px;
}

.uc-profile { text-align: center; margin-bottom: 16px; }
.uc-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; margin: 0 auto 8px;
}
.uc-name { color: white; font-weight: 700; font-size: 0.88rem; }
.uc-bio { color: rgba(255,255,255,0.7); font-size: 0.72rem; margin-top: 4px; }

.uc-links { display: flex; flex-direction: column; gap: 8px; }
.uc-link {
  padding: 9px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.15); color: white;
  font-size: 0.75rem; font-weight: 600;
  text-align: center;
}

.usecase-info { padding: 20px 24px 24px; }
.uc-category { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.usecase-info h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.usecase-info p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 16px; }
.uc-stat {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--bg-light); border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.uc-stat span { color: var(--text-secondary); }
.uc-stat strong { color: var(--accent-green); font-weight: 700; }

/* ===== PREVIEW MODAL ===== */
.preview-modal {
  max-width: 360px;
  padding: 0;
  overflow: hidden;
}

/* ===== IMAGE PREVIEW ===== */
.tpl-img-preview {
  height: 280px;
  overflow: hidden;
  position: relative;
  background: var(--bg-light);
}

.tpl-img-preview img {
  width: 100%;
  height: 350px;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
}

.template-card:hover .tpl-img-preview img {
  transform: scale(1.04);
}

.tpl-label {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  letter-spacing: -0.02em;
}

/* ===== CTA ===== */
.cta-section { background: linear-gradient(135deg, #1A0A3E 0%, #0D0520 100%); }
.cta-inner {
  text-align: center;
  padding: 80px 48px;
  border-radius: var(--radius-xl);
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(107,70,255,0.3), rgba(255,107,157,0.2));
  border: 1px solid rgba(255,255,255,0.08);
}
.cta-bg-blur {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(107,70,255,0.3) 0%, transparent 70%);
  pointer-events: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .templates-grid { grid-template-columns: repeat(2, 1fr); }
  .usecase-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .templates-grid { grid-template-columns: 1fr; }
  .usecase-grid { grid-template-columns: 1fr; }
  .tpl-hero-stats { gap: 20px; padding: 14px 24px; }
  .filter-bar { flex-direction: column; align-items: flex-start; }
  .filter-search { width: 100%; }
  .cta-inner { padding: 48px 24px; }
}

/* Show only first 9 templates until expanded */
#templatesGrid .template-card[data-more-hidden="1"] { display: none !important; }