/* =========================================================================
   Telegram Mini App UI (html.tg-app) — лаконичный режим приложения
   в фирменной красно-графитовой палитре сайта (#e52323 / #313435 / #f4f6f8).
   НЕ влияет на обычный браузер (десктоп и мобильный).
   ========================================================================= */

#tg-topbar { display: none; }

html.tg-app {
  --tg-accent: #e52323;
  --tg-accent-dark: #c41818;
  --tg-accent-soft: #fdeaea;
  --tg-ink: #313435;
  --tg-muted: #76828f;
  --tg-line: #e4e9ee;
  --tg-bg: #f4f6f8;
  --tg-alert: #ce0e5a;
}

html.tg-app body {
  padding-top: 54px !important;
  padding-bottom: calc(var(--mnav-h, 58px) + env(safe-area-inset-bottom, 0px)) !important;
  background: var(--tg-bg) !important;
  color: var(--tg-ink);
}

/* Нижнее меню в цветах сайта */
html.tg-app #mnav {
  --mnav-accent: #e52323;
  --mnav-alert: #e52323;
  --mnav-ink: #313435;
  --mnav-muted: #76828f;
  --mnav-line: #e4e9ee;
}

/* Скрываем стандартную шапку OpenCart, подвал и плавающие виджеты */
html.tg-app #top,
html.tg-app header,
html.tg-app .menu-row,
html.tg-app #menu-mobile,
html.tg-app #info-mobile,
html.tg-app #oct-mobile-search-box,
html.tg-app #oct-menu-box,
html.tg-app .oct-m-search,
html.tg-app footer,
html.tg-app #uptocall-mini,
html.tg-app jdiv,
html.tg-app .jivo-btn,
html.tg-app #jivo-iframe-container,
html.tg-app [class^="jivo-"],
html.tg-app #back-top {
  display: none !important;
}

/* ── Верхняя App-шапка (бургер слева, логотип по центру, поиск справа) ── */
html.tg-app #tg-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1035;
  height: 54px;
  padding: 0 8px;
  background: #fff;
  border-bottom: 1px solid var(--tg-line);
}

html.tg-app .tg-top-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tg-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}
html.tg-app .tg-top-btn:active { background: var(--tg-bg); }
html.tg-app .tg-top-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html.tg-app .tg-top-title {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  flex: 1 1 auto;
  padding: 0 8px;
  text-decoration: none;
  font: 700 15px/1 "Open Sans", Arial, sans-serif;
  letter-spacing: .05em;
  color: var(--tg-ink);
  text-transform: uppercase;
}
html.tg-app .tg-top-logo {
  max-height: 32px;
  max-width: 170px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* ── Поиск выезжает СВЕРХУ ── */
html.tg-app .mnav-sheet--top {
  top: 0 !important;
  bottom: auto !important;
  max-height: 60vh;
  border-radius: 0 0 16px 16px !important;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: 12px !important;
  transform: translateY(-105%) !important;
}
html.tg-app .mnav-sheet--top.is-open {
  transform: none !important;
}
html.tg-app .mnav-search button {
  background: var(--tg-accent);
}
html.tg-app .mnav-link {
  color: var(--tg-accent);
}

/* ── Нижнее меню в TG: 4 главных пункта (Каталог и Поиск ушли наверх) ── */
html.tg-app #mnav [data-sheet="catalog"],
html.tg-app #mnav [data-sheet="search"] {
  display: none !important;
}

/* ── Штатный попап корзины (#cart-popup) в стиле Telegram-приложения ── */
html.tg-app .mfp-wrap { z-index: 10020 !important; }
html.tg-app .mfp-bg { z-index: 10019 !important; }
html.tg-app #cart-popup.white-popup {
  border-radius: 16px !important;
  padding: 16px 14px !important;
  max-width: 96vw !important;
  width: 100% !important;
  max-height: 85vh;
  overflow-y: auto;
  background: #fff !important;
}
html.tg-app #cart-popup .oct-carousel-header {
  font-size: 18px !important;
  font-weight: 700 !important;
  color: var(--tg-ink) !important;
  margin-bottom: 10px !important;
}
html.tg-app #cart-popup .oct-button {
  background: var(--tg-accent) !important;
  border-color: var(--tg-accent) !important;
  color: #fff !important;
  border-radius: 10px !important;
}

/* ── Попап-шторка Избранного ── */
html.tg-app .mnav-sheet-loading {
  padding: 28px 0;
  text-align: center;
  color: var(--tg-muted);
  font-size: 14px;
}
html.tg-app #mnav-wishlist-body .table-responsive { border: 0; margin: 0; }
html.tg-app #mnav-wishlist-body table { width: 100%; border-collapse: collapse; }
html.tg-app #mnav-wishlist-body thead { display: none; }
html.tg-app #mnav-wishlist-body tr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--tg-line);
}
html.tg-app #mnav-wishlist-body td {
  border: 0 !important;
  padding: 0 !important;
  text-align: left !important;
}
html.tg-app #mnav-wishlist-body td:first-child { width: 56px; flex: 0 0 56px; }
html.tg-app #mnav-wishlist-body td:first-child img { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; background: #f4f6f8; }
html.tg-app #mnav-wishlist-body td:nth-child(2) { flex: 1 1 140px; font-weight: 600; font-size: 13px; }
html.tg-app #mnav-wishlist-body td:nth-child(3),
html.tg-app #mnav-wishlist-body td:nth-child(4) { display: none; }
html.tg-app #mnav-wishlist-body td:nth-child(5) { font-weight: 700; color: var(--tg-ink); font-size: 14px; }
html.tg-app #mnav-wishlist-body td:last-child { margin-left: auto; display: flex; gap: 6px; }

