/* product-card.css — спільний стиль картки товару (.p-card) для каталогу,
   головної, пошуку та блоку «схожі товари» на сторінці товару.
   Джерело істини — щоб картки скрізь були однакові. */

.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

/* Картка товару */
.p-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,.07);
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
    display: flex; flex-direction: column;
    position: relative;
}
.p-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,.12); transform: translateY(-3px); }

.p-card-discount {
    position: absolute; top: 10px; left: 10px;
    background: #e74c3c; color: #fff;
    font-size: 12px; font-weight: 700;
    padding: 3px 8px; border-radius: 5px;
    z-index: 2;
}
.p-card-img-wrap {
    position: relative;
    height: 240px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    padding: 4px;
}
.p-card-img-wrap img {
    width: 100%; height: 100%;
    object-fit: contain;
    transition: transform .35s;
}
.p-card:hover .p-card-img-wrap img { transform: scale(1.06); }

/* ── Гортання фото при наведенні ── */
.p-card-img-wrap.has-gallery .p-card-img {
    position: absolute;
    top: 4px; left: 4px; right: 4px; bottom: 4px;
    width: calc(100% - 8px); height: calc(100% - 8px);
    margin: auto;
    opacity: 0;
    transition: opacity .35s ease;
}
.p-card-img-wrap.has-gallery .p-card-img.active { opacity: 1; }

