/**
 * Bulbasoft Tuning Frontend Styles
 * Стили для фронтенда плагина Bulbasoft Tuning
 */

/* ===================================
   QUANTITY PRICE UPDATE
   Пересчет цены при изменении количества
   =================================== */

   .bsfttune-quantity-price-display {
	font-size: 14px;
	color: #555;
	margin-top: 0px !important;
	/* padding: 8px 12px !important; */
	/* background: #f8f9fa !important; */
	/* border: 1px solid #e9ecef !important; */
	/* border-radius: 4px !important; */
	font-weight: 500 !important;
	text-align: left;
	transition: all 0.3s ease !important;
	margin-bottom: 10px;
}

.bsfttune-quantity-price-display:hover {
    background: #e9ecef !important;
    border-color: #dee2e6 !important;
}

.bsfttune-attributes-table td {
	border-bottom: 1px solid #ddd;
	padding: 5px;
}

.bsfttune-attribute-name {
	font-weight: bold;
}

.bsfttune-attributes-table {
	margin: 10px 0px;
	font-size: 15px;
	width: 100%;
}

.bsfttune-attributes-more-link {
	margin-bottom: 15px;
}

.bsfttune-attributes-more-link a {
	color: #346ca8;
	text-decoration: underline;
	font-size: 15px;
}

/* Dark theme support for quantity price display */
@media (prefers-color-scheme: dark) {
    .bsfttune-quantity-price-display {
        background: #2c3e50 !important;
        border-color: #34495e !important;
        color: #ecf0f1 !important;
    }
    
    .bsfttune-quantity-price-display:hover {
        background: #34495e !important;
        border-color: #5d6d7e !important;
    }
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .bsfttune-quantity-price-display {
        font-size: 13px !important;
        padding: 6px 10px !important;
        margin-top: 8px !important;
    }
}

/* ===================================
   STOCK QUANTITY DISPLAY
   Отображение остатка товара
   =================================== */

.bsfttune-stock-quantity {
    display: inline-block;
}

.bsfttune-stock-available {
    /* Styles controlled via admin settings */
    display: inherit;
}

.bsfttune-stock-low {
    /* Styles controlled via admin settings */
    display: inherit;
}

.bsfttune-stock-out {
    /* Styles controlled via admin settings */
    display: inherit;
}

.bsfttune-stock-medium {
    /* Medium stock level status */
    display: inherit;
}

.bsfttune-stock-high {
    /* High stock level status */
    display: inherit;
}

.bsfttune_price_from, .bsfttune_price_to {
	color: #ccc;
}
/* ===================================
   WC CATEGORIES MENU (SIDEBAR)
   Дерево категорий WooCommerce с авто-раскрытием активной ветки
   =================================== */

.bsfttune_wc_cats {
	margin-bottom: 20px;
}

.bsfttune-wc-cats.level-0 {
	background: transparent;
	padding: 0;
	border-radius: 0;
	margin: 0;
	font-size: 15px;
}

.bsfttune_wc_cats .bsfttune-wc-cats.level-0 > li {
	background: #f8f8f8;
	padding: 10px;
	border-radius: 3px;
	margin: 10px 0;
}

/* CSS-only reveal next level for active branch */
.bsfttune_wc_cats .bsfttune-wc-cats { list-style: none; margin: 0; }
.bsfttune_wc_cats .bsfttune-wc-cats .bsfttune-wc-cats { display: none; }
.bsfttune_wc_cats .bsfttune-wc-cats > li { margin: 4px 0; }
.bsfttune_wc_cats .bsfttune-wc-cats li.active > .bsfttune-wc-cats,
.bsfttune_wc_cats .bsfttune-wc-cats li.active-ancestor > .bsfttune-wc-cats {
	display: block;
}

