/* ====== КАТАЛОГ ====== */

.catalog {
  padding: 4rem 5%;
  margin-top: var(--header-height);
  position: relative;
}

.search-highlight {
  background-color: #ffeb3b;
  color: #000;
  padding: 1px 2px;
  font-weight: 600;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}



.catalog .container {
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
}

.catalog-header {
  margin-bottom: 3rem;
  text-align: center;
  position: relative;
  z-index: 1;
}



.catalog-controls {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 2rem;
  position: relative;
  z-index: 1;
}

/* ====== ПОИСК И ФИЛЬТРЫ ====== */

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

.search-box input {
  width: 100%;
  padding: 1.2rem 1.5rem 1.2rem 3.5rem;
  border-radius: 50px;
  border: none;
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 1rem;
  border: 1px solid var(--card-border);
  transition: var(--transition);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-neon);
  box-shadow:
    0 0 0 2px var(--accent-neon-transparent),
    0 8px 32px rgba(0, 240, 255, 0.1);
}

.search-icon {
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 1.1rem;
  transition: var(--transition);
}

.search-box input:focus + .search-icon {
  color: var(--accent-neon);
}

.filters-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.filter-btn,
.sort-btn {
  position: relative;
  overflow: hidden;
  outline: none;
  padding: 0.8rem 1.5rem;
  border-radius: 50px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
}

.filter-btn:hover,
.sort-btn:hover {
  background: var(--accent-neon-transparent);
  color: var(--accent-neon);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 240, 255, 0.1);
}

.filter-btn.active,
.sort-btn.active {
  border-color: transparent;
  color: #000;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 240, 255, 0.3);
}

.filter-btn.active::before,
.sort-btn.active::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent-gradient);
  z-index: -1;
}

.sort-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 1rem;
}

.grid-toggle {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.grid-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}

.grid-toggle-btn i {
  font-size: 0.9rem;
}

.grid-toggle-btn span {
  font-weight: 500;
}

.grid-toggle-btn:hover {
  background: var(--accent-neon-transparent);
  color: var(--accent-neon);
}

.grid-toggle-btn.active {
  background: var(--accent-gradient);
  color: #000;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(0, 240, 255, 0.3);
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
  position: relative;
  z-index: 1;
}

/* Мобильные режимы сетки (1×1 и 2×1) */
@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .products-grid.grid-1x1 {
    grid-template-columns: 1fr;
  }

  .products-grid.grid-2x1 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-toggle {
    justify-content: center;
  }
}

/* ====== КАРТОЧКИ ТОВАРОВ ====== */

.product-card {
  position: relative;
  background: #141722;
  border-radius: 18px;
  overflow: hidden;
  transition: var(--transition);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  height: 100%;
  transform-style: preserve-3d;
  perspective: 1000px;
}

.product-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: var(--transition);
  z-index: 0;
}

.product-card:hover {
  transform: translateY(-8px) rotateX(2deg) rotateY(2deg);
  box-shadow:
    0 12px 40px rgba(0, 240, 255, 0.2),
    0 0 0 1px var(--accent-neon),
    0 0 30px rgba(0, 240, 255, 0.1);
  border-color: var(--accent-neon);
}

.product-card:hover::before {
  opacity: 0.1;
}

.product-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, var(--accent-neon-transparent) 0%, transparent 70%);
  opacity: 0;
  transition: var(--transition);
  pointer-events: none;
}

.product-card:hover::after {
  opacity: 0.3;
  animation: pulseGlow 2s ease-in-out infinite;
}

.product-image-container {
  height: 240px;
  position: relative;
  overflow: hidden;
  background: var(--image-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  flex-shrink: 0;
}

.product-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.3));
}

.product-card:hover .product-image {
  transform: scale(1.08) translateY(-5px);
  filter: drop-shadow(0 10px 20px rgba(0, 240, 255, 0.3));
}

.product-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: linear-gradient(135deg, #ffd45a, #ff9d2d);
  color: #000;
  padding: 0.3rem 1rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 2;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: var(--transition);
}

.product-badge.new {
  background: linear-gradient(135deg, #8ff3ff, #4ab3ff);
}

.discount-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #001018;
  background: linear-gradient(135deg, #7cffb8 0%, #23e06f 100%);
  box-shadow: 0 4px 12px rgba(35, 224, 111, 0.35),
    0 0 0 2px rgba(35, 224, 111, 0.25) inset;
  transform-origin: center;
  overflow: hidden;
  isolation: isolate;
  animation: badgePulse 2.2s ease-in-out infinite, badgeFloat 6s ease-in-out infinite;
}

.discount-badge::after {
  content: '';
  position: absolute;
  inset: -40% -120% auto auto;
  width: 160%;
  height: 200%;
  transform: rotate(25deg) translateX(-120%);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.35) 45%,
    rgba(255, 255, 255, 0) 65%
  );
  mix-blend-mode: soft-light;
  animation: badgeShine 3.8s ease-in-out infinite;
}

