
:root {
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --price: #10b981;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  --card-hover-shadow: 0 12px 36px rgba(0, 0, 0, 0.12);
  --header-bg: rgba(255, 255, 255, 0.8);
  --badge-bg: rgba(99, 102, 241, 0.1);
  --badge-text: #6366f1;
  --meta-border: #f3f4f6;
  --transition: 0.3s ease;
}

body.dark {
  --bg: #0f0f1a;
  --card-bg: #1a1a2e;
  --text: #e5e7eb;
  --text-secondary: #9ca3af;
  --border: #2d2d44;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --card-hover-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  --header-bg: rgba(15, 15, 26, 0.85);
  --badge-bg: rgba(99, 102, 241, 0.2);
  --badge-text: #818cf8;
  --meta-border: #2d2d44;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition:
    background var(--transition),
    color var(--transition);
}

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 20px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  transition:
    background var(--transition),
    border-color var(--transition);
}

#heading {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
  transition: color var(--transition);
}

.theme-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}

.theme-btn:hover {
  transform: rotate(30deg) scale(1.1);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 20px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: color var(--transition);
}

.loader.hidden {
  display: none;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.output {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.product-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: all var(--transition);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-hover-shadow);
  border-color: var(--accent);
}

.product-card img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.product-card:hover img {
  transform: scale(1.03);
}

.card-img-wrap {
  overflow: hidden;
  position: relative;
}

.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 10px;
}

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

.tag-category {
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  transition:
    background var(--transition),
    color var(--transition);
}

.tag-rating {
  font-size: 0.78rem;
  color: #f59e0b;
  font-weight: 600;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  transition: color var(--transition);
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.55;
  flex-grow: 1;
  transition: color var(--transition);
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--meta-border);
  transition: border-color var(--transition);
}

.price-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.price {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--price);
}

.hot-deal {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 700;
}

.btn-cart {
  background: linear-gradient(135deg, var(--accent), #a855f7);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: "Inter", sans-serif;
  transition: all var(--transition);
}

.btn-cart:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  padding-top: 10px;
  border-top: 1px solid var(--meta-border);
  transition:
    color var(--transition),
    border-color var(--transition);
}

@media (max-width: 1024px) {
  .output {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    padding: 16px;
  }

  #heading {
    font-size: 1.5rem;
  }
}

@media (max-width: 768px) {
  .output {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    padding: 12px;
  }

  header {
    padding: 16px;
  }

  #heading {
    font-size: 1.3rem;
  }

  .theme-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
    top: 16px;
    right: 12px;
  }

  .product-card img {
    height: 180px;
  }
}

@media (max-width: 480px) {
  .output {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 10px;
  }

  #heading {
    font-size: 1.1rem;
  }

  .subtitle {
    font-size: 0.75rem;
  }

  .card-body {
    padding: 14px;
  }

  .product-card img {
    height: 200px;
  }

  .card-footer {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .btn-cart {
    text-align: center;
    padding: 10px;
  }
}

@media (max-width: 360px) {
  .output {
    padding: 8px;
  }

  header {
    padding: 12px 8px;
  }

  #heading {
    font-size: 1rem;
  }
}