.bsfttune_wc_cats .bsfttune-wc-cats li.active > a { font-weight: 600; }
.bsfttune_wc_cats .bsfttune-wc-cats li.has-children > a { position: relative; }
.bsfttune_wc_cats a { color: #000; }

.bsfttune-wc-cats.level-1 {
	padding: 10px;
	border-radius: 3px;
	margin: 10px 0px;
}

.bsfttune_wc_cats_title {
	margin: 0;
	padding-bottom: 7px;
	font-size: 17px;
	font-weight: 600;
	color: #000;
	text-align: left;
}

/* ===================================
   CATEGORY DESCRIPTION TOGGLE
   Обрезка/раскрытие: .term-description (категории WC), .page-description (базовая /shop)
   =================================== */

.bsfttune-cat-desc-pending .term-description,
.bsfttune-cat-desc-pending .page-description,
.bsfttune-cat-desc-pending .bsftbrand-single-intro,
.bsfttune-cat-desc-pending .bsftbrand-archive-intro {
	visibility: hidden;
}

.bsfttune-cat-desc-pending .term-description.bsfttune-cat-desc-ready,
.bsfttune-cat-desc-pending .page-description.bsfttune-cat-desc-ready,
.bsfttune-cat-desc-pending .bsftbrand-single-intro.bsfttune-cat-desc-ready,
.bsfttune-cat-desc-pending .bsftbrand-archive-intro.bsfttune-cat-desc-ready {
	visibility: visible;
}

/* Описание с редактируемой страницы магазина WC (типичный класс темы — .page-description) */
body.woocommerce-shop .page-description {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	clear: both;
}

.bsfttune-cat-desc-excerpt {
	white-space: normal;
}

.bsfttune-cat-desc-excerpt-image {
	margin-bottom: 10px;
}

.bsfttune-cat-desc-excerpt-image img {
	max-width: 100%;
	height: auto;
	display: block;
}

.bsfttune-cat-desc-excerpt-text {
	white-space: normal;
}

.bsfttune-cat-desc-full[hidden] {
	display: none !important;
}

.bsfttune-cat-desc-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	width: 100%;
	margin-top: 12px;
	padding: 0;
	border: 0;
	background: transparent;
	color: #004f9f;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}

.bsfttune-cat-desc-toggle::before,
.bsfttune-cat-desc-toggle::after {
	content: '';
	flex: 1 1 auto;
	min-width: 28px;
	border-top: 1px dashed #b7c8df;
}

.bsfttune-cat-desc-toggle:hover {
	color: #003d7c;
}

.bsfttune-cat-desc-toggle:hover::before,
.bsfttune-cat-desc-toggle:hover::after,
.bsfttune-cat-desc-toggle:focus-visible::before,
.bsfttune-cat-desc-toggle:focus-visible::after {
	border-top-color: #86a9d3;
}

.bsfttune-cat-desc-toggle:focus-visible {
	outline: none;
	color: #003d7c;
}
/* ===================================
   VARIATIONS COUNT DISPLAY
   Отображение количества вариаций
   =================================== */

.bsfttune_variationscount_wrapper .bsfttune-variations-count {
    display: inline-block;
    font-size: 13px;
    color: #666;
    margin: 2px 0;
    padding: 2px 6px;
    background: #f5f5f5;
    border-radius: 3px;
    font-weight: normal;
    float: left;
}

/* ===================================
   CATALOG HEIGHT ALIGNMENT
   Выравнивание товаров каталога по высоте
   =================================== */

/* Основные стили для выравнивания списка товаров */
.products.bsfttune-catalog-height-align {
    display: flex;
    flex-wrap: wrap;
}

/* Стили для ссылок товаров при выравнивании по высоте */
.products.bsfttune-catalog-height-align .bsfttune_product_link {
    display: flex !important;
    flex-wrap: wrap;
    height: 100%;
    align-items: stretch;
    align-content: space-between;
    position: relative;
}

/* Force flex layout for tuned archive cards even if theme sets li a {display:block} */
.woocommerce ul.products li.product > a.bsfttune_product_link.flex_contain {
    display: flex !important;
    flex-wrap: wrap;
    align-items: stretch;
    align-content: flex-start;
    width: 100%;
}

/* ===================================
   TITLE POSITION ADJUSTMENTS
   Корректировки для позиции названия товара
   =================================== */

/* Когда название размещено над изображением */
.woocommerce ul.products li.product .woocommerce-loop-product__title {
    margin-bottom: 0.5em;
}

/* Убираем лишние отступы, если название сверху */
.woocommerce ul.products li.product h2.woocommerce-loop-product__title {
    margin-top: 0;
}

/* ===================================
   IMAGE WRAPPER
   Контейнер для изображений товаров
   =================================== */

/* Основные стили для контейнера изображений */
.bsfttune-img-wrap {
    height: var(--bsfttune-img-height-desktop, 250px);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    margin-bottom: 5px;
}

.bsfttune-img-wrap img {
    max-height: var(--bsfttune-img-height-desktop, 250px);
    max-width: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
}

/* Tablet styles (768px and below) */
@media (max-width: 768px) {
    .bsfttune-img-wrap {
        height: var(--bsfttune-img-height-tablet, 200px);
    }
    
    .bsfttune-img-wrap img {
        max-height: var(--bsfttune-img-height-tablet, 200px);
    }
}

/* Mobile styles (480px and below) */
@media (max-width: 480px) {
    .bsfttune-img-wrap {
        height: var(--bsfttune-img-height-mobile, 150px);
    }
    
    .bsfttune-img-wrap img {
        max-height: var(--bsfttune-img-height-mobile, 150px);
    }
}

/* ===================================
   AVAILABILITY STATUS DISPLAY
   Отображение статуса наличия товара
   =================================== */

.bsfttune-availability-status {
    display: inline-block;
}

.bsfttune-availability-instock {
    background: #28a745;
    color: white;
}

.bsfttune-availability-outofstock {
    background: #dc3545;
    color: white;
}

.bsfttune-availability-backorder {
    background: #ffc107;
    color: #212529;
}

/* Custom availability statuses */
.bsfttune-availability-preorder {
    background: #6f42c1;
    color: white;
}

.bsfttune-availability-custom {
    background: #6c757d;
    color: white;
}

/* ===================================
   RATING DISPLAY
   Отображение рейтинга товара
   =================================== */

.bsfttune-rating-wrapper {
    margin: 5px 0;
    font-size: 14px;
}

.bsfttune-rating-wrapper .star-rating {
    margin: 0 auto;
    font-size: 12px;
    float:right !important;
}

.bsfttune-rating-wrapper .star-rating:before {
    color: #ddd;
}

.bsfttune-rating-wrapper .star-rating span:before {
    color: #ffc107;
}

/* ===================================
   CART FORM INSIDE LINK
   Форма корзины внутри ссылки товара
   =================================== */

.bsfttune-cart-form {
    display: inline-block;
    margin: 0;
    padding: 0;
    width: 100%;
}

.bsfttune-cart-form button {
    /* Reset form button styles and inherit WooCommerce button styles */
    margin: 0;
    font: inherit;
    cursor: pointer;
    outline: inherit;
    
    /* Let WooCommerce button classes handle the styling */
    display: inline-block;
    text-decoration: none;
    border: 1px solid;
    border-radius: 3px;
    padding: 0.6180469716em 1.41575em;
    text-align: center;
    word-break: break-word;
    color: #515151;
    background-color: transparent;
    border-color: #515151;
    transition: all 0.2s;
}

.bsfttune-cart-form button:hover {
    background-color: #515151;
    color: #fff;
    border-color: #515151;
}

/* Apply WooCommerce theme colors if available */
.bsfttune-cart-form button.add_to_cart_button {
    background-color: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.bsfttune-cart-form button.add_to_cart_button:hover {
    background-color: #005a87;
    border-color: #005a87;
}

.bsftoclick-wrapper button {
	margin: 0 !important;
}

.bsfttune-img-wrap img {
	margin: 0 !important;
}

.bsfttune-primary {
	width: 100% !important;
	flex: 0 0 100% !important;
}

.bsfttune-custom-image {
	width: 100% !important;
}

.bsfttune_card_block {
	position: relative;
}

/* ===================================
   CUSTOM PRODUCT CARD LAYOUT
   Flex grid utilities scoped to card
   =================================== */
.bsfttune_card_wrap.flex_contain {
	display: flex;
	flex-wrap: wrap;
	width: 100%;
}

.bsfttune_card_wrap .flex_limit.product {
	display: flex;
	flex-wrap: wrap;
	width: 100%;
	align-items: flex-start;
}

.bsfttune_card_wrap .flex_block {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
}

.bsfttune_card_wrap .bsfttune_card_block {
	flex: 0 0 var(--bsfttune-wf, 100%);
	max-width: var(--bsfttune-wf, 100%);
	padding: var(--bsfttune-padding-top-desktop, 0px) var(--bsfttune-padding-right-desktop, 0px) var(--bsfttune-padding-bottom-desktop, 0px) var(--bsfttune-padding-left-desktop, 0px);
}

@media (max-width: 1024px) {
	.bsfttune_card_wrap .bsfttune_card_block {
		flex-basis: var(--bsfttune-tf, 100%);
		max-width: var(--bsfttune-tf, 100%);
	}
}

@media (max-width: 768px) {
	.bsfttune_card_wrap .bsfttune_card_block {
		flex-basis: var(--bsfttune-mf, 100%);
		max-width: var(--bsfttune-mf, 100%);
		padding: var(--bsfttune-padding-top-mobile, var(--bsfttune-padding-top-desktop, 0px)) var(--bsfttune-padding-right-mobile, var(--bsfttune-padding-right-desktop, 0px)) var(--bsfttune-padding-bottom-mobile, var(--bsfttune-padding-bottom-desktop, 0px)) var(--bsfttune-padding-left-mobile, var(--bsfttune-padding-left-desktop, 0px));
	}
}

.bsfttune_card_wrap .bsfttune-wrapper-container {
    display: block;
    margin: 4px 0;
}

.bsfttune-wrapper-container.wfit {
	display: inline-flex;
	flex-wrap: wrap;
	width: max-content;
	max-width: 100%;
}

.bsfttune-wrapper-inner {
    display: flex;
    flex-wrap: wrap;
	align-items: center;
}

.bsfttune_card_wrap .bsfttune_card_item {
	width: 100%;
	box-sizing: border-box;
}

.bsfttune_card_wrap .flex_row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
}

.bsfttune_card_wrap .jc_c { justify-content: center; }
.bsfttune_card_wrap .ai_c { align-items: center; }
.bsfttune_card_wrap .g7 { gap: 7px; }

.bsfttune-description-link-wrap a {
	background: none !important;
	padding: 0 !important;
	color: #20368c !important;
	text-decoration: underline !important;
	margin-bottom: 40px !important;
	font-size: 15px !important;
	font-weight: normal !important;
}

/* ===================================
   STICKY IMAGES (CUSTOM PRODUCT CARD)
   Фиксация блока изображений при скролле
   =================================== */

body.bsfttune-pcard-images-sticky .bsfttune_card_wrap .bsfttune_card_item_images {
	position: sticky;
	top: var(--bsfttune-pcard-images-sticky-top, 20px);
	/* ВАЖНО: когда родитель становится flex-column, flex-start может "сжать" ширину.
	   Нам нужна 100% ширина без деформации галереи. */
	align-self: stretch;
	z-index: 20;
	width: 100%;
	max-width: 100%;
}

/*
  Ключевой момент для правильной "остановки по низу":
  sticky ограничивается высотой своего контейнера. Нам нужно, чтобы колонка с изображениями
  растягивалась по высоте до самой высокой колонки внутри карточки (т.е. до низа bsfttune_card_wrap).
*/
body.bsfttune-pcard-images-sticky .bsfttune_card_wrap .flex_limit.product {
	align-items: stretch !important;
	/* не трогаем overflow, чтобы не ломать галерею/зум */
}

body.bsfttune-pcard-images-sticky .bsfttune_card_wrap .bsfttune_card_block {
	/* Это и было ключом к корректной остановке по НИЗУ:
	   sticky ограничивается высотой своего контейнера, поэтому делаем колонку стабильной. */
	align-self: stretch;
	display: flex;
	flex-direction: column;
	/* не трогаем overflow на родителях галереи, но самой колонке разрешаем visible */
	overflow: visible;
}