/**
 * Каталог товарів — повні стилі
 * Файл: your-theme/assets/css/catalog-card.css
 *
 * Виправлення:
 *  1. Кнопка кошика — власні стилі, скидання всіх Astra/WooCommerce
 *  2. Ховер — позиціонується всередині картки, не виїжджає
 *  3. Бічна панель (sidebar) — сітка з фільтром зліва
 */

/* ══════════════════════════════════════════════════════════════
   СІТКА: SIDEBAR (фільтр) + ПРОДУКТИ
══════════════════════════════════════════════════════════════ */

/* Astra використовує .ast-container або стандартний .woocommerce.
   Нижче переозначаємо структуру двоколончастого лейауту. */

.woocommerce .woocommerce-notices-wrapper,
.woocommerce-page .woocommerce-notices-wrapper {
    grid-column: 1 / -1;
}

/* Якщо тема виводить sidebar через .content-area + .widget-area —
   ці класи вже розміщені темою. Далі ми стилізуємо лише вміст. */


/* ══════════════════════════════════════════════════════════════
   БІЧНА ПАНЕЛЬ — ФІЛЬТРИ
══════════════════════════════════════════════════════════════ */

/* Astra sidebar */
#secondary.widget-area,
.sidebar-widget-area,
.woocommerce-page .sidebar {
    min-width: 220px;
    /*max-width: 260px;*/
}

/* Заголовок фільтра */
.widget_layered_nav .widgettitle,
.widget_price_filter .widgettitle,
.widget_layered_nav_filters .widgettitle,
.woocommerce-widget-layered-nav .widgettitle,
.ch-filter-widget .widgettitle,
#secondary .widget-title,
#secondary .widgettitle {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #111827;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #E5E7EB;
}

/* Кожен окремий widget-блок */
#secondary .widget,
.sidebar-widget-area .widget {
    background: #fff;
/*     border: 1px solid #E5E7EB; */
/*     border-radius: 10px; */
/*     padding: 16px; */
    margin-bottom: 14px;
}

/* ── Фільтр за ціною ── */
.widget_price_filter .price_slider_wrapper {
    padding-top: 8px;
}
.widget_price_filter .ui-slider {
    margin: 14px 0 20px;
}
.widget_price_filter .ui-slider-horizontal {
    height: 4px;
    background: #E5E7EB;
    border: none;
    border-radius: 2px;
}
.widget_price_filter .ui-slider-range {
    background: #2563EB;
    border: none;
}
.widget_price_filter .ui-slider-handle {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2563EB;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(37,99,235,.4);
    top: -6px;
    cursor: pointer;
    outline: none;
}
.widget_price_filter .ui-slider-handle:focus {
    box-shadow: 0 0 0 3px rgba(37,99,235,.3);
}
.widget_price_filter .price_label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #374151;
    margin-bottom: 10px;
}
.widget_price_filter button.button,
.widget_price_filter button[type="submit"] {
    background: #2563EB !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 7px 16px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: background .18s !important;
    width: 100% !important;
    margin-top: 4px !important;
}
.widget_price_filter button.button:hover {
    background: #1D4ED8 !important;
}

/* ── Фільтр за атрибутами / чекбокси ── */
.widget_layered_nav ul,
.woocommerce-widget-layered-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.widget_layered_nav ul li,
.woocommerce-widget-layered-nav ul li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
}
.widget_layered_nav ul li a,
.woocommerce-widget-layered-nav ul li a {
    color: #374151;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    transition: color .15s;
}
.widget_layered_nav ul li a:hover,
.woocommerce-widget-layered-nav ul li a:hover {
    color: #2563EB;
}
/* Кількість товарів */
.widget_layered_nav ul li .count,
.woocommerce-widget-layered-nav ul li .count {
    margin-left: auto;
    background: #F3F4F6;
    color: #6B7280;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
}
/* Активний пункт фільтра */
.widget_layered_nav ul li.chosen a,
.woocommerce-widget-layered-nav ul li.chosen a {
    color: #2563EB;
    font-weight: 600;
}

/* ── Фільтр "В наявності" / чекбокс ── */
.widget_layered_nav_filters ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.widget_layered_nav_filters ul li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
}
.widget_layered_nav_filters a {
    color: #374151;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.widget_layered_nav_filters a:hover {
    color: #2563EB;
}

