:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f7f7f8;
  --bg-card: #ffffff;
  --bg-card-hover: #f3f3f5;
  --bg-glass: rgba(0, 0, 0, 0.02);
  --border-subtle: #e5e5e7;
  --border-hover: #d1d1d6;
  --text-primary: #111111;
  --text-secondary: #555555;
  --text-muted: #888888;
  --accent: #111111;
  --accent-hover: #222222;
  --accent-glow: rgba(0, 0, 0, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-card: 0 1px 4px rgba(0,0,0,0.05);
  --shadow-hover: 0 12px 32px rgba(0,0,0,0.08);
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --navbar-height: 64px;
  --max-width: 1400px;
}

/* Global Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background-color: var(--accent);
  color: #fff;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary); 
}
::-webkit-scrollbar-thumb {
  background: var(--bg-card-hover); 
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover); 
}

/* Navbar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background: #000000;
  border-bottom: 1px solid #1a1a1a;
  z-index: 1000;
  transition: border-bottom-color var(--transition-fast), background-color var(--transition-fast);
}

.navbar.scrolled {
  background: #000000;
  border-bottom-color: #222222;
}

.navbar-container {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.navbar-logo:hover {
  opacity: 0.9;
}

.logo-brand {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  color: #ffffff;
  line-height: 1;
}

.logo-store {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-create {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  color: #000000;
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.82rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-create:hover {
  background: #f0f0f2;
  color: #000000;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(255, 255, 255, 0.25);
}

/* Hero Section */
.hero {
  padding-top: calc(var(--navbar-height) + 50px);
  padding-bottom: 36px;
  text-align: center;
  position: relative;
  background-color: #000000;
}

.hero::before {
  display: none;
}

.hero-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.hero-title {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 12px;
  letter-spacing: -0.03em;
}

.hero-subtitle {
  color: #94a3b8;
  max-width: 540px;
  margin: 0 auto;
  font-size: 1.05rem;
  line-height: 1.5;
  font-weight: 400;
}

/* Filters Section (Canva Style) */
.filters-section {
  position: sticky;
  top: var(--navbar-height);
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 16px 0 12px 0;
}

.filters-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.filters-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 4px 4px 10px 4px;
  align-items: flex-start;
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.filters-scroll::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  background: transparent;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  outline: none;
  flex-shrink: 0;
  text-decoration: none;
  color: inherit;
}

.filter-icon-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--pill-color, #111111);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

