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

/* Отступ для основного контента под фиксированной шапкой */

/* ========== ЗАГОЛОВОК КАТАЛОГА ========== */
.catalog-header {
  text-align: center;
  font-size: 32px;
  font-weight: 600;
  color: #45555f;
  margin: 32px 0;
  position: relative;
  z-index: 1;
}

/* ========== КОНТРОЛЫ ========== */
.catalog-controls {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
  align-items: center;
  box-sizing: border-box;
  position: sticky;
  top: 80px;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  transition: all 0.3s ease;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  -webkit-perspective: 1000px;
  perspective: 1000px;
}

.catalog-controls.scrolled {
  background: rgba(255, 255, 255, 0.98);
}

/* Фильтры */
.catalog-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding-bottom: 6px;
  box-sizing: border-box;
  flex: 1 1 60%;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

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

.catalog-filters::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 2px;
}

.catalog-filters::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

.catalog-filters::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.catalog-filters button {
  background-color: #f3f4f6;
  border: none;
  border-radius: 9999px;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  font-size: 14px;
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
}

.catalog-filters button:hover {
  background-color: #e5e7eb;
  color: #45555f;
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.catalog-filters button.active {
  background: linear-gradient(135deg, #45555f, #2f3c44);
  color: #fff;
  box-shadow: 0 4px 12px rgba(69, 85, 95, 0.3);
}

.catalog-filters button.active:hover {
  background: linear-gradient(135deg, #2f3c44, #1a2529);
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 6px 16px rgba(69, 85, 95, 0.4);
}

/* Поиск и сортировка */
.controls-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 0 0 auto;
}

.search-input {
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  min-width: 160px;
  max-width: 320px;
  box-sizing: border-box;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: #fff;
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  animation: searchInputFadeIn 0.6s ease-out forwards;
}

.search-input:focus {
  outline: none;
  border-color: #2d5a27;
  box-shadow: 0 0 0 3px rgba(45, 90, 39, 0.1), 0 4px 12px rgba(45, 90, 39, 0.15);
  transform: translateY(0) scale(1) !important;
  opacity: 1 !important;
}

.search-input:hover:not(:focus) {
  border-color: #4a7c59;
  box-shadow: 0 2px 8px rgba(45, 90, 39, 0.1);
  transform: translateY(-2px);
}

@keyframes searchInputFadeIn {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sort-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  animation: sortWrapperFadeIn 0.6s ease-out 0.2s forwards;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(
    135deg,
    rgba(127, 179, 20, 0.05),
    rgba(255, 255, 255, 0.8)
  );
  border-radius: 12px;
  padding: 6px 12px;
  border: 2px solid rgba(127, 179, 20, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

@keyframes sortWrapperFadeIn {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sort-wrapper:hover {
  transform: translateY(-2px);
  border-color: rgba(127, 179, 20, 0.3);
  box-shadow: 0 4px 12px rgba(127, 179, 20, 0.15);
  background: linear-gradient(
    135deg,
    rgba(127, 179, 20, 0.1),
    rgba(255, 255, 255, 0.9)
  );
}

.sort-select {
  padding: 8px 32px 8px 12px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  appearance: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  color: #45555f;
  position: relative;
  outline: none;
  min-width: 140px;
}

.sort-select:hover {
  color: #7fb314;
}

.sort-select:focus {
  color: #6a9810;
}

.sort-select::after {
  content: "▼";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #7fb314;
  font-size: 10px;
  transition: transform 0.2s ease;
  font-weight: normal;
}

.sort-select:focus::after {
  transform: translateY(-50%) rotate(180deg);
}

.sort-reset {
  cursor: pointer;
  color: #dc2626;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(220, 38, 38, 0.2);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.sort-reset:hover {
  background: #dc2626;
  color: white;
  border-color: #dc2626;
  transform: scale(1.15) rotate(90deg);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.sort-reset:active {
  transform: scale(1) rotate(90deg);
}

.color-thumbs {
  display: flex; /* flex-контейнер */
  flex-wrap: wrap; /* перенос на новую строку при необходимости */
  justify-content: space-between; /* выравнивание по центру горизонтально */
  gap: 0px; /* расстояние между миниатюрами */
  margin-bottom: 20px;
}

/* Мобильные: карточка раскрывается в потоке, без absolute и z-index */
@media (max-width: 1025px) {
  /* Карточка в потоке */
  .card > div {
    position: relative !important;
    z-index: 20 !important;
  }

  /* Контейнер миниатюр цветов */
  .color-thumbs-wrapper {
    max-height: 65px; /* свернутый вид */
    overflow: hidden;
    transition: max-height 0.3s ease;
    position: relative !important;
    box-shadow: none !important;
  }

  .color-thumbs-wrapper.expanded {
    max-height: 200px; /* раскрытый вид */
    justify-content: center;
  }
}

.profile-icon svg,
.cart-icon svg {
  width: 28px; /* одинаковая ширина */
  height: 28px; /* одинаковая высота */
  display: block;
  cursor: pointer;
  position: relative;
  transition: background-color 0.3s;
}

.profile-icon,
.cart-icon {
  margin-right: 20px;
}

.color-thumbs-wrapper {
  position: absolute;
  display: flex;
  top: 100%; /* отталкиваем от низа карточки */
  left: 0;
  width: 100%;
  background: #fff;
  border-radius: 8px;
  z-index: 10; /* выше соседних карточек */
  overflow: hidden;
  transition: max-height 0.3s ease;
  justify-content: space-around;
}

/* ========== СЕТКА КАТАЛОГА ========== */
.catalog-container {
  max-width: 1200px;
  min-height: 500px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  box-sizing: border-box;
  align-items: start;
}

/* Хедер как на странице продукта */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
}

/* Центрирование логотипа в шапке */
.site-header .logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Скрываем дублирующий верхний логотип только на странице каталога */
.logo-top {
  display: none !important;
}

/* Размер логотипа */
.site-header .logo img {
  height: 60px;
}

/* На десктопе логотип слева */
@media (min-width: 721px) {
  .site-header .logo {
    position: static;
    transform: none;
  }
}

.burger {
  display: none;
  background: none;
  border: 0;
  width: 36px;
  height: 28px;
  padding: 0;
  margin-left: 8px;
  cursor: pointer;
}
.burger span {
  display: block;
  height: 3px;
  background: #45555f;
  margin: 6px 0;
  border-radius: 2px;
}

.mobile-menu {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 300;
}
.mobile-menu.open {
  opacity: 1;
  pointer-events: auto;
}
.mobile-menu-panel {
  position: absolute;
  top: 80px;
  left: 0;
  right: 0;
  background: #fff;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid #e5e7eb;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.mobile-menu-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: 0;
  font-size: 24px;
  line-height: 1;
  color: #45555f;
  cursor: pointer;
}
.mobile-menu-panel a {
  color: #45555f;
  text-decoration: none;
  font-weight: 500;
}
.logo-top {
  display: none !important;
}

@media (max-width: 1025px) {
  .nav-links {
    display: none;
  }
  .burger {
    display: inline-block;
  }
  .site-header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 8px;
    height: 48px !important;
  }
  /* Отступ под фиксированной шапкой (моб) */
  main {
    padding-top: 48px;
  }
  .site-header .logo {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
  .profile-icon {
    margin-left: auto;
  }
  .profile-icon,
  .cart-icon {
    display: flex;
    align-items: center;
  }
  .site-header .cart-icon {
    position: static !important;
    top: auto !important;
    right: auto !important;
    transform: none !important;
    margin-right: 10px;
  }
  .site-header .cart-icon .cart-badge.show {
    margin-right: 10px;
    margin-top: 6px;
  }
  .mobile-menu-panel {
    top: 48px;
  }
}

/* Анимация появления карточек */
.card {
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  opacity: 0;
  transform: translateY(20px) translateZ(0);
  display: flex;
  font-size: 16px;
  line-height: 1.3;
  overflow: hidden;
  contain: layout style paint;
  will-change: transform, opacity;
}

a.card.show {
  min-height: 400px;
}

.card:hover {
  position: relative;
  z-index: 100;
  transform: translateY(-4px) translateZ(0);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
  /* scale убран для производительности */
}

.card.show {
  opacity: 1;
  transform: translateY(0);
  animation: cardSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Анимация для элементов управления */
.catalog-controls {
  animation: fadeInDown 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Анимация для поиска и сортировки */
.search-container,
.sort-container,
.filter-container {
  animation: slideInRight 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Плавная анимация при фокусе */
.search-input:focus,
select:focus {
  animation: none;
}

/* Не поднимать при наведении на тач-устройствах */
@media (hover: none) {
  .card:hover {
    transform: none;
  }
}

/* ========== АДАПТИВ ========== */
@media (max-width: 1300px) {
  .catalog-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }

  .card {
    padding: 12px;
  }

  .card-name {
    font-size: 18px;
  }

  .card-price {
    font-size: 15px;
  }
}

@media (max-width: 1024px) {
  .catalog-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .catalog-header {
    font-size: 28px;
    margin-top: 24px;
  }

  .catalog-controls {
    padding: 0 12px;
    gap: 12px;
    top: 80px;
  }

  .catalog-filters button {
    padding: 6px 12px;
    font-size: 13px;
  }

  .search-input {
    min-width: 140px;
    max-width: 200px;
  }

  main {
    padding-top: 0px;
  }
}

@media (max-width: 768px) {
  .catalog-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 12px;
  }

  .catalog-controls {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    top: 80px;
  }

  .catalog-filters {
    flex: 1 1 100%;
    justify-content: center;
    overflow-x: auto;
    padding-bottom: 8px;
  }

  .controls-right {
    flex-direction: row;
    justify-content: center;
    gap: 8px;
  }

  .search-input {
    min-width: 120px;
    max-width: 180px;
  }
}

@media (max-width: 1025px) {
  .catalog-header {
    font-size: 24px;
    margin: 16px 0;
    padding: 0 16px;
  }

  .catalog-container {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 12px;
  }

  .catalog-controls {
    padding: 0 12px;
    margin-bottom: 20px;
    top: 88px;
  }

  .catalog-filters {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
  }

  .catalog-filters button {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 16px;
    white-space: nowrap;
  }

  .controls-right {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .search-input {
    width: 100%;
    min-width: auto;
    max-width: none;
  }

  .sort-wrapper {
    width: 100%;
  }

  .sort-select {
    width: 100%;
  }

  main {
    padding-top: 0px;
  }
}

@media (max-width: 480px) {
  .catalog-header {
    font-size: 20px;
    margin: 12px 0;
  }

  .catalog-container {
    padding: 8px;
    gap: 12px;
  }

  .catalog-controls {
    padding: 0 8px;
    top: 88px;
  }

  .catalog-filters {
    max-height: 100px;
  }

  .catalog-filters button {
    padding: 5px 8px;
    font-size: 11px;
  }
}
.add-category-btn {
  background-color: #28a745;
  color: #0f172a;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
}

.add-category-btn:hover {
  background-color: #218838;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal-panel {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 300px;
  max-width: 90%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-input {
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  width: 100%;
  font-size: 14px;
  margin-bottom: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.add-category-btn {
  background-color: #7fb314 !important;
  color: white;
}

.add-category-btn:hover {
  background-color: #6a9810 !important;
  color: rgb(206, 206, 206) !important;
}
.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f3f3f3;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
}

.category-item span {
  font-size: 14px;
}

.delete-btn {
  background: none;
  border: none;
  color: #e63946;
  font-weight: bold;
  cursor: pointer;
}
.delete-btn:hover {
  color: #d62828;
}

.btn-column {
  display: flex;
  flex-direction: column;
  gap: 4px; /* расстояние между кнопками */
}

.replace-btn {
  background: none;
  border: none;
  color: #3973e6;
  font-weight: bold;
  cursor: pointer;
}
.replace-btn:hover {
  color: #3060c0;
}

.dropzone {
  border: 2px dashed #bbb;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  margin-bottom: 10px;
  background: #fafafa;
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s;
}
.dropzone:hover {
  background: #f0f0f0;
  border-color: #888;
}

.error-input {
  border: 2px solid red !important;
}
.error-text {
  color: red;
  font-size: 13px;
  margin-top: 4px;
}

.delete-product-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 18px;
  line-height: 26px;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s;
}
.delete-product-btn:hover {
  background: rgba(220, 38, 38, 0.85); /* красный при наведении */
}
.card {
  position: relative; /* нужно для абсолютного позиционирования кнопки */
}

/* Кнопка редактирования товара */
.edit-product-btn {
  position: absolute;
  top: 6px;
  right: 36px; /* Немного слева от кнопки удаления */
  width: 28px;
  height: 28px;
  background-color: #4a90e2; /* цвет в стиле кнопок сайта */
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.2s;
  z-index: 2;
}

.edit-product-btn:hover {
  background-color: #357ab8;
  transform: scale(1.1);
}

/* dropzone + видео-превью */
.dropzone {
  border: 2px dashed #ddd;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  background: #fafafa;
}
.dropzone.dragover {
  background: #f0f8ff;
  border-color: #8ab4ff;
}
.video-preview {
  margin-top: 8px;
  display: block;
  width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
}
/* ========== МОДАЛКА ПРОФИЛЯ ========== */

.profile-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 2500;
}

.profile-modal {
  background: white;
  padding: 20px;
  border-radius: 12px;
  max-width: 600px;
}

.profile-form h2 {
  justify-content: center;
  display: flex;
}

.profile-tabs {
  display: flex;
  justify-content: space-around;
  margin-bottom: 20px;
}
.profile-tabs button {
  flex: 1;
  padding: 10px;
  background: #f3f3f3;
  border: none;
  cursor: pointer;
}
.profile-tabs button.active {
  background: #45555f;
  color: white;
  font-weight: bold;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.profile-form input {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
}
.profile-form button {
  padding: 12px;
  border: none;
  border-radius: 6px;
  background: #7fb314;
  color: white;
  font-weight: bold;
  cursor: pointer;
}
.profile-form button:hover {
  background-color: #6a9810;
  transform: scale(1.05);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}
.profile-form .msg {
  font-size: 14px;
  color: red;
  text-align: center;
  height: 5px;
  margin: 0px;
  margin-top: -15px;
}

@media (max-width: 480px) {
  .profile-modal {
    padding: 15px;
    max-width: 95%;
  }
  .profile-form input,
  .profile-form button {
    font-size: 14px;
  }
}

/* Стили профиля конец */

.cart-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #e63946;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border-radius: 50%;
  padding: 2px 6px;
  line-height: 1;
  min-width: 18px;
  text-align: center;
  display: none; /* скрыт по умолчанию */
  z-index: 10;
}

.cart-badge.show {
  display: inline-block;
}
