/*
 * Картки товарів у списках (oct_deals): категорії, пошук, акції, виробники, модулі товарів.
 * Лише вигляд сітки (product-grid і слайдери модулів); вигляд «список» і «прайс» теми не змінюються.
 */

/* ---- Вигляд картки: м'які кути, легка тінь, підйом при наведенні ---- */
:is(.product-grid, .ds-module-item:not(.product-layout)) > .content-block {
    --pg-accent: var(--ds-primary-color, #00A8E8);
    padding: 12px 12px 14px; border: 1px solid color-mix(in srgb, var(--ds-border-color, #e3e7ee) 75%, transparent); border-radius: 18px;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
:is(.product-grid, .ds-module-item:not(.product-layout)) > .content-block:hover {
    border-color: transparent; box-shadow: 0 16px 36px -14px rgba(16, 24, 40, .25); transform: translateY(-3px);
}
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-img img { border-radius: 12px; }

/* Кнопки «переглянути / обране / порівняти» — круглі, на комп'ютері з'являються при наведенні */
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-buttons {
    top: 2px; right: 2px; gap: 6px; padding: 0; border-radius: 0; background: none;
}
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-buttons button {
    display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%;
    background: var(--ds-white-color, #fff); box-shadow: 0 2px 10px rgba(16, 24, 40, .12); transition: transform .15s, opacity .2s;
}
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-buttons button:hover { transform: scale(1.08); }
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-buttons button:hover svg path { fill: var(--ds-primary-color, #00A8E8); }
@media (hover: hover) and (pointer: fine) {
    :is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-buttons button { opacity: 0; transform: translateX(6px); }
    :is(.product-grid, .ds-module-item:not(.product-layout)) .content-block:hover .ds-module-buttons button { opacity: 1; transform: none; }
    :is(.product-grid, .ds-module-item:not(.product-layout)) .content-block:hover .ds-module-buttons button:nth-child(2) { transition-delay: .03s; }
    :is(.product-grid, .ds-module-item:not(.product-layout)) .content-block:hover .ds-module-buttons button:nth-child(3) { transition-delay: .06s; }
}

/* Стікери теми (Новинка, Хіт…) — акуратні «таблетки» */
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-img .ds-module-stickers { top: 4px; left: 4px; }
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-sticker { padding: 4px 8px; border-radius: 8px !important; font-size: 11px; font-weight: 600; }

/* Текст */
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-caption { padding-top: 10px; }
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-title { margin-bottom: 4px; color: var(--ds-dark-text-color, #1d2433) !important; font-size: 14px; font-weight: 500 !important; }
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-title:hover { color: var(--ds-primary-color, #00A8E8) !important; text-decoration: none; }
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-code { color: var(--ds-light-text-color, #8a919e); font-size: 12px; }
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-stock { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-stock.green-text::before {
    content: ""; flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

/* Ціна */
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-price-new { font-size: 21px !important; font-weight: 800 !important; letter-spacing: -.01em; line-height: 1.15; }
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-price-old { font-size: 13px !important; }
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-price .ds-module-sticker { padding: 2px 6px; border-radius: 6px !important; font-size: 11px; font-weight: 700; }

/* Кошик — заповнена кнопка кольору теми */
:is(.product-grid, .ds-module-item:not(.product-layout)) :is(.ds-category-cart-btn, .ds-module-cart-btn) {
    min-width: 46px; height: 46px; padding: 0 12px; border: 0 !important; border-radius: 14px !important;
    background: var(--ds-primary-color, #00A8E8) !important; color: #fff !important;
    box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--ds-primary-color, #00A8E8) 70%, transparent); transition: transform .15s, filter .15s;
}
:is(.product-grid, .ds-module-item:not(.product-layout)) :is(.ds-category-cart-btn, .ds-module-cart-btn) svg path { fill: #fff !important; }
:is(.product-grid, .ds-module-item:not(.product-layout)) :is(.ds-category-cart-btn, .ds-module-cart-btn):hover:not([disabled]) { filter: brightness(.94); transform: translateY(-1px); }
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-quantity { border-radius: 12px !important; }

/* Товар уже в кошику: світла кнопка з галочкою; натискання відкриває кошик */
:is(.product-grid, .ds-module-item:not(.product-layout)) :is(.ds-category-cart-btn, .ds-module-cart-btn).pg-in-cart {
    position: relative; overflow: visible;
    background: color-mix(in srgb, var(--ds-primary-color, #00A8E8) 12%, var(--ds-white-color, #fff)) !important;
    box-shadow: inset 0 0 0 1.5px var(--ds-primary-color, #00A8E8);
}
:is(.product-grid, .ds-module-item:not(.product-layout)) :is(.ds-category-cart-btn, .ds-module-cart-btn).pg-in-cart svg path { fill: var(--ds-primary-color, #00A8E8) !important; }
:is(.product-grid, .ds-module-item:not(.product-layout)) :is(.ds-category-cart-btn, .ds-module-cart-btn).pg-in-cart::after {
    content: ""; position: absolute; top: -5px; right: -5px; width: 18px; height: 18px; border: 2px solid var(--ds-white-color, #fff); border-radius: 50%;
    background: var(--ds-primary-color, #00A8E8) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 10px no-repeat;
    box-sizing: border-box;
}

/* ---- Підкатегорії вгорі категорії ---- */
.ds-subcategories.row {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 12px;
    margin: 0 0 18px !important; overflow: visible;
}
.ds-subcategories > .ds-subcategories-item { width: auto; max-width: none; margin: 0; padding: 0; flex: none; }
.ds-subcategories-item > .content-block {
    gap: 8px; padding: 12px 10px 14px !important; border: 1px solid color-mix(in srgb, var(--ds-border-color, #e3e7ee) 75%, transparent);
    border-radius: 18px; text-decoration: none; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.ds-subcategories-item > .content-block:hover { border-color: transparent; box-shadow: 0 14px 30px -14px rgba(16, 24, 40, .25); transform: translateY(-2px); }
.ds-subcategories-item img {
    width: 76px; height: 76px; margin: 0 auto !important; padding: 8px; border-radius: 16px;
    background: var(--ds-light-bg-color, #f3f5f8); object-fit: contain; box-sizing: border-box; transition: transform .2s ease;
}
/* Білий фон фото зливається з плашкою (світла тема) */
body:not(.dark-theme) .ds-subcategories-item img { mix-blend-mode: multiply; }
.ds-subcategories-item > .content-block:hover img { transform: scale(1.05); }
.ds-subcategories-title {
    display: -webkit-box; overflow: hidden; color: var(--ds-dark-text-color, #1d2433) !important;
    font-size: 13px !important; font-weight: 600 !important; line-height: 1.3 !important; text-align: center;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical; transition: color .15s;
}
.ds-subcategories-item:hover span { text-decoration: none; }
.ds-subcategories-item > .content-block:hover .ds-subcategories-title { color: var(--ds-primary-color, #00A8E8) !important; }

/* Телефон і планшет — стрічка «таблеток», гортається пальцем */
@media (max-width: 767.98px) {
    .ds-subcategories.row {
        display: flex; flex-wrap: nowrap; gap: 8px; margin: 0 -12px 16px !important; padding: 2px 12px 6px;
        overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
    }
    .ds-subcategories.row::-webkit-scrollbar { display: none; }
    .ds-subcategories > .ds-subcategories-item { flex: 0 0 auto; scroll-snap-align: start; }
    .ds-subcategories-item > .content-block { flex-direction: row !important; align-items: center !important; gap: 8px; padding: 6px 14px 6px 6px !important; border-radius: 14px; }
    .ds-subcategories-item img { width: 40px; height: 40px; padding: 4px; border-radius: 10px; }
    .ds-subcategories-title { text-align: left; white-space: nowrap; -webkit-line-clamp: 1; }
}

/* ---- Однакова висота рядків картки ---- */
/* Назва — завжди 2 рядки: код, наявність, рейтинг і ціна стоять на одному рівні в усьому ряду */
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-title {
    display: -webkit-box; min-height: 2.8em; overflow: hidden;
    line-height: 1.4; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-code,
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-stock {
    overflow: hidden; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap;
}

/* Модулі (головна, «Ви дивилися»): рейтинг і ціна — внизу картки разом, як у категорії */
.ds-module-item:not(.product-layout) .ds-module-caption > .ds-module-rating { margin-top: auto; }
.ds-module-item:not(.product-layout) .ds-module-caption > .ds-module-rating + .ds-module-price { margin-top: 0 !important; }

/* Ціна: зі знижкою (стара ціна над новою) і без — нова ціна на одному рівні */
:is(.product-grid, .ds-module-item:not(.product-layout)) .ds-module-price {
    display: flex; flex-direction: column; justify-content: flex-end; min-height: 46px;
}

/* ---- Оплата частинами: одна плашка зліва внизу фото ---- */
.ds-module-img-box .ukrcreditsticker {
    top: auto; right: auto; bottom: 6px; left: 6px; z-index: 5;
    display: inline-flex; align-items: center; gap: 0; width: max-content; max-width: calc(100% - 12px);
    padding: 3px 9px 3px 3px; border-radius: 20px;
    background: var(--ds-white-color, #fff); box-shadow: 0 2px 10px rgba(16, 24, 40, .14);
    color: var(--ds-dark-text-color, #1d2433); font-size: 12px; line-height: 1; pointer-events: none;
}
.ds-module-img-box .ukrcreditsticker > div {
    flex: 0 0 22px; width: 22px; height: 22px; margin-left: -6px;
    border: 2px solid var(--ds-white-color, #fff); border-radius: 50%;
    background-color: var(--ds-white-color, #fff); background-size: 18px !important;
}
.ds-module-img-box .ukrcreditsticker > div:first-child { margin-left: 0; }
.ds-module-img-box .ukrcreditsticker > div span { display: none; }
.ds-module-img-box .ukrcreditsticker > div.pg-hidden { display: none; }
/* Стилі ukrcredits роблять кожен span у плашці кружечком 20×20 поверх логотипа — для «+N» і тексту скасовуємо */
.ds-module-img-box .ukrcreditsticker .pg-credit-more,
.ds-module-img-box .ukrcreditsticker .pg-credit-text {
    position: static; top: auto; right: auto; bottom: auto; left: auto; z-index: auto;
    width: auto; height: auto; border-radius: 0; background: none; text-align: left;
}
.ds-module-img-box .ukrcreditsticker .pg-credit-more {
    flex: 0 0 auto; min-width: 22px; height: 22px; margin-left: -6px; padding: 0 4px;
    border: 2px solid var(--ds-white-color, #fff); border-radius: 11px;
    background: var(--ds-light-bg-color, #f0f2f5); color: var(--ds-light-text-color, #5b6472);
    font-size: 10px; font-weight: 700; line-height: 18px; text-align: center; box-sizing: border-box;
}
.ds-module-img-box .ukrcreditsticker .pg-credit-text {
    min-width: 0; margin-left: 7px; overflow: hidden; color: var(--ds-dark-text-color, #1d2433);
    font-size: 12px; font-weight: 600; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap;
}

/* Наведення на плашку — список усіх банків над нею (на комп'ютері) */
.ds-module-img-box .ukrcreditsticker .pg-credit-list { display: none; }
@media (hover: hover) and (pointer: fine) {
    .ds-module-img-box .ukrcreditsticker.pg-has-list { pointer-events: auto; cursor: default; }
    .ds-module-img-box .ukrcreditsticker.pg-has-list:hover { z-index: 20; box-shadow: 0 4px 16px rgba(16, 24, 40, .2); }
    .ds-module-img-box .ukrcreditsticker.pg-has-list:hover .pg-credit-list { display: block; }
    /* Між плашкою й списком — невидимий місток, щоб список не зникав, поки ведеш мишу */
    .ds-module-img-box .ukrcreditsticker.pg-has-list::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 8px; }
}
.ds-module-img-box .ukrcreditsticker .pg-credit-list {
    position: absolute; bottom: calc(100% + 8px); left: 0; width: 236px; max-width: 80vw; margin: 0; padding: 4px;
    border: 1px solid var(--ds-border-color, #e3e7ee); border-radius: 12px; background: var(--ds-white-color, #fff);
    box-shadow: 0 12px 32px rgba(16, 24, 40, .18); list-style: none; text-align: left;
    animation: pg-credit-in .12s ease-out;
}
.ds-module-img-box .ukrcreditsticker .pg-credit-list li { display: flex; align-items: center; gap: 8px; margin: 0; padding: 4px 6px; border-radius: 8px; }
.ds-module-img-box .ukrcreditsticker .pg-credit-list li.pg-credit-head {
    display: block; padding: 4px 6px 6px; color: var(--ds-light-text-color, #5b6472); font-size: 11px; font-weight: 600; line-height: 1.3;
}
.ds-module-img-box .ukrcreditsticker .pg-credit-logo {
    flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%;
    background-color: var(--ds-white-color, #fff); background-repeat: no-repeat; background-position: center; background-size: 20px !important;
}
.ds-module-img-box .ukrcreditsticker .pg-credit-list em {
    flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--ds-light-text-color, #5b6472);
    font-size: 12px; font-style: normal; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap;
}
.ds-module-img-box .ukrcreditsticker .pg-credit-list b { color: var(--ds-dark-text-color, #1d2433); font-weight: 600; }
.ds-module-img-box .ukrcreditsticker .pg-credit-list strong { flex: 0 0 auto; color: var(--ds-dark-text-color, #1d2433); font-size: 12px; font-weight: 700; line-height: 1.3; white-space: nowrap; }
.ds-module-img-box .ukrcreditsticker .pg-credit-list li.is-best strong { color: color-mix(in srgb, var(--ds-primary-color, #00A8E8) 85%, var(--ds-dark-text-color, #1d2433)); }
@keyframes pg-credit-in { from { opacity: 0; transform: translateY(4px); } }

@media (max-width: 575.98px) {
    .ds-module-img-box .ukrcreditsticker { bottom: 4px; left: 4px; padding-right: 7px; font-size: 11px; }
    .ds-module-img-box .ukrcreditsticker > div { flex-basis: 20px; width: 20px; height: 20px; background-size: 16px !important; }
    .ds-module-img-box .ukrcreditsticker .pg-credit-more { height: 20px; line-height: 16px; }
    .ds-module-img-box .ukrcreditsticker .pg-credit-text { margin-left: 5px; font-size: 11px; }
}