/* ── Контейнеры и заголовки ── */
html.tg-app .container { padding-left: 10px; padding-right: 10px; }
html.tg-app .content-row { padding-left: 0; padding-right: 0; }
html.tg-app .breadcrumb-box { margin: 6px 0 8px; }
html.tg-app .breadcrumb {
  padding: 0;
  margin: 0;
  background: none;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  font-size: 12px;
}
html.tg-app .breadcrumb::-webkit-scrollbar { display: none; }
html.tg-app h1,
html.tg-app .cat-header {
  font-size: 19px !important;
  line-height: 1.25 !important;
  margin: 4px 0 10px !important;
  font-weight: 700 !important;
  color: var(--tg-ink);
}
html.tg-app #top_description,
html.tg-app .subcat-header { display: none !important; }

/* ── Главная страница: слайдер, категории, карусели ── */
html.tg-app .oct-slideshow-box {
  border-radius: 14px;
  overflow: hidden;
  margin: 6px 0 12px !important;
  box-shadow: 0 2px 8px rgba(49, 52, 53, .08);
}
html.tg-app .oct-slideshow-item-button {
  background: var(--tg-accent) !important;
  border-radius: 8px !important;
}
html.tg-app .oct-category-item-box {
  background: #fff;
  border: 1px solid var(--tg-line);
  border-radius: 12px;
  padding: 10px !important;
  margin-bottom: 10px !important;
}
html.tg-app .oct-category-item-header {
  font-size: 15px !important;
  font-weight: 700 !important;
  color: var(--tg-ink) !important;
}
html.tg-app .oct-carousel-box {
  margin: 10px 0 14px !important;
  padding: 0 !important;
  background: none !important;
  border: 0 !important;
}
html.tg-app .oct-carousel-header {
  font-size: 17px !important;
  font-weight: 700 !important;
  color: var(--tg-ink) !important;
  margin: 0 0 10px !important;
  padding: 0 !important;
}

/* ── Горизонтальные пилюли подкатегорий ── */
html.tg-app .subcats-row { margin: 0 -10px 10px; padding: 0 10px; }
html.tg-app #subcats {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  padding: 2px 0 6px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
html.tg-app #subcats::-webkit-scrollbar { display: none; }
html.tg-app #subcats .subcat-box {
  flex: 0 0 auto;
  width: auto !important;
  float: none !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  background: none !important;
}
html.tg-app #subcats .subcat-box a {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--tg-line);
  color: var(--tg-ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
html.tg-app #subcats .subcat-box a img { display: none !important; }
html.tg-app #subcats .subcat-box a span {
  display: inline;
  margin: 0;
  padding: 0;
  font-size: 13px;
  line-height: 1;
}

/* ── Кнопка фильтра и сортировка ── */
html.tg-app #oct-fs-fab { top: 64px; background: var(--tg-accent); }
html.tg-app .mobile-category-header #filter-button {
  border-radius: 10px !important;
  background: var(--tg-accent) !important;
  color: #fff !important;
  border: 0 !important;
  height: 40px;
  padding: 0 14px !important;
  font-size: 14px !important;
}
html.tg-app .sort-row {
  margin: 0 0 10px !important;
  padding: 0 !important;
  background: none !important;
  border: 0 !important;
}
html.tg-app .sort-row .left-sort-row {
  display: flex;
  gap: 8px;
  width: 100%;
  float: none !important;
}
html.tg-app .sort-row .input-sort-div { flex: 1 1 auto; margin: 0 !important; }
html.tg-app .sort-row .input-limit-div { display: none !important; }
html.tg-app .sort-row select {
  width: 100% !important;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--tg-line);
  background: #fff;
  font-size: 13px;
}

/* ── Чистая 2-колоночная сетка карточек товаров ── */
html.tg-app #res-products > .row {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px !important;
  margin: 0 !important;
}
html.tg-app #res-products > .row::before,
html.tg-app #res-products > .row::after { display: none !important; }
html.tg-app #res-products .product-layout {
  width: 100% !important;
  float: none !important;
  padding: 0 !important;
  margin: 0 !important;
}
html.tg-app .product-thumb {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  margin: 0 !important;
  padding: 8px !important;
  background: #fff !important;
  border: 1px solid var(--tg-line) !important;
  border-radius: 12px !important;
  box-shadow: 0 1px 3px rgba(49, 52, 53, .05) !important;
}
html.tg-app .product-thumb .image {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #f4f6f8;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px !important;
}
html.tg-app .product-thumb .image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
html.tg-app .product-thumb .quick-view,
html.tg-app .product-thumb .cat-model,
html.tg-app .product-thumb .rating,
html.tg-app .product-thumb hr,
html.tg-app .product-thumb .oct-product-stock,
html.tg-app .product-thumb .oct-additional-info,
html.tg-app .product-thumb .compare {
  display: none !important;
}