/* Кастомний чекбокс для наявності */
.widget_layered_nav_filters .woocommerce-layered-nav-term::before,
.widget_layered_nav ul li a::before,
.woocommerce-widget-layered-nav ul li a::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    min-width: 16px;
    border: 1.5px solid #D1D5DB;
    border-radius: 4px;
    background: #fff;
    transition: background .15s, border-color .15s;
}
.widget_layered_nav ul li.chosen a::before,
.woocommerce-widget-layered-nav ul li.chosen a::before {
    background: #2563EB;
    border-color: #2563EB;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 6l3 3 5-5' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

/* Кнопка "Скинути фільтри" */
.woocommerce-layered-nav-filters .wc-layered-nav-rating a,
a.woocommerce-remove-current-filter {
    color: #DC2626;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
}
a.woocommerce-remove-current-filter:hover {
    text-decoration: underline;
}


/* ══════════════════════════════════════════════════════════════
   СІТКА ПРОДУКТІВ
══════════════════════════════════════════════════════════════ */

ul.products {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    /* ВАЖЛИВО: дозволяємо ховер-блокам виходити за межі сітки */
    overflow: visible !important;
}

/* Коли є sidebar — 3 колонки в основній зоні */
.woocommerce-page.has-sidebar ul.products,
.ast-page-builder-template ul.products,
body.page-template-default .products {
    grid-template-columns: repeat(4, 1fr) !important;
}

@media (max-width: 1100px) {
    ul.products { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 768px) {
    ul.products { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 480px) {
    ul.products { grid-template-columns: 1fr !important; }
}


/* ══════════════════════════════════════════════════════════════
   ОБГОРТКА КАРТКИ (li)
══════════════════════════════════════════════════════════════ */
.ch-card-wrap {
    padding: 0 !important;
    margin: 0 !important;
    width: auto !important;
    float: none !important;
    clear: none !important;
    /* Потрібно щоб z-index на .ch-card працював */
    position: relative !important;
    overflow: visible !important;
}


/* ══════════════════════════════════════════════════════════════
   КАРТКА
══════════════════════════════════════════════════════════════ */
.ch-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    /* overflow: hidden — ПРИБРАНО: ховер має виходити за межі картки */
    /*transition: box-shadow .22s, transform .22s;*/
    position: relative; /* якір для ховера */
}
.ch-card:hover {
    border-radius: 10px 10px 0 0  ;
    /*box-shadow: 0 6px 24px rgba(0,0,0,.10);*/
    z-index: 100; /* картка при ховері піднімається над сусідами */
}

/* ── Блок зображення ── */
.ch-card__img-wrap {
    position: relative;
    /* overflow: hidden — ПРИБРАНО: потрібно для ховера */
    aspect-ratio: 1 / 1;
/*     background: #F9FAFB; */
    border-radius: 10px 10px 0 0; /* закруглення лише зверху */
    flex-shrink: 0;
    overflow: hidden; /* лише для масштабування фото */
}

.ch-card__img-link {
    display: block;
    width: 100%;
    height: 100%;
}

.ch-card__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
    display: block;
    transition: transform .3s ease;
}
.ch-card:hover .ch-card__img {
    transform: scale(1.04);
}

/* Бейдж артикулу */
.ch-card__sku {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    font-size: 11px;
    color: #6B7280;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(4px);
    padding: 2px 7px;
    border-radius: 4px;
    pointer-events: none;
    line-height: 1.6;
}


/* ══════════════════════════════════════════════════════════════
   ХОВЕР-БЛОК — виїжджає ЗНИЗУ картки, накладається поверх сусідів
   Картка НЕ змінює розмір — ховер абсолютно позиційований.
══════════════════════════════════════════════════════════════ */
.ch-card__hover {
    position: absolute;
    top: 100%;           /* одразу під карткою */
    left: -1px;          /* вирівнюємо з лівою межею картки */
    right: -1px;         /* та правою */
    z-index: 200;        /* поверх ВСІХ сусідніх карток */
    pointer-events: none;

    /* Анімація виїзду знизу */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .2s ease, visibility .2s ease, transform .22s ease;
}

.ch-card:hover .ch-card__hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Внутрішній блок */
.ch-hover-inner {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-top: none;           /* зливається з карткою */
    border-radius: 0 0 10px 10px;
/*     box-shadow: 0 12px 28px rgba(0, 0, 0, .12); */
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Максимальна висота щоб не бути задовгим */
    max-height: 260px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #D1D5DB transparent;
}
.ch-hover-inner::-webkit-scrollbar { width: 4px; }
.ch-hover-inner::-webkit-scrollbar-track { background: transparent; }
.ch-hover-inner::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 2px; }



/* Секція */
.ch-hover-section {
    display: flex;
/*     flex-direction: column; */
    gap: 4px;
	padding-bottom: 10px;
	margin-bottom: 10px;
	border-bottom: 1px dashed #E5E7EB;
}
.ch-hover-section__title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6B7280;
    margin-bottom: 2px;
}

/* Звичайний рядок */
.ch-hover-row {
    display: flex;
	flex-direction: column;
    gap: 6px;
    font-size: 12px;
    line-height: 1.4;
    align-items: baseline;
}
.ch-hover-row__label {
    color: #6B7280;
    flex-shrink: 0;
    min-width: 80px;
}
.ch-hover-row__value {
    color: #111827;
    font-weight: 500;
}

