:root {
  --bg: #fff;
  --text: #222;
  --highlight: #ffcc00;
  --accent: #ff0000;
  --shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --bg: #121212;
  --text: black;
  --highlight: #ffd700;
  --accent: #ff4444;
  --shadow: rgba(255, 255, 255, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.4s ease, color 0.4s ease;
}

header {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1000;
  box-shadow: 0 1px 4px var(--shadow);
  transition: background 0.4s ease, box-shadow 0.4s ease;
  padding-bottom: 8px;
}

.top-nav {
  display: flex;
  overflow-x: auto;
  white-space: nowrap;
  padding: 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--highlight);
}

.top-nav::-webkit-scrollbar {
  display: none;
}

.nav-item {
  flex: 0 0 auto;
  margin-right: 10px;
  padding: 8px 18px;
  background-color: var(--highlight);
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s ease;
  user-select: none;
}

.nav-item:hover {
  background-color: #f1c40f;
}

.category-link.active {
  font-weight: bold;
  text-decoration: underline;
  color: var(--accent);
}

.search-bar {
  display: flex;
  padding: 10px;
  gap: 10px;
  background: var(--bg);
  align-items: center;
  justify-content: center;
}

.search-container {
  position: relative;
  width: 300px;
}

#search {
  width: 100%;
  padding: 12px 40px 12px 16px;
  font-size: 16px;
  border: 1px solid var(--highlight);
  border-radius: 8px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: 0.3s;
}

#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(255,0,0,0.2);
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 18px;
  color: var(--accent);
  display: none;
  user-select: none;
}

.search-clear:hover {
  color: #000;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--highlight);
  max-height: 200px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.search-result {
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.search-result:hover {
  background-color: var(--highlight);
  color: var(--bg);
}

.theme-toggle {
  font-size: 22px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.3s ease;
  padding: 0 10px;
}

.theme-toggle:hover {
  transform: rotate(20deg);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  padding: 20px;
}

.product-card {
  background: #fff;
  color: black;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 3px 8px rgba(0,0,0,0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: fadeIn 0.5s ease-in;
}

.product-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 6px 14px rgba(255, 0, 0, 0.3);
}

.product-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background:black;
}

.product-info {
  padding: 12px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.product-info h4 {
  margin: 0 0 6px;
  font-size: 16px;
}

.product-info p {
  margin: 0 0 10px;
  font-size: 14px;
  color: black;
  flex-grow: 1;
}

.cart-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-btn button {
  background: var(--accent);
  border: none;
  padding: 6px 12px;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s ease;
}

.cart-btn button:hover {
  background: #cc0000;
}

.cart-btn span {
  font-weight: bold;
}

.cart-icon {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--accent);
  color: white;
  padding: 12px 18px;
  border-radius: 30px;
  cursor: pointer;
  font-size: 14px;
  z-index: 999;
  box-shadow: 0 4px 10px rgba(255, 0, 0, 0.4);
  transition: background 0.3s ease;
  user-select: none;
}

.cart-icon:hover {
  background: #cc0000;
}

.cart-popup {
  position: fixed;
  right: 20px;
  bottom: 70px;
  background: var(--bg);
  border: 1px solid var(--highlight);
  border-radius: 10px;
  padding: 15px;
  width: 300px;
  display: none;
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 999;
  transition: all 0.3s ease;
}

.cart-popup.active {
  display: block;
}

.cart-total {
  margin-top: 10px;
  font-weight: bold;
  font-size: 16px;
  text-align: right;
}

#checkout-btn {
  margin-top: 15px;
  width: 100%;
  background: var(--highlight);
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-weight: bold;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.3s ease;
}

#checkout-btn:hover {
  background: #ffe066;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Мобильная адаптация */
@media (max-width: 600px) {
  .product-grid {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .product-card {
    flex-direction: row;
    height: 130px;
  }

  .product-card img {
    width: 40%;
    height: 100%;
    object-fit: cover;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  .product-info {
    padding: 10px;
  }
}
.product-card img {
  width: 160px;          /* фиксированная ширина */
  height: 160px;         /* фиксированная высота - квадрат */
  object-fit: contain;   /* изображение целиком, без обрезки */
  background: #fff;      /* белый фон, чтобы пустые области были белыми */
  display: block;        /* убрать нижние отступы */
  margin: 0 auto;        /* центрируем по горизонтали */
  border-radius: 12px 12px 0 0; /* скругленные углы сверху (если нужно) */
}

/* Адаптив для мобильных */
@media (max-width: 600px) {
  .product-card img {
    width: 40%;          /* ширина 40% от карточки */
    aspect-ratio: 1 / 1; /* сохраняем квадрат */
    height: auto;        /* высота подстраивается */
    object-fit: contain; /* изображение полностью вмещается */
    border-radius: 10px 0 0 10px;
    margin: 0;
  }
}
header {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1000;
  box-shadow: 0 1px 4px var(--shadow);
  transition: background 0.4s ease, box-shadow 0.4s ease;
  padding: 4px 0; /* уменьшили отступы */
}

.top-nav {
  display: flex;
  overflow-x: auto;
  white-space: nowrap;
  padding: 6px 8px; /* уменьшили отступ */
  background: var(--bg);
  border-bottom: 1px solid var(--highlight);
}

.nav-item {
  flex: 0 0 auto;
  margin-right: 8px;
  padding: 6px 14px; /* чуть меньше */
  font-size: 13px; /* немного меньше */
  border-radius: 16px;
}
