/* ================== БАЗА ================== */
:root{
  --sidebar-w: 240px;
  --nav-h: 52px;
}

html { font-size: 16px; }

body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background: #f4f4f8;
  color: #333;
  overflow-x: hidden;
  font-size: clamp(0.9rem, 1vw + 0.5rem, 1rem);
}

p { margin: 5px 0; }
a { color: inherit; text-decoration: none; }

/* ================== FOOTER ================== */
footer {
  background-color: rgb(36, 36, 36);
  color: rgb(255, 255, 255);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  z-index: 999;
  position: relative;
}

.footer-container {
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.footer-left, .footer-middle, .footer-right {
  width: 30%;
}

.footer-left img {
  width: 375px;
  height: auto;
}

.footer-middle { display: flex; flex-direction: column; }
.footer-right  { display: flex; flex-direction: column; }

.input-name, .input-phone {
  margin-top: 10px;
  padding: 10px;
  width: 95%;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.submit-button {
  margin-top: 10px;
  padding: 10px;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.social-icons a { margin-right: 10px; text-decoration: none; }
.social-icons img { width: 30px; height: auto; cursor: pointer; }

.success-popup {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: #4CAF50; color: white;
  padding: 20px 30px; border-radius: 10px;
  box-shadow: 0 0 20px rgba(0,0,0,0.3);
  z-index: 9999; opacity: 0; transition: all 0.4s ease;
  text-align: center;
}
.success-popup .checkmark { font-size: 2.5em; display:block; margin-bottom:10px; animation: pop 0.5s ease; }
@keyframes pop { 0%{transform:scale(0)} 60%{transform:scale(1.2)} 100%{transform:scale(1)} }
.success-popup.show { opacity:1; transform: translate(-50%, -50%) scale(1); }
.success-popup.hidden { display:none; }

/* ================== NAVBAR ================== */
.main-navbar {
  position: sticky; top: 0; z-index: 999;
  background-color: #1f1f1f;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  opacity: 0; transform: translateX(-30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.main-navbar.animate { opacity: 1; transform: translateX(0); }

.burger-wrapper { display: none; align-items: center; cursor: pointer; gap: 8px; padding: 0.75rem 1rem; }
.burger { display: flex; flex-direction: column; gap: 5px; }
.burger span { width: 22px; height: 3px; background: #e0ffe3; border-radius: 2px; }
.burger-label { color: #e0ffe3; font-size: 1rem; }

.nav-links {
  display: flex; justify-content: center; padding: 14px 0; margin: 0;
  list-style: none; gap: 40px; flex-wrap: wrap;
}
.nav-links a {
  color: #e0ffe3; font-size: 1.1rem; font-weight: 500; position: relative; transition: color .3s ease;
}
.nav-links a::after {
  content: ""; position: absolute; width: 0%; height: 2px; bottom: -4px; left: 0; background-color: #00ff94; transition: width .3s ease;
}
.nav-links a:hover { color: #00ff94; }
.nav-links a:hover::after { width: 100%; }

/* ================== STICKY SEARCH ================== */
.sticky-search {
  position: sticky; top: var(--nav-h); z-index: 10;
  background: #f4f4f8; padding: 10px 0; margin-bottom: 1rem;
}
.search-cart {
  display: flex; justify-content: space-between; max-width: 570px; margin: auto; align-items: center;
  flex-wrap: wrap; gap: .5rem; position: relative;
}
.search-cart input {
  padding: .6rem; border-radius: 8px; background-color: #333; color: chartreuse; border: none;
  flex: 1; font-size: clamp(.85rem, 1vw + .5rem, 1rem);
}
.clear-icon {
  position: absolute; right: 4.5rem; top: 50%; transform: translateY(-50%);
  cursor: pointer; font-size: 1.5rem; color: chartreuse; display: none; user-select: none;
}
.cart-icon { font-size: 1.5rem; position: relative; cursor: pointer; }
.cart-icon span {
  position: absolute; top: -10px; right: -10px; background: rgb(43, 220, 20); color: #fff;
  border-radius: 50%; font-size: .8rem; padding: 2px 6px;
}

/* ================== КАТАЛОГ: КОНТЕЙНЕРЫ ================== */
.catalog-container {
  display: flex; align-items: flex-start; transition: all .3s ease;
}
.catalog-content {
  flex: 1; display: flex; flex-direction: column; transition: all .3s ease;
}

/* ================== САЙДБАР ================== */
.sidebar {
  position: sticky; z-index: 2; top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto; width: var(--sidebar-w);
  background-color: #181818; border-right: 1px solid #2f2f2f;
  padding: 1rem; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  scrollbar-width: none; transition: width .3s ease, padding .3s ease;
}
.sidebar::-webkit-scrollbar { width: 0; height: 0; }

.sidebar.collapsed { width: 0; overflow: hidden; padding: 0; }

/* Кнопка переключения бокового меню */
.toggle-sidebar-btn {
  position: fixed;
  top: 22rem; /* чтобы не перекрывала поиск */
  left: calc(var(--sidebar-w) + 1.8rem);
  background-color: #181818; color: #fff; border: none; cursor: pointer;
  padding: 10px 14px; border-top-right-radius: 10px; border-bottom-right-radius: 10px;
  transition: left .3s ease, transform .3s ease, background-color .3s ease;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; width: 24px; height: 60px; font-size: 20px;
}
.sidebar.collapsed ~ .toggle-sidebar-btn { left: .5rem; }
.toggle-sidebar-btn i { transition: transform .3s ease; }
/* Поворачиваем стрелку при свёрнутом сайдбаре */
.sidebar.collapsed ~ .toggle-sidebar-btn i { transform: rotate(180deg); }

/* ================== КАТЕГОРИИ ================== */
.category-tabs { display: flex; justify-content: space-between; margin-bottom: 1rem; gap: .5rem; }
.category-tabs .tab {
  flex: 1; margin: 0; padding: .6rem; background-color: #2a2a2a; border: none; border-radius: 8px;
  color: #ccc; font-weight: 600; cursor: pointer; transition: background-color .3s, color .3s;
}
.category-tabs .tab.active { background-color: #4caf50; color: #fff; }

/* Подкатегории */
#subcategories { display: flex; flex-direction: column; gap: .5rem; padding-bottom: 30px; }
#subcategories button {
  display: flex; align-items: center; gap: 10px; background: none; border: none; color: #fff;
  font-size: 14px; padding: 8px 12px; cursor: pointer; width: 100%; text-align: left; transition: background .2s ease;
}
#subcategories button:hover, #subcategories button.active { background-color: #4caf50; color: #fff; }
#subcategories .cat-icon { width: 20px; height: 20px; object-fit: contain; }

/* ================== СЕТКА ТОВАРОВ ================== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  padding: 0 20px 30px;
}

/* ================== КАРТОЧКИ (замени свой блок этим) ================== */
.product-card {
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;         /* карточка растягивается по ширине родителя */
  min-height: 360px;            /* единая высота карточки (подкорректируй при необходимости) */
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  overflow: hidden;
  transition: transform .3s;
}

/* hover */
.product-card:hover { transform: translateY(-5px); }

/* Флип-обёртка: занимает всю высоту карточки */
.card-flip-wrapper {
  perspective: 1000px;
  width: 100%;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
}

/* Inner — хранит оба слоя (front/back) и делает флип */
.card-flip-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform .6s;
  transform-style: preserve-3d;
}

/* При добавлении .flipped на .card-flip-wrapper делать rotate */
.card-flip-wrapper.flipped .card-flip-inner {
  transform: rotateY(180deg);
}

/* Слой фронт/бек: располагаются поверх друг друга (grid или absolute).
   Важно: оба слоя занимают всю площадь и одинаковую структуру (img + info + footer) */
.card-front,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between; /* ключ: распределяем зоны, чтобы кнопка была внизу */
  backface-visibility: hidden;
  background: #fff;
  box-sizing: border-box;
  padding: 0; /* внутренние отступы задаём в конкретных зонах */
}

/* обратная сторона повёрнута */
.card-back { transform: rotateY(180deg); }

/* ========== Изображение ========== */
.card-front img,
.card-back img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

/* ========== Информационная зона ========== */
/* .info — зона между картинкой и футером; она должна занимать доступное место */
.card-front .info,
.card-back .info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: .6rem;
  width: 100%;
  box-sizing: border-box;
  flex: 1; /* расширяется, чтобы оттеснить кнопку вниз */
  text-align: center;
}

/* Заголовок */
.card-front h3,
.card-back h3 {
  font-size: clamp(1rem, 1vw + .6rem, 1.1rem);
  margin: 0;
  min-height: 48px;         /* фиксированная зона под название */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 .4rem;
}

/* Цена / дополнительная строка */
.card-front p,
.card-back p {
  margin: 0;
  font-weight: bold;
  color: #28a745;
  min-height: 24px;         /* фиксированная высота для выравнивания */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 .4rem;
}

/* ========== Блок доп.кнопок (зарезервированное место) ========== */
/* Этот блок должен присутствовать в HTML каждой карточки (можно пустым).
   min-height нужно подобрать под максимальное количество кнопок. */
/* ========== Блок доп.кнопок (зарезервированное место) ========== */
.extra-buttons {
  display: flex;
  gap: .3rem;               /* чуть меньше промежутки */
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  min-height: 32px;         /* уменьшил высоту (было 44px) */
  width: 100%;
  box-sizing: border-box;
  padding: 0 .4rem;
}

/* Кнопки "Подробнее" и "Закрыть" */
.flip-btn {
  padding: .15rem .45rem;   /* компактнее */
  font-size: .6rem;         /* чуть меньше размер шрифта */
  background: transparent;
  color: #28a745;
  border: 1px solid #28a745;
  border-radius: 5px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.flip-btn-close{
  padding:.05rem;   /* компактнее */
  font-size: .8rem;         /* чуть меньше размер шрифта */
  margin-top: 15px;
  margin-right: 75%;
  background: transparent;
  color: #28a745;
  border: 1px solid #28a745;
  border-radius: 5px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}

.flip-btn:hover,
.flip-btn-close:hover {
  background: #28a745;
  color: #fff;
}

/* ========== Футер: кнопка Купить ========== */
/* Чтобы кнопка всегда была внизу — она располагается в footer-зоне, вне .info, */
.card-footer {
  width: 100%;
  box-sizing: border-box;
  padding: .6rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .5rem;
}

/* сама кнопка */
.buy-btn {
  padding: .55rem 1rem;
  background: #28a745;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .2s;
  font-size: 1rem;
  width: 100%;
  max-width: 200px;
}
.buy-btn:hover { background: #218838; }

/* ========== Небольшие правки адаптива и box-sizing ========== */
.product-card *, .product-card *::before, .product-card *::after { box-sizing: inherit; }


/* ================== ПОЛНОЭКРАННОЕ ИЗОБРАЖЕНИЕ ================== */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  overflow: hidden; /* чтобы не было прокрутки */
}

.fullscreen-content img {
  max-width: 90vw;   /* не шире экрана */
  max-height: 90vh;  /* не выше экрана */
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
}

.close-fullscreen {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 3rem;
  color: #ffffff;
  cursor: pointer;
  z-index: 10000;
}

.close-fullscreen:hover {
  color: #28a745;
}

/* ================== МЕДИАЗАПРОСЫ ================== */

/* Планшеты (сайдбар остаётся слева, контент адаптируется) */
@media (max-width: 1024px) {
  .nav-links { gap: 1rem; }
  .footer-left img { max-width: 100%; height: auto; }
}

/* Телефоны */
@media (max-width: 768px) {
  /* бургер-меню */
  .burger-wrapper { display: flex; }
  .nav-links { display: none; width: 90%; }
  .nav-links.active {
    display: flex !important; flex-direction: column; align-items: center; gap: 1rem;
    background: #1f1f1f; padding: 1rem;
  }

  /* поиск */
  .sticky-search {
    top: calc(var(--nav-h) - 9px); /* ровно под навбаром */
  }
  .search-cart { padding: 0 1rem; max-width: 100%; }
  .search-cart input { width: 100%; }
  .clear-icon { right: 3rem; }

  /* сетка товаров — ровно 2 колонки */
  .product-grid { grid-template-columns: repeat(2, 1fr); }

  /* кнопка сайдбара — прижимаем к левому краю */
  .toggle-sidebar-btn { top: 50%; bottom: 1rem; left: 0.5rem; }

  /* футер — как просил */
  .footer-container { flex-direction: column; }
  form#call-back-form { order: 1; }
  .footer-middle { order: 2; }
  .footer-left { order: 3; text-align: left; }
  .footer-left, .footer-middle, form#call-back-form { width: 100%; margin-bottom: 20px; }
  .footer-left img { max-width: 200px; display: block; margin: 0; }

  /* чтобы оверлей фото был шире на мобилке */
    .fullscreen-content img {
    max-width: 90%;
    display: block;
    margin: 0 auto;
  }
}
/* ================== МАЛЕНЬКИЕ ЭКРАНЫ: Сайдбар открытый ================== */
@media (max-width: 768px) {
  /* если сайдбар открыт — 1 колонка */
  .sidebar:not(.collapsed) ~ .catalog-content .product-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  :root {
    --sidebar-w: 180px; /* уже сайдбар на мобилке */
  }

  .sidebar {
    width: var(--sidebar-w);
    top: calc(var(--nav-h) - 9px); /* чуть выше, чтобы убрать зазор */
  }

  /* кнопка при открытом сайдбаре */
  .toggle-sidebar-btn {
    left: calc(var(--sidebar-w) + 1.8rem);
    top: 50%;
    transform: translateY(-50%);
  }

  /* кнопка при свёрнутом сайдбаре */
  .sidebar.collapsed ~ .toggle-sidebar-btn {
    left: 0.5rem;
    transform: translateY(-50%) rotate(180deg);
  }
}

/* ====== МЕТКА КАТЕГОРИИ НА КАРТОЧКЕ ====== */
.card-front {
  position: relative; /* теперь метка позиционируется относительно фронта */
}

.product-label {
  position: absolute;
  top: 8px;
  left: 8px;
  background-color: #28a745;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  z-index: 5;
  pointer-events: none;
}

/* ====== Адаптивность метки ====== */
@media (max-width: 768px) {
  .product-label {
    font-size: 0.6rem;
    top: 6px;
    left: 6px;
    padding: 1px 4px;
  }
}


