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

:root {
  --primary-color: #007bff;
  --primary-dark: #0056b3;
  --secondary-color: #6c757d;
  --background-color: #f8f9fa;
  --text-color: #212529;
  --text-light: #6c757d;
  --border-color: #dee2e6;
  --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --card-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
  --success-color: #28a745;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background: var(--background-color);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  background: white;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-color);
  text-decoration: none;
}

.logo svg {
  color: var(--primary-color);
}

.nav {
  display: flex;
  gap: 24px;
  align-items: center;
}

.nav a {
  color: var(--text-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.nav a:hover,
.nav a.active {
  color: var(--primary-color);
}

.nav-github {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-github svg {
  color: currentColor;
  transition: color 0.2s;
}

.nav-github:hover svg {
  color: currentColor;
}

/* Language Switcher */
.lang-switcher {
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid var(--border-color);
  position: relative;
}

.lang-button {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  font-family: inherit;
  font-weight: 500;
}

.lang-button:hover {
  border-color: var(--primary-color);
  background: rgba(0, 123, 255, 0.05);
}

.lang-button svg:first-child {
  color: var(--primary-color);
}

.lang-arrow {
  transition: transform 0.2s;
}

.lang-button:hover .lang-arrow {
  transform: translateY(2px);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 120px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 1000;
}

.lang-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-option {
  display: block;
  padding: 10px 16px;
  color: var(--text-color);
  text-decoration: none;
  transition: background 0.15s;
  border-radius: 4px;
  margin: 4px;
}

.lang-option:first-child {
  margin-top: 8px;
}

.lang-option:last-child {
  margin-bottom: 8px;
}

.lang-option:hover {
  background: var(--background-color);
  color: var(--primary-color);
}

.lang-option.active {
  color: var(--primary-color);
  font-weight: 600;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 80px 0;
  text-align: center;
}

.hero h1 {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 16px;
}

.hero-description {
  font-size: 20px;
  opacity: 0.9;
  margin-bottom: 32px;
}

.search-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  padding: 16px 48px 16px 20px;
  font-size: 16px;
  border: none;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

/* Filters */
.filters {
  background: white;
  border-bottom: 1px solid var(--border-color);
  padding: 24px 0;
}

.filter-groups {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-weight: 500;
  color: var(--text-light);
}

.filter-select {
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: white;
  font-size: 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.results-count {
  text-align: right;
  color: var(--text-light);
  font-size: 14px;
}

#resultsCount {
  font-weight: 600;
  color: var(--primary-color);
}

/* Templates Grid */
.templates {
  padding: 48px 0;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 24px;
}

.template-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.template-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
}

.template-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 12px;
}

.template-title {
  font-size: 20px;
  font-weight: 700;
}

.template-title a {
  color: var(--text-color);
  text-decoration: none;
}

.template-title a:hover {
  color: var(--primary-color);
}

.template-category {
  background: var(--primary-color);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.template-description {
  color: var(--text-light);
  margin-bottom: 16px;
  flex-grow: 1;
}

.template-features {
  list-style: none;
  margin-bottom: 16px;
}

.template-features li {
  padding: 4px 0;
  padding-left: 24px;
  position: relative;
  font-size: 14px;
  color: var(--text-light);
}

.template-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--success-color);
  font-weight: bold;
}

.template-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tag {
  background: var(--background-color);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-light);
  border: 1px solid var(--border-color);
}

.template-actions {
  display: flex;
  gap: 12px;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.4;
}

.btn svg {
  color: currentColor;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: white;
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--background-color);
  border-color: var(--text-light);
}

/* No Results */
.no-results {
  text-align: center;
  padding: 48px;
  color: var(--text-light);
}

.no-results h3 {
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--text-color);
}

/* Template Detail Page */
.breadcrumb {
  background: white;
  border-bottom: 1px solid var(--border-color);
  padding: 16px 0;
}

.breadcrumb .container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.breadcrumb a {
  color: var(--primary-color);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.separator {
  color: var(--text-light);
}

.current {
  color: var(--text-light);
}

.template-detail {
  padding: 48px 0;
}

.template-header-detail {
  margin-bottom: 48px;
}

.template-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.template-description-large {
  font-size: 20px;
  color: var(--text-light);
  margin-bottom: 24px;
}

.template-tags-large {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 32px;
}

.template-tags-large .tag {
  padding: 6px 14px;
  font-size: 14px;
}

.template-actions-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 100%;
}

.template-actions-detail .btn {
  width: 100%;
}

.command-display {
  background: #2d2d2d;
  color: #f8f8f2;
  padding: 12px 16px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.command-display code {
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 14px;
  color: #a6e22e;
  flex: 1;
  overflow-x: auto;
  white-space: nowrap;
}

.copy-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  color: rgba(255, 255, 255, 0.6);
  border-radius: 4px;
}

.copy-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}

.copy-button:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.95);
}

.copy-button.copied {
  color: #2ecc71;
}

.copy-button svg {
  display: block;
}