/* Рядок Гарантія */
.ch-hover-row--warranty {
    font-size: 13px;
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 1px dashed #E5E7EB;
    margin-bottom: 2px;
	flex-direction: row;
}
.ch-hover-row--warranty .ch-hover-row__label {
    color: #374151;
}
.ch-hover-row--warranty .ch-hover-row__value {
    color: #2563EB;
    font-weight: 700;
}

/* ══════════════════════════════════════════════════════════════
   ТІЛО КАРТКИ
══════════════════════════════════════════════════════════════ */
.ch-card__body {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px 12px 12px;
    flex: 1;
}

.ch-card__title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
    margin: 0;
    color: #111827;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ch-card__title a {
    color: inherit;
    text-decoration: none;
}
.ch-card__title a:hover { color: #2563EB; }

.ch-card__stock {
    font-size: 12px;
    font-weight: 500;
	text-align:right;
}
.ch-card__stock--in   { color: #059669; }
.ch-card__stock--back { color: #D97706; }
.ch-card__stock--out  { color: #DC2626; }

.ch-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
}

/* Ціна */
.ch-card__price { flex: 1; }

.ch-card__price .price,
.ch-card__price .woocommerce-Price-amount {
    font-size: 17px !important;
    font-weight: 700 !important;
    color: #111827 !important;
    white-space: nowrap;
}
.ch-card__price ins  { text-decoration: none !important; }
.ch-card__price del  { font-size: 13px !important; color: #9CA3AF !important; margin-right: 4px; }


/* ══════════════════════════════════════════════════════════════
   КНОПКА КОШИКА — ПОВНЕ СКИДАННЯ СТИЛІВ ASTRA + WOOCOMMERCE
══════════════════════════════════════════════════════════════ */

/*
 * Astra + WooCommerce додають .button, .wp-element-button та інші класи,
 * які зазвичай перебивають наші стилі. Нижче — повне скидання + наш стиль.
 */

a.ch-cart-btn,
a.ch-cart-btn.button,
a.ch-cart-btn.add_to_cart_button,
a.ch-cart-btn.ajax_add_to_cart,
.woocommerce a.ch-cart-btn,
.woocommerce-page a.ch-cart-btn {
    /* Скидання WooCommerce / Astra */
    all: unset !important;

    /* Наші стилі */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 75px !important;
    height: 40px !important;
    min-width: 40px !important;
    border-radius: 24px !important;
    background: linear-gradient(180deg, #37569f 0%, #4d82c2 68.27%) !important;
    color: #fff !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    text-decoration: none !important;
    transition: background .18s ease, transform .15s ease, box-shadow .15s ease !important;
    box-shadow: 0 2px 8px rgba(37,99,235,.30) !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    font-size: 0 !important;  /* приховуємо будь-який текст всередині */
    line-height: 1 !important;
}

a.ch-cart-btn svg {
    display: block !important;
    width: 20px !important;
    height: 20px !important;
    stroke: #fff !important;
    flex-shrink: 0 !important;
    pointer-events: none !important;
}

a.ch-cart-btn:hover,
.woocommerce a.ch-cart-btn:hover {
    background: #1D4ED8 !important;
    transform: scale(1.08) !important;
    box-shadow: 0 4px 12px rgba(37,99,235,.40) !important;
}

a.ch-cart-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(37,99,235,.40) !important;
}

/* Стан "Додається..." (AJAX) */
a.ch-cart-btn.loading {
    pointer-events: none !important;
    opacity: .65 !important;
}
a.ch-cart-btn.loading::after {
    content: '' !important;
    display: block !important;
    width: 16px !important;
    height: 16px !important;
    border: 2px solid rgba(255,255,255,.3) !important;
    border-top-color: #fff !important;
    border-radius: 50% !important;
    animation: ch-spin .7s linear infinite !important;
    position: absolute !important;
}
a.ch-cart-btn.loading svg { display: none !important; }

/* Стан "Додано ✓" */
a.ch-cart-btn.added {
    background: #059669 !important;
}

@keyframes ch-spin {
    to { transform: rotate(360deg); }
}

/* Кнопка "Детальніше" */
a.ch-card__btn-view {
    font-size: 12px;
    padding: 8px 14px;
    background: #F3F4F6;
    color: #374151;
    border-radius: 8px;
    text-decoration: none;
    transition: background .18s;
    white-space: nowrap;
    flex-shrink: 0;
}
a.ch-card__btn-view:hover { background: #E5E7EB; color: #111827; }


/* ══════════════════════════════════════════════════════════════
   МОБІЛЬНІ — ХОВЕР ПРИХОВАНИЙ, ПОКАЗУЄМО МІНІМУМ INFO
══════════════════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
    .ch-card__hover { display: none !important; }
}

@media (max-width: 600px) {
    .ch-card__title { -webkit-line-clamp: 2; }
    .ch-card__price .price,
    .ch-card__price .woocommerce-Price-amount {
        font-size: 15px !important;
    }
    a.ch-cart-btn,
    a.ch-cart-btn.button {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }
}



