/* ═══════════════════════════════════════════════════════════════
   M18 (v2): компактная страница ПК в стиле jimms.fi, плоский стиль
   оригинальной темы: без панелей и обводок, свои кнопки-свотчи.
   ═══════════════════════════════════════════════════════════════ */

/* ── Сетка: галерея + покупка ── */
.tgp.product__content { padding-top: 14px !important; }
.tgp .tgp-grid {
  display: grid;
  grid-template-columns: minmax(400px, 540px) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
.tgp .product { margin-top: 10px; }

/* ── Галерея: крупный фото-блок ── */
.tgp .tgp-gallery { position: sticky; top: 90px; }
/* резерв высоты фото-области с первого кадра: flexslider инициализируется
   позже и своими inline-высотами двигал страницу (~0.5с после загрузки) */
@media (min-width: 1101px) {
  .tgp .woocommerce-product-gallery__wrapper { min-height: 540px; }
}
.tgp .woocommerce-product-gallery {
  opacity: 1 !important;
  transition: none;
}
.tgp .woocommerce-product-gallery__wrapper { margin: 0; }
.tgp .woocommerce-product-gallery__image img {
  max-height: 540px;
  width: auto;
  margin: 0 auto;
}
.tgp .flex-control-thumbs,
.tgp .woocommerce-product-gallery .flex-control-nav {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.tgp .flex-control-thumbs li,
.tgp .flex-control-nav li {
  flex: 0 0 70px;
  width: 70px;
  max-width: 70px;
  height: 70px;
  margin: 0;
  background: #2d2d2d;
  border: 1px solid transparent;
  border-radius: 0;
  overflow: hidden;
}
.tgp .flex-control-thumbs li img,
.tgp .flex-control-nav li img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  opacity: 1;
}
.tgp .flex-control-thumbs li.flex-active,
.tgp .flex-control-nav li.flex-active { border-color: #00f049; }
.tgp .woocommerce-product-gallery__trigger { display: none; }

/* ── Заголовок и наличие ── */
.tgp .tgp-head { min-width: 0; }
.tgp .product_title {
  font-size: 24px;
  line-height: 1.2;
  margin: 0 0 6px;
}
.tgp-stock {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: "Leto Sans", sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.tgp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: 0 0 auto;
}
/* в наличии — физический сток на вариациях */
.tgp-stock--in { color: #2dff7e; }
.tgp-stock--in .tgp-dot { background: #2dff7e; }
/* под заказ — собираем после заказа */
.tgp-stock--order { color: #ffb020; }
.tgp-stock--order .tgp-dot { background: #ffb020; }
/* нет в наличии */
.tgp-stock--out { color: #ff6b6b; }
.tgp-stock--out .tgp-dot { background: #ff6b6b; }

/* ── Конфигуратор: свои кнопки-свотчи, компактно ── */
.tgp .tgp-config { min-width: 0; }
.tgp table.variations {
  border-collapse: collapse;
  width: 100%;
  margin: 6px 0 0;
}
.tgp table.variations tbody { display: block; }
.tgp table.variations tr { display: block; }
.tgp table.variations th.label {
  display: block;
  padding: 9px 0 5px;
  border: none;
  text-align: left;
  font-family: "Leto Sans", sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.6);
}
.tgp table.variations th.label label { color: inherit; }
.tgp table.variations td.value {
  display: block;
  padding: 0 0 7px !important;
  margin: 0 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
/* у последней группы разделитель не нужен — его несёт строка бейджа */
.tgp table.variations tr:last-child td.value { border-bottom: none; }
.tgp table.variations tbody tr:first-child th.label { padding-top: 0; }

/* компактные кнопки-свотчи woo-variation-swatches */
.tgp ul.variable-items-wrapper {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 !important;
  padding: 0 !important;
}
.tgp ul.variable-items-wrapper li.button-variable-item {
  display: flex;
  align-items: center;
  margin: 0 !important;
  padding: 0 !important;
  min-height: 34px !important;
  height: auto !important;
  background: #242424 !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  overflow: hidden;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.tgp ul.variable-items-wrapper li.button-variable-item:hover {
  border-color: rgba(0, 240, 73, 0.55) !important;
}
.tgp ul.variable-items-wrapper li.button-variable-item.selected {
  background: rgba(0, 240, 73, 0.1) !important;
  border-color: #00f049 !important;
}
.tgp .variable-item-span-button {
  display: block !important;
  padding: 7px 13px !important;
  font-family: "Leto Sans", sans-serif;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
  color: rgba(255, 255, 255, 0.85) !important;
  white-space: nowrap;
}
.tgp li.button-variable-item.selected .variable-item-span-button {
  color: #fff !important;
}
.tgp .reset_variations {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  text-decoration: underline;
}
.tgp .reset_variations:hover { color: #fff; }

/* ── Цена (JS переносит её к кнопке) ── */
.tgp-price-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 4px 0 0;
  margin: 0;
}
.tgp-price { display: inline-flex; align-items: baseline; }
.tgp-price-num {
  font-size: 38px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1;
}
.tgp-price-cur {
  font-size: 22px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  margin-left: 3px;
}
.tgp-price-old {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.4);
  text-decoration: line-through;
  margin-right: 10px;
  align-self: center;
}
.tgp-vat {
  font-family: "Leto Sans", sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
}

/* ESTO — строкой под ценой, без обводки, в общем стиле.
   Селектор тег-агностичный: плагин при AJAX-перерисовке может
   заменить <p> на другой тег с тем же классом. */
.tgp .tgp-price-row .esto-calculator,
.tgp .esto-calculator {
  flex-basis: 100%;
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin: 5px 0 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  font-family: "Leto Sans", sans-serif !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  line-height: 1.4 !important;
  color: rgba(255, 255, 255, 0.6) !important;
}
.tgp .esto-calculator__logo {
  height: 22px !important;
  margin: 0 !important;
  opacity: 1;
  flex: 0 0 auto;
}

/* ── Порядок блоков внутри формы покупки ──
   M19: группа собирается на сервере прямо в нужном порядке
   (конфигуратор → бейдж наличия → доставка → цена + ESTO → кнопка),
   CSS order дублирует это на случай иных DOM-позиций хуков. */
.tgp .tgp-config form.cart { display: block; order: 1; }
.tgp .tgp-config .variations_form.cart > div {
  display: flex;
  flex-direction: column;
}
.tgp .variations_form.cart > div > table.variations { order: 1; }
.tgp .variations_form.cart > div > .single__upps { order: 2; }
.tgp .variations_form.cart > div > .tgp-stock-row { order: 3; }
.tgp .variations_form.cart > div > .tg-tarneaeg { order: 4; }
.tgp .variations_form.cart > div > .tgp-price-row { order: 5; }
.tgp .variations_form.cart > div > .single_variation_wrap { order: 6; }
/* запасной путь: если ESTO не вырезался из вывода хука */
.tgp .tgp-config > .esto-calculator { order: 99; }
/* пустой YITH-контейнер скрыт с первого кадра (раньше прятал JS на ready —
   страница дёргалась на его высоту ~49px через полсекунды);
   :has внутри :not валиден, вложенный :has внутри :has — нет */
.tgp #yith-wapo-container:not(:has(.yith-wapo-group)) {
  display: none;
}

/* строка бейджа наличия — верх группы, несёт разделитель */
.tgp .tgp-stock-row {
  display: flex;
  align-items: center;
  margin: 10px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

/* дубль цены внутри single_variation прячем — цена над кнопкой */
.tgp .single_variation { display: none !important; }
.tgp .single_variation_wrap.flex {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  border-bottom: none;
}

/* ── CTA ── */
.tgp .woocommerce-variation-add-to-cart.variations_button {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.tgp .single_add_to_cart_button {
  flex: 1 1 auto;
  width: auto;
  min-height: 50px;
  font-family: "Leto Sans", sans-serif !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  padding: 14px 24px;
  border-radius: 0;
}

/* ── Срок доставки: строка с иконкой под бейджем, над ценой ── */
.tgp .tg-tarneaeg {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 2px;
  padding: 0;
  background: transparent;
  border: none;
  font-family: "Leto Sans", sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
}
.tgp .tg-tarneaeg svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: #00f049;
}

/* ── Табы ниже: отделяем от блока покупки ── */
.tgp .woocommerce-tabs {
  margin-top: 56px;
  padding-bottom: 48px;
}

/* ── Адаптив ── */
@media (max-width: 1100px) {
  .tgp .tgp-grid { grid-template-columns: minmax(0, 1fr); }
  .tgp .tgp-gallery { position: static; max-width: 540px; margin: 0 auto; }
  /* flexslider ставит inline-ширину по скрытому состоянию — режем */
  .tgp .woocommerce-product-gallery,
  .tgp .flex-viewport,
  .tgp .woocommerce-product-gallery__wrapper {
    width: 100% !important;
    max-width: 100% !important;
  }
}
@media (max-width: 640px) {
  .tgp .product_title { font-size: 20px; }
  .tgp-price-num { font-size: 30px; }
  .tgp .woocommerce-product-gallery__image img { max-height: 340px; }
  .tgp .variable-item-span-button { font-size: 12px !important; padding: 6px 11px !important; }
  /* длинные названия комплектующих переносятся, а не растягивают экран */
  .tgp .variable-item-span-button { white-space: normal !important; }
  .tgp ul.variable-items-wrapper li.button-variable-item { max-width: 100%; }
}