.template-content {
  max-width: 1000px;
  margin: 0 auto;
  text-align: center;
}

.template-features-section,
.template-guide-section {
  margin-bottom: 48px;
}

.template-features-section h2,
.template-guide-section h2 {
  font-size: 32px;
  margin-bottom: 24px;
  text-align: center;
}

.features-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  text-align: left;
}

.features-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.features-list li svg {
  color: var(--success-color);
  flex-shrink: 0;
}

.guide-content {
  padding: 32px 0;
  line-height: 1.8;
  text-align: left;
}

.guide-content h1,
.guide-content h2,
.guide-content h3 {
  margin-top: 32px;
  margin-bottom: 16px;
}

.guide-content h1:first-child {
  margin-top: 0;
}

.guide-content pre {
  background: transparent;
  padding: 0;
  margin: 16px 0;
  border-radius: 8px;
  overflow: hidden;
}

.guide-content pre code {
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  display: block;
  overflow-x: auto;
}

/* Inline code */
.guide-content :not(pre) > code {
  background: #f1f3f5;
  color: #d6336c;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 0.9em;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--success-color);
  color: white;
  padding: 16px 24px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease;
}

.toast.hidden {
  display: none;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Footer */
.footer {
  background: white;
  border-top: 1px solid var(--border-color);
  padding: 24px 0;
  margin-top: 48px;
  text-align: center;
}

.footer p {
  color: var(--text-light);
  margin: 0;
  font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
  /* Container */
  .container {
    padding: 0 16px;
  }

  /* Header */
  .header-content {
    flex-wrap: wrap;
    padding: 12px 0;
  }

  .logo {
    font-size: 18px;
  }

  .logo svg {
    width: 28px;
    height: 28px;
  }

  .nav {
    gap: 8px;
    font-size: 14px;
    flex-wrap: nowrap;
    margin-left: auto;
  }

  .nav-github {
    font-size: 14px;
  }

  .nav-github svg {
    width: 18px;
    height: 18px;
  }

  .lang-switcher {
    margin-left: 8px;
    padding-left: 8px;
  }

  .lang-select {
    padding: 4px 8px;
    font-size: 13px;
  }

  /* Hero */
  .hero {
    padding: 48px 0;
  }

  .hero h1 {
    font-size: 28px;
    margin-bottom: 12px;
  }

  .hero-description {
    font-size: 16px;
    margin-bottom: 24px;
  }

  .search-input {
    padding: 14px 40px 14px 16px;
    font-size: 15px;
  }

  /* Filters */
  .filters {
    padding: 16px 0;
  }

  .filter-groups {
    flex-direction: column;
    gap: 12px;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .filter-select {
    width: 100%;
    padding: 10px 12px;
  }

  .results-count {
    text-align: center;
    margin-top: 8px;
  }

  /* Templates Grid */
  .templates {
    padding: 32px 0;
  }

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

  .template-card {
    padding: 20px;
  }

  .template-header {
    flex-direction: column;
    gap: 8px;
  }

  .template-title {
    font-size: 18px;
  }

  .template-features {
    margin-bottom: 12px;
  }

  .template-features li {
    font-size: 13px;
  }

  .template-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
  }

  /* Template Detail */
  .breadcrumb {
    padding: 12px 0;
    font-size: 13px;
  }

  .template-detail {
    padding: 32px 0;
  }

  .template-header-detail {
    margin-bottom: 32px;
  }

  .template-meta {
    flex-wrap: wrap;
  }

  .template-description-large {
    font-size: 18px;
  }

  .template-tags-large {
    gap: 8px;
  }

  .template-tags-large .tag {
    padding: 5px 12px;
    font-size: 13px;
  }

  .template-actions-detail {
    gap: 12px;
  }

  .template-actions-detail .btn {
    width: 100%;
  }

  .command-display {
    padding: 12px;
  }

  .command-display code {
    font-size: 13px;
    word-break: break-all;
  }

  .template-features-section h2,
  .template-guide-section h2 {
    font-size: 24px;
  }

  .features-list {
    grid-template-columns: 1fr;
  }

  .guide-content {
    padding: 20px;
  }

  .guide-content pre {
    margin: 12px 0;
  }

  .guide-content pre code {
    font-size: 13px;
  }

  .guide-content :not(pre) > code {
    font-size: 0.85em;
    padding: 2px 5px;
  }

  /* Toast */
  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  /* Footer */
  .footer {
    padding: 20px 0;
    margin-top: 32px;
  }

  .footer p {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  /* Extra small devices */
  .hero h1 {
    font-size: 24px;
  }

  .hero-description {
    font-size: 15px;
  }

  .template-card {
    padding: 16px;
  }

  .template-title {
    font-size: 16px;
  }

  .btn {
    font-size: 13px;
    padding: 10px 16px;
  }

  .template-description-large {
    font-size: 16px;
  }

  .template-features-section h2,
  .template-guide-section h2 {
    font-size: 20px;
  }

  .guide-content {
    padding: 16px;
  }
}