/* Instagram Gradient Background */
.filter-pill[data-category="Instagram"] .filter-icon-circle {
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

/* All / Default Icon Circle */
.filter-pill[data-category="all"] .filter-icon-circle {
  background: #f0f0f4;
  color: #111111;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}

/* Snapchat Dark Icon on Yellow Circle */
.filter-pill[data-category="Snapchat"] .filter-icon-circle {
  color: #000000;
}

.filter-icon-circle svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  fill: currentColor;
}

.filter-icon-circle svg[stroke] {
  stroke: currentColor;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: color var(--transition-fast), font-weight var(--transition-fast);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  line-height: 1.2;
}

/* Hover & Active States */
.filter-pill:hover .filter-icon-circle {
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

.filter-pill:hover .filter-label {
  color: var(--text-primary);
}

.filter-pill.active .filter-icon-circle {
  transform: translateY(-2px) scale(1.08);
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 5px var(--pill-color, #111111), 0 8px 20px rgba(0, 0, 0, 0.2);
}

.filter-pill[data-category="all"].active .filter-icon-circle {
  background: #111111;
  color: #ffffff;
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 5px #111111, 0 8px 20px rgba(0, 0, 0, 0.2);
}

.filter-pill.active .filter-label {
  font-weight: 700;
  color: var(--text-primary);
}

.filter-count {
  display: none;
}

/* Templates Grid (Pinterest Masonry Layout) */
.templates-grid {
  columns: 280px;
  column-gap: 24px;
  padding: 32px 24px;
  max-width: var(--max-width);
  margin: 0 auto;
}

@media (max-width: 768px) {
  .templates-grid {
    columns: 160px;
    column-gap: 12px;
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .templates-grid {
    columns: 140px;
  }
}

/* Template Card (Pinterest Style) */
.template-card {
  break-inside: avoid;
  display: inline-block;
  width: 100%;
  margin-bottom: 24px;
  background: transparent;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeInUp 0.5s ease backwards;
}

@media (max-width: 768px) {
  .template-card {
    margin-bottom: 12px;
    border-radius: 12px;
  }
}

.template-card:nth-child(1) { animation-delay: 0.05s; }
.template-card:nth-child(2) { animation-delay: 0.1s; }
.template-card:nth-child(3) { animation-delay: 0.15s; }
.template-card:nth-child(4) { animation-delay: 0.2s; }
.template-card:nth-child(5) { animation-delay: 0.25s; }
.template-card:nth-child(6) { animation-delay: 0.3s; }
.template-card:nth-child(7) { animation-delay: 0.35s; }
.template-card:nth-child(8) { animation-delay: 0.4s; }
.template-card:nth-child(9) { animation-delay: 0.45s; }
.template-card:nth-child(10) { animation-delay: 0.5s; }
.template-card:nth-child(11) { animation-delay: 0.55s; }
.template-card:nth-child(12) { animation-delay: 0.6s; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.template-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.template-card .card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  width: 100%;
}

.template-card .card-image {
  position: relative;
  overflow: hidden;
  background: #f0f0f4;
  border-radius: 16px;
  width: 100%;
}

@media (max-width: 768px) {
  .template-card .card-image {
    border-radius: 12px;
  }
}

.template-card .card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 16px;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 768px) {
  .template-card .card-image img {
    border-radius: 12px;
  }
}

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

.template-card .card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.4) 55%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px 16px;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 16px;
}

@media (max-width: 768px) {
  .template-card .card-overlay {
    border-radius: 12px;
    padding: 12px 10px;
  }
}

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

.template-card .overlay-content {
  transform: translateY(10px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.template-card:hover .overlay-content {
  transform: translateY(0);
}

.template-card .card-title {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.template-card .card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.template-card .card-category {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 100px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.template-card .card-format {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 400;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Template Detail Page */
.template-detail {
  padding-top: calc(var(--navbar-height) + 32px);
  padding-bottom: 64px;
}

.detail-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 48px;
  padding: 24px;
}

@media (max-width: 992px) {
  .detail-container {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

.detail-gallery {
  position: relative;
}

.gallery-main {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.gallery-main img {
  width: 100%;
  display: block;
  transition: opacity 0.3s;
}

.gallery-thumbnails {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.gallery-thumbnails::-webkit-scrollbar {
  height: 4px;
}

.gallery-thumb {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  opacity: 0.6;
  transition: var(--transition-fast);
  flex-shrink: 0;
  background: var(--bg-card);
  padding: 0;
  outline: none;
}

.gallery-thumb:hover {
  opacity: 0.8;
}

.gallery-thumb.active {
  border-color: #111111;
  opacity: 1;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-category {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.875rem;
  padding: 5px 14px;
  border-radius: 100px;
  font-weight: 500;
  background: #f0f0f2;
  color: #111111;
}

.detail-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.detail-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.spec-item {
  background: #f8f8f9;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.spec-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: block;
}

.spec-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-use-template {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #111111;
  color: #ffffff;
  padding: 16px 32px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: var(--transition-fast);
  margin-top: 8px;
}

.btn-use-template:hover {
  background: #222222;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.detail-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

/* Related Section */
.related-section {
  padding-top: 64px;
  margin-top: 64px;
  border-top: 1px solid var(--border-subtle);
}

.related-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

/* Footer */
.footer {
  background: #000000;
  color: #ffffff;
  border-top: 1px solid #1a1a1a;
  padding: 48px 24px;
  margin-top: auto;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.footer-logo {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: inline-block;
  color: #ffffff;
  text-decoration: none;
}
.footer-logo span {
  color: #a0a0a0;
}

.footer-tagline {
  color: var(--text-muted);
  font-size: 0.875rem;
  max-width: 500px;
  margin: 0 auto 24px auto;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: var(--transition-fast);
}

.footer-links a:hover {
  color: var(--text-primary);
}

.footer-copy {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 80px 24px;
}
.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.5;
}
.empty-state h3 {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.empty-state p {
  color: var(--text-muted);
}

/* 404 Page */
.error-page {
  text-align: center;
  padding-top: 200px;
  padding-bottom: 100px;
}
.error-page h1 {
  font-size: 6rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 16px;
}
.error-page p {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}
.error-page .btn-home {
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: var(--transition-fast);
}
.error-page .btn-home:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

/* Utility */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Print Styles */
@media print {
  body {
    background: #fff;
    color: #000;
  }
  .navbar, .filters-section, .hero::before, .footer, .overlay-btn {
    display: none;
  }
  .template-card {
    border: 1px solid #ccc;
    box-shadow: none;
    page-break-inside: avoid;
  }
}
