* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.gocayin-templates-header_subtitle {
  font-size: 20px;
  color: #ffffff;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
  padding-bottom: 20px;
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.gocayin-templates-bannerimg {
  background-blend-mode: multiply;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: 0% 50%;
  max-width: 100%;
  z-index: 0;
  display: flex;
  align-items: center;
  background-image:
    url("../../images/gocayin/templates/gocayin-templates_header_bg.webp");
  background-color: rgba(196, 196, 196, 0.7);
}

/* Search Section */
.search-section {
  padding-top: 20px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  max-width: 1200px;
}

.search-section .search-bar { position: relative; }
.search-section .search-bar > .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); z-index: 2; pointer-events: none; }
.search-section .search-bar > #searchInput { width: 100% !important; padding-left: 36px !important; }

.search-controls {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  align-items: center;
  justify-content: center;
}

.search-bar {
  position: relative;
  flex: 1;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 16px;
  pointer-events: none;
  z-index: 1;
}

.search-input {
  padding: 12px 16px 12px 36px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.3s ease;
  width: 100%;
}

.search-input:focus {
  border-color: #fabe00;
}


.filters {
  display: flex;
  gap: 16px;
  padding: 0 0 16px 0;
  border-radius: 10px;
  flex-wrap: wrap;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 150px;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
  outline: none;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  min-width: 160px;
  appearance: none;
  background-position: right 12px center;
  background-repeat: no-repeat;
}

.filter-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 180px;
}

.filter-group label {
  font-weight: 800;
  color: #ffffff;
  font-size: 14px;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

.clear-filters {
  background: #fabe00;
  color: #fff8e1;
  border: none;
  padding: 7px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 10px;
}

.filter-select:focus {
  border-color: #fabe00;
  box-shadow: 0 4px 15px rgba(250, 190, 0, 0.2);

}


/* Templates Section */
.templates-section {
  padding: 60px 0;
  background: white;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 30px;
  margin-top: 40px;
}

.template-card {
  background: white;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.template-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.template-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: #f5f5f5;
  transition: opacity 0.3s ease;
}

.lazy-image {
  background: #f5f5f5 url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><circle cx="20" cy="20" r="18" fill="none" stroke="%23ddd" stroke-width="2"/><circle cx="20" cy="20" r="18" fill="none" stroke="%23fabe00" stroke-width="2" stroke-linecap="round" stroke-dasharray="28.3" stroke-dashoffset="28.3"><animate attributeName="stroke-dashoffset" dur="1.4s" values="28.3;0;28.3" repeatCount="indefinite"/></circle></svg>') center center no-repeat;
  background-size: 40px 40px;
}

.image-error {
  background: #f5f5f5 url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><text x="20" y="25" text-anchor="middle" fill="%23ccc" font-size="12" font-family="Arial">圖片載入失敗</text></svg>') center center no-repeat;
  background-size: contain;
}

.template-content {
  padding: 20px;
}

.template-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
}

.template-description {
  color: #666;
  font-size: 14px;
  margin-bottom: 15px;
  line-height: 1.5;
}

.template-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 15px;
}

.tag {
  background: #fff8e1;
  color: #fabe00;
  padding: 4px 12px;
  border-radius: 25px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #fabe00;
}

.template-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.template-category {
  background: #f0f0f0;
  color: #666;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}

.preview-btn {
  background: #fabe00;
  color: #333;
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.3s ease;
}

.preview-btn:hover {
  background: #e6a800;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background-color: white;
  margin: 5% auto;
  padding: 0;
  border-radius: 10px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideIn 0.3s ease;
}

.modal-header {
  padding: 10px 30px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  color: #595959;
  font-size: 1.5rem;
}

.close {
  position: absolute;
  right: 20px;
  top: 20px;
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1001;
}

.close:hover {
  color: #595959;
}

.modal-body {
  padding: 10px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.modal-body img {
  width: auto;
  height: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 10px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.modal-info p {
  color: #595959;
  line-height: 1.6;
  margin-bottom: 20px;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-footer {
  padding: 20px 30px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 15px;
  justify-content: flex-end;
}

.btn-primary {
  background: #fabe00;
  color: #595959;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: background 0.3s ease;
}

.btn-primary:hover {
  background: #e6a800;
}

.btn-secondary {
  background: #f5f5f5;
  color: #595959;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: background 0.3s ease;
}

.btn-secondary:hover {
  background: #e0e0e0;
}


/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .nav-menu {
    display: none;
  }

  .hero-title {
    font-size: 2.5rem;
  }

  .search-controls {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }


  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    justify-content: space-between;
  }

  .templates-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .modal-content {
    width: 95%;
    margin: 10% auto;
  }

  .modal-footer {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 2rem;
  }

  .search-section {
    padding: 24px 0;
  }

  .search-controls {
    gap: 8px;
  }

  .search-input {
    padding: 10px 12px 10px 36px;
    height: 44px;
    font-size: 14px;
  }

  .search-icon {
    left: 10px;
    font-size: 14px;
  }


  .template-content {
    padding: 15px;
  }
}