.product-info {
  padding: 16px 18px 18px;
  position: relative;
  z-index: 1;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.product-title {
  margin-bottom: 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  transition: var(--transition);
}

.product-card:hover .product-title {
  color: var(--accent-neon);
}

.product-description {
  margin-bottom: 12px;
  color: #98a0b3;
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-grow: 1;
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: #d6ddf2;
  font-size: 13px;
}

.product-rating-empty {
  color: #8d97b1;
}

.product-rating-stars {
  --rating: 0;
  --star-size: 14px;
  position: relative;
  display: inline-block;
  font-size: var(--star-size);
  line-height: 1;
  letter-spacing: 1px;
}

.product-rating-stars::before {
  content: '★★★★★';
  color: rgba(255, 255, 255, 0.22);
}

.product-rating-stars::after {
  content: '★★★★★';
  color: #f9c74f;
  position: absolute;
  left: 0;
  top: 0;
  width: calc((var(--rating) / 5) * 100%);
  overflow: hidden;
  white-space: nowrap;
}

.product-rating-value {
  font-weight: 700;
  color: #eef4ff;
}

.product-rating-count {
  color: #91a0bf;
}

.product-footer {
  display: flex;
  flex-direction: column;
  margin-top: auto;
  width: 100%;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
  justify-content: flex-start;
}

.price-current {
  font-size: 22px;
  font-weight: 800;
  color: #9cf0ff;
  white-space: nowrap;
}

.price-current::after {
  content: ' ₽';
  font-size: 14px;
  opacity: 0.85;
}

.price-old {
  font-size: 16px;
  font-weight: 700;
  color: #cfd5e6;
  opacity: 1;
  text-decoration-line: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}

.buy-button {
  width: 100%;
  border-radius: 12px;
  border: none;
  padding: 12px 14px;
  background: linear-gradient(135deg, #33e6ff, #187bff);
  color: #001018;
  font-weight: 800;
  display: flex;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: 0.15s;
  font-size: 1.05rem;
}

.buy-button:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 5px 20px rgba(0, 240, 255, 0.4);
}

.product-card:hover .buy-button {
  animation: pulseButton 1.5s ease-in-out infinite;
}

.buy-button.out-of-stock {
  background: #232838;
  color: #8a90a6;
  cursor: not-allowed;
  box-shadow: none;
  animation: none !important;
  opacity: 0.75;
}

/* ====== СОСТОЯНИЯ СПИСКА ====== */

.loading-spinner,
.no-results,
.error-message {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  text-align: center;
  color: var(--text-secondary);
  background: var(--card-bg);
  border-radius: var(--border-radius);
  border: 1px dashed var(--card-border);
  min-height: 300px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--accent-neon-transparent);
  border-top: 4px solid var(--accent-neon);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1.5rem;
}

.loading-spinner p,
.no-results p,
.error-message p {
  max-width: 500px;
  line-height: 1.6;
}

/* ====== ДОП. ЭЛЕМЕНТЫ КОРЗИНЫ, УНИКАЛЬНЫЕ ДЛЯ КАТАЛОГА ====== */

.cart-item-flavor {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

/* ====== МОДАЛ ВКУСОВ ====== */

.flavor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 11, 0.95);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: 20px;
  overflow-y: auto;
}

.flavor-overlay.active {
  display: flex;
  opacity: 1;
}

.flavor-modal {
  background: var(--bg-darker);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  color: var(--text-primary);
  text-align: center;
  border: 1px solid var(--accent-neon-transparent);
  transform: translateY(20px);
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  margin: auto;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.flavor-overlay.active .flavor-modal {
  transform: translateY(0);
  opacity: 1;
}

.flavor-modal h3 {
  flex-shrink: 0;
  margin-bottom: 1rem;
  font-size: 1.4rem;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

#flavor-list {
  flex: 1;
  overflow-y: auto;
  position: relative;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-neon) transparent;
}

#flavor-list::after {
  content: '';
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to top, var(--bg-darker) 0%, transparent 100%);
  pointer-events: none;
  z-index: 2;
}

.flavor-preview-large {
  width: 100%;
  height: 280px;
  margin-bottom: 1.5rem;
  border-radius: var(--border-radius);
  overflow: hidden;
  background: var(--image-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.15);
  padding: 1.5rem;
  position: relative;
}

.flavor-preview-large::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(0, 240, 255, 0.05) 0%, transparent 70%);
  z-index: 1;
  pointer-events: none;
}