.p-card-dots {
    position: absolute;
    left: 0; right: 0; bottom: 8px;
    display: flex; justify-content: center; gap: 5px;
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
    z-index: 3;
}
.p-card:hover .p-card-dots { opacity: 1; }
.p-card-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: rgba(0,0,0,.18);
    transition: background .25s, transform .25s;
}
.p-card-dot.active { background: #f60; transform: scale(1.25); }

.p-card-body { padding: 12px 14px 14px; flex: 1; display: flex; flex-direction: column; }

.p-card-title {
    font-size: 14px; font-weight: 500; line-height: 1.4;
    color: #222; text-decoration: none;
    min-height: 40px;
    margin-bottom: 8px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.p-card-title:hover { color: #f60; }

/* Рядок наявність + рейтинг */
.p-card-avail-row {
    display: flex; align-items: center;
    justify-content: space-between; gap: 6px;
    margin-bottom: 8px;
}
.p-card-avail {
    font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.p-card-avail.ok  { color: #27ae60; }
.p-card-avail.no  { color: #e74c3c; }
.p-card-avail.pre { color: #f39c12; }

.p-card-rating {
    display: flex; align-items: center; gap: 5px;
    flex-shrink: 0;
}
.p-card-stars { display: flex; gap: 2px; }
.p-card-star  { font-size: 15px; line-height: 1; }
.p-card-star.on  { color: #f5c518; }
.p-card-star.off { color: #dde0e7; }
.p-card-rat-score { font-size: 13px; font-weight: 700; color: #333; }
.p-card-rat-cnt   { font-size: 12px; color: #aaa; }
.p-card-rat-sep   { color: #dde0e7; font-size: 11px; }
.p-card-rat-write {
    font-size: 12px; color: #b08000; font-weight: 600;
    text-decoration: none;
    padding: 2px 7px; border-radius: 5px;
    background: #fef9e0; white-space: nowrap; transition: background .15s;
}
.p-card-rat-write:hover { background: #fdf0b0; color: #8a6000; }

.p-card-rating.no-reviews .p-card-rat-write {
    font-size: 11px; padding: 2px 6px;
    background: #f5f6f8; color: #aaa;
    border: 1px dashed #dde0e7;
}
.p-card-rating.no-reviews .p-card-rat-write:hover { background: #fef9e0; color: #b08000; border-color: #f5c518; }

.p-card-prices { margin-bottom: 10px; }
.p-card-freeship { position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 5px;
    background: #ffdd00; color: #1a1a1a; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 6px;
    margin-bottom: 10px; line-height: 1.2; box-shadow: 0 1px 5px rgba(255,221,0,.55); }
.p-card-freeship svg { flex-shrink: 0; }
.p-card-freeship::after { content: ''; position: absolute; top: 0; left: -60%; width: 45%; height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255,255,255,.75), transparent);
    transform: skewX(-20deg); animation: pcFsShine 3.4s ease-in-out infinite; pointer-events: none; }
@keyframes pcFsShine { 0%, 55% { left: -60%; } 100% { left: 135%; } }
.p-card-freeship { max-width: 100%; white-space: normal; }
.p-card-freeship.urgent { color: #c0392b; }
.p-card-old {
    font-size: 12px; color: #f60; font-weight: 600;
    text-decoration: line-through; display: block; margin-bottom: 2px;
}
.p-card-price {
    font-size: 20px; font-weight: 800;
    color: #1a1a1a; background: #ffdd00;
    display: inline-block; padding: 3px 10px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(255,221,0,.4);
}
.p-card-savings {
    font-size: 12px; color: #27ae60; font-weight: 700;
    display: block; margin-top: 4px;
}

/* Qty + кнопки в картці */
.p-card-actions {
    margin-top: auto;
    display: flex; align-items: stretch; gap: 6px;
}
.p-qty-row {
    display: flex; align-items: center;
    border: 2px solid #dde2e8; border-radius: 8px;
    overflow: hidden; flex-shrink: 0; align-self: center;
}
.p-btn-col {
    flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0;
}
.p-qty-btn {
    width: 32px; height: 36px;
    background: #f5f6f8; border: none; cursor: pointer;
    font-size: 18px; font-weight: 300; color: #555; line-height: 1;
    transition: background .15s;
}
.p-qty-btn:hover { background: #ebebeb; }
.p-qty-inp {
    width: 40px; height: 36px;
    border: none; border-left: 2px solid #dde2e8; border-right: 2px solid #dde2e8;
    text-align: center; font-size: 14px; font-weight: 600;
    outline: none; padding: 0;
    -moz-appearance: textfield; appearance: textfield;
}
.p-qty-inp::-webkit-outer-spin-button,
.p-qty-inp::-webkit-inner-spin-button { -webkit-appearance: none; }
.p-card-btn-add {
    flex: 1;
    background: #f60; color: #fff;
    border: none; border-radius: 7px;
    padding: 0; min-height: 34px;
    font-size: 12px; font-weight: 700;
    cursor: pointer; text-align: center;
    transition: background .2s;
    font-family: 'Inter', Arial, sans-serif;
}
.p-card-btn-add:hover { background: #e55a00; }
.p-card-btn-buy {
    flex: 1;
    background: #27ae60; color: #fff;
    border: none; border-radius: 7px;
    padding: 0; min-height: 34px;
    font-size: 12px; font-weight: 700;
    cursor: pointer; text-align: center;
    transition: background .2s;
    font-family: 'Inter', Arial, sans-serif;
    text-decoration: none;
    display: flex; align-items: center; justify-content: center;
}
.p-card-btn-buy:hover { background: #219a52; color: #fff; text-decoration: none; }
@media (max-width: 640px) {
    .p-card-actions { flex-direction: column; gap: 5px; }
    .p-qty-row { width: 100%; justify-content: center; }
    .p-qty-btn { flex: 1; }
    .p-card-btn-add, .p-card-btn-buy { min-height: 32px; font-size: 12px; }
}
/* Кнопка "Детальніше" (недоступний товар) */
.p-card-btn-detail {
    display: block; width: 100%;
    background: #7f8c8d; color: #fff;
    border-radius: 7px; padding: 10px 0;
    font-size: 13px; font-weight: 700;
    text-align: center; text-decoration: none;
    font-family: 'Inter', Arial, sans-serif;
    margin-top: auto;
}
.p-card-btn-detail:hover { background: #707b7c; color: #fff; text-decoration: none; }

/* ── Адаптив сітки ── */
@media (max-width: 900px) { .products-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .products-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