html.tg-app .product-thumb > div:last-child {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}
html.tg-app .product-thumb .caption {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 0 !important;
  margin: 0 !important;
}
html.tg-app .product-thumb .cat-box-effect,
html.tg-app .product-thumb .cat-box-effect-inner { display: contents !important; }

html.tg-app .product-thumb .price {
  order: 1;
  margin: 0 0 4px !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  color: var(--tg-ink) !important;
  line-height: 1.2 !important;
}
html.tg-app .product-thumb .price .price-new { color: var(--tg-alert); }
html.tg-app .product-thumb .price .price-old {
  font-size: 12px;
  font-weight: 400;
  color: var(--tg-muted);
  text-decoration: line-through;
  margin-left: 4px;
}
html.tg-app .product-thumb .caption .h4 {
  order: 2;
  margin: 0 0 8px !important;
  height: auto !important;
  min-height: 34px;
}
html.tg-app .product-thumb .caption .h4 a {
  font-size: 13px !important;
  line-height: 1.3 !important;
  font-weight: 500 !important;
  color: var(--tg-ink) !important;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
html.tg-app .product-thumb .cart {
  order: 3;
  margin-top: auto !important;
  display: block !important;
}
html.tg-app .product-thumb .cart .button-cart {
  width: 100% !important;
  height: 34px !important;
  padding: 0 8px !important;
  border-radius: 8px !important;
  background: var(--tg-accent) !important;
  color: #fff !important;
  border: 0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 13px !important;
  font-weight: 600 !important;
  text-decoration: none;
}
html.tg-app .product-thumb .cart .button-cart .hidden-xs { display: inline !important; }
html.tg-app .product-thumb .cart .button-cart.out-of-stock-button { background: #9aa5b0 !important; }

html.tg-app .product-thumb .cart .wishlist {
  position: absolute !important;
  top: 14px !important;
  right: 14px !important;
  z-index: 3;
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, .94) !important;
  color: var(--tg-ink) !important;
  border: 0 !important;
  box-shadow: 0 2px 6px rgba(49, 52, 53, .14) !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

/* ── Карточка товара (product.tpl) ── */
html.tg-app .product-info-box {
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--tg-line);
}
html.tg-app .product-info-box .thumbnails > li > a {
  border-radius: 10px;
  overflow: hidden;
  background: #f4f6f8;
  border: 0 !important;
}
html.tg-app #image-additional {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 0;
  scrollbar-width: none;
}
html.tg-app #image-additional::-webkit-scrollbar { display: none; }
html.tg-app .product-info-box .price {
  font-size: 22px !important;
  font-weight: 700;
  color: var(--tg-ink);
  margin: 8px 0 12px;
}
html.tg-app .product-info-box .price-old { font-size: 14px; color: var(--tg-muted); }
html.tg-app #product .button-compare { display: none !important; }
html.tg-app #product #button-cart {
  width: 100%;
  height: 46px;
  border-radius: 10px !important;
  background: var(--tg-accent) !important;
  border-color: var(--tg-accent) !important;
  color: #fff !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
html.tg-app #product #button-cart .hidden-sm { display: inline !important; }
html.tg-app #product .button-one-click {
  height: 42px;
  border-radius: 10px !important;
  background: var(--tg-accent-soft) !important;
  color: var(--tg-ink) !important;
  border: 1px solid var(--tg-accent) !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
html.tg-app #product .button-one-click .hidden-sm { display: inline !important; }
html.tg-app #product .button-wishlist {
  height: 42px;
  width: 46px;
  border-radius: 10px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}
html.tg-app .oct-product-tab .nav-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 6px;
  border: 0 !important;
  padding: 8px 0;
  scrollbar-width: none;
}
html.tg-app .oct-product-tab .nav-tabs::-webkit-scrollbar { display: none; }
html.tg-app .oct-product-tab .nav-tabs > li > a {
  border: 1px solid var(--tg-line) !important;
  border-radius: 18px !important;
  background: #fff !important;
  color: var(--tg-ink) !important;
  padding: 7px 14px !important;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
}
html.tg-app .oct-product-tab .nav-tabs > li.active > a {
  background: var(--tg-accent) !important;
  border-color: var(--tg-accent) !important;
  color: #fff !important;
}
html.tg-app .oct-product-tab .tab-content {
  background: #fff;
  border: 1px solid var(--tg-line);
  border-radius: 12px;
  padding: 12px;
}

/* ── Аккаунт / корзина / кнопки ── */
html.tg-app .account-content,
html.tg-app #content > .table-responsive {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--tg-line);
}
html.tg-app .oct-button,
html.tg-app .btn-primary {
  border-radius: 10px !important;
}