.flavor-preview-large img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--border-radius-sm);
  transition: all 0.3s ease;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.3));
}

.flavor-list-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 4.5rem;
}

.flavor-item {
  padding: 0.8rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  min-height: 52px;
}

.flavor-item::before {
  content: '';
  position: absolute;
  inset: 0;
  width: 0;
  background: var(--accent-gradient);
  transition: var(--transition);
  z-index: 0;
}

.flavor-item:hover {
  border-color: var(--accent-neon);
  transform: translateY(-2px);
}

.flavor-item.selected {
  border-color: var(--accent-neon);
  box-shadow: 0 0 0 1px var(--accent-neon);
}

.flavor-item.selected::before {
  width: 100%;
  opacity: 0.15;
}

.flavor-name {
  position: relative;
  z-index: 1;
  flex-grow: 1;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 10px;
}

.flavor-item.selected .flavor-name {
  font-weight: 600;
}

.flavor-icon {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
  min-width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: var(--transition);
}

.flavor-item.selected .flavor-icon {
  color: var(--accent-neon);
  transform: scale(1.2);
}

.flavor-item.out-of-stock {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.5);
  transform: none !important;
  border-color: var(--card-border) !important;
}

.flavor-buttons {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-darker);
  padding-top: 1rem;
  padding-bottom: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: center;
  gap: 1rem;
  z-index: 5;
  flex-shrink: 0;
}

.flavor-buttons button {
  flex: 1;
  min-width: 120px;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
  font-size: 0.9rem;
}

#flavor-cancel {
  background: var(--card-bg);
  color: var(--text-secondary);
  border: 1px solid var(--card-border);
}

#flavor-confirm {
  background: var(--accent-gradient);
  color: #000;
  box-shadow: 0 5px 15px rgba(0, 240, 255, 0.3);
}

#flavor-cancel:hover {
  background: var(--accent-neon-transparent);
  color: var(--accent-neon);
  border-color: var(--accent-neon);
}

#flavor-confirm:hover {
  background: var(--accent-gradient-hover);
  box-shadow: 0 8px 25px rgba(0, 240, 255, 0.5);
  transform: translateY(-2px);
}

/* ====== АДАПТИВ КАТАЛОГА ====== */

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

@media (max-width: 768px) {
  .catalog {
    padding: 1.2rem 0.75rem 1.5rem;
  }

  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .filters-container,
  .sort-filter {
    gap: 0.5rem;
  }

  .filter-btn,
  .sort-btn {
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
  }

  .product-image-container {
    height: 180px;
  }

  .flavor-preview-large {
    height: 240px;
    padding: 1rem;
  }
}

@media (max-width: 600px) {
  .filters-container {
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 0.8rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-neon) transparent;
  }

  .filters-container::-webkit-scrollbar {
    height: 4px;
  }

  .filters-container::-webkit-scrollbar-thumb {
    background-color: var(--accent-neon);
    border-radius: 2px;
  }
}

@media (max-width: 480px) {
  .catalog {
    padding: 0.8rem 0.35rem 1.2rem;
  }

  .catalog .container {
    padding: 0 0.25rem;
    max-width: none;
  }

  html.tg-webapp-mobile body .catalog .container {
    padding: 0 0.1rem;
  }

  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .product-image-container {
    height: 160px;
  }

  .search-box input {
    padding: 0.8rem 1.2rem 0.8rem 2.5rem;
  }

  .search-icon {
    left: 1rem;
  }

  .filter-btn,
  .sort-btn {
    padding: 0.5rem 0.8rem;
  }

  .flavor-modal {
    padding: 1.2rem;
  }

  .flavor-preview-large {
    height: 200px;
  }

  .flavor-buttons {
    flex-direction: column;
    gap: 0.5rem;
  }

  .flavor-buttons button {
    width: 100%;
  }

  .cart-modal {
    max-width: 100%;
  }
}

/* ====== KEYFRAMES (каталог) ====== */

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.5; }
}

@keyframes pulseButton {
  0%, 100% { box-shadow: 0 5px 20px rgba(0, 240, 255, 0.4); }
  50% { box-shadow: 0 5px 25px rgba(0, 240, 255, 0.6); }
}

@keyframes badgePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(35, 224, 111, 0.35),
      0 0 0 2px rgba(35, 224, 111, 0.25) inset;
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 8px 18px rgba(35, 224, 111, 0.5),
      0 0 0 3px rgba(35, 224, 111, 0.35) inset;
  }
}

@keyframes badgeFloat {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -2px; }
}

@keyframes badgeShine {
  0%, 60% {
    transform: rotate(25deg) translateX(-120%);
    opacity: 0;
  }
  65% {
    opacity: 0.9;
  }
  90% {
    transform: rotate(25deg) translateX(30%);
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
