/* ==========================================================================
   VIGNETTE PRODUIT (vue/snippets/product.php) - utilisée sur tout le site
   S'appuie sur les variables de css/chavigny.css
   ========================================================================== */

.pc {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius);
    background: var(--ch-white);
    overflow: hidden;
    transition: box-shadow .25s var(--ch-ease), border-color .25s var(--ch-ease), transform .25s var(--ch-ease);
}

.pc:hover,
.pc:focus-within {
    border-color: transparent;
    box-shadow: var(--ch-shadow-lg);
    transform: translateY(-3px);
}

/* Visuel : format carré, produit entier sur fond blanc */
.pc-media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    min-height: 0;
    overflow: hidden;
    padding: 18px;
    background: var(--ch-white);
}

.pc-media img {
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
    transition: transform .35s var(--ch-ease);
}

.pc-media img.is-fallback {
    opacity: .35;
}

.pc:hover .pc-media img {
    transform: scale(1.05);
}

.pc-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1;
    padding: 4px 10px;
    border-radius: var(--ch-radius-pill);
    background: var(--ch-red);
    color: var(--ch-white);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

/* Contenu */
.pc-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 6px;
    padding: 4px 16px 16px;
    border-top: 1px solid var(--ch-grey-light);
}

.pc-eyebrow {
    min-height: 1.4em; /* ligne réservée même sans marque : désignations alignées */
    margin: 10px 0 0;
    line-height: 1.4;
    overflow: hidden;
    color: var(--ch-grey-dark);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.pc-name {
    margin: 0;
    font-family: var(--ch-font);
    font-size: .95rem;
    font-weight: 700;
    line-height: 1.35;
}

.pc-name a {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    min-height: calc(1.35em * 3); /* 3 lignes réservées : vignettes de même hauteur sur toute la grille */
    overflow: hidden;
    color: var(--ch-text);
    text-decoration: none;
    transition: color .2s var(--ch-ease);
}

.pc-name a:hover {
    color: var(--ch-red);
}

/* Toute la vignette est cliquable, sans masquer les boutons d'action */
.pc-name a::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
}

.pc-ref {
    margin: 0;
    color: var(--ch-grey);
    font-size: .78rem;
}

.pc-ref-sep {
    margin: 0 4px;
}

.pc-stock {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    margin: 2px 0 0;
    color: var(--ch-grey-dark);
    font-size: .8rem;
    font-weight: 700;
}

.pc-stock-dot {
    flex: 0 0 8px;
    align-self: center;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ch-grey);
}

.pc-stock.is-in { color: #2d7a3e; }
.pc-stock.is-in .pc-stock-dot { background: #2d9a4a; box-shadow: 0 0 0 3px rgba(45, 154, 74, .15); }
.pc-stock.is-other { color: #9a6200; }
.pc-stock.is-other .pc-stock-dot { background: #e0a000; box-shadow: 0 0 0 3px rgba(224, 160, 0, .15); }
.pc-stock.is-out .pc-stock-dot { background: var(--ch-grey); }

/* Mode « Commande différée » : lien « En savoir plus » sur sa propre ligne, sous l'état du stock
   (au-dessus du lien de la vignette) */
.pc-stock-text { min-width: 0; }
/* Libellé sur une ligne dans une vignette standard ; s'il passe à la ligne, la pastille reste sur la première */
.pc-stock.is-differe {
    gap: 6px;
    align-items: flex-start;
    font-size: .76rem;
    line-height: 1.35;
}
.pc-stock.is-differe .pc-stock-dot {
    align-self: flex-start;
    margin-top: calc((1.35em - 8px) / 2);
}
.pc-stock-more {
    position: relative;
    z-index: 1;
    align-self: flex-start;
    margin: -4px 0 0 14px;
    color: var(--ch-grey-dark);
    font-size: .74rem;
    font-weight: 400;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.pc-stock-more:hover,
.pc-stock-more:focus-visible { color: var(--ch-red); }

.pc-price {
    margin-top: auto;
    padding-top: 10px;
}

.pc-price strong {
    color: var(--ch-text);
    font-size: 1.2rem;
    font-weight: 700;
}

.pc-price em {
    color: var(--ch-grey-dark);
    font-size: .84rem;
}

/* Mode « Commande différée » : prix validé par le conseiller */
.pc-price em.pc-price-differe {
    color: var(--ch-text);
    font-size: 1rem;
    font-style: normal;
    font-weight: 700;
}

/* Actions (au-dessus du lien étendu de la vignette) : toujours en bas de la vignette,
   avec ou sans prix (visiteur non connecté), pour des boutons alignés d'une vignette à l'autre */
.pc-actions {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap; /* vignette étroite : le bouton passe sous la quantité */
    gap: 8px;
    margin-top: auto;
    padding-top: 10px;
}

/* Avec un prix : prix et actions groupés en bas */
.pc-price + .pc-actions {
    margin-top: 0;
}

.pc-view,
.pc-add {
    flex: 1 1 120px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--ch-radius-pill);
    background: var(--ch-red);
    color: var(--ch-white);
    font-family: var(--ch-font);
    font-size: .9rem;
    font-weight: 700;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: .02em;
    cursor: pointer;
    transition: background-color .2s var(--ch-ease), box-shadow .2s var(--ch-ease);
}

.pc-view:hover,
.pc-view:focus-visible,
.pc-add:hover,
.pc-add:focus-visible {
    background: var(--ch-red-dark);
    color: var(--ch-white);
    box-shadow: 0 6px 14px rgba(208, 52, 58, .25);
}

.pc-add[disabled] {
    opacity: .7;
    cursor: wait;
}

.pc-add.is-added {
    background: #2d7a3e;
}

.pc-add i {
    font-size: 1rem;
}

/* Sélecteur de quantité */
.pc-qty {
    flex: 1 1 96px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;
    border: 1.5px solid var(--ch-border);
    border-radius: var(--ch-radius-pill);
    background: var(--ch-white);
    overflow: hidden;
}

.pc-qty:focus-within {
    border-color: var(--ch-red);
}

.pc-qty-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 100%;
    border: 0;
    background: transparent;
    color: var(--ch-grey-dark);
    font-size: .8rem;
    cursor: pointer;
}

.pc-qty-btn:hover {
    color: var(--ch-red);
}

.pc-qty-input {
    width: 36px;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ch-text);
    font-family: var(--ch-font);
    font-size: .92rem;
    font-weight: 700;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}

.pc-qty-input::-webkit-outer-spin-button,
.pc-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pc-qty-input:focus {
    outline: none;
}

/* Grille standard de vignettes */
.pc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* --------------------------------------------------------------------------
   Confirmation d'ajout au panier (js/product-card.js)
   -------------------------------------------------------------------------- */
.pc-toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 14px;
    width: min(380px, calc(100vw - 32px));
    padding: 14px 16px;
    border-left: 4px solid #2d9a4a;
    border-radius: var(--ch-radius);
    background: var(--ch-white);
    box-shadow: 0 16px 40px rgba(0, 0, 0, .2);
    font-family: var(--ch-font);
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    transition: opacity .25s var(--ch-ease), transform .25s var(--ch-ease);
}

.pc-toast.is-visible {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.pc-toast.is-error {
    border-left-color: var(--ch-red);
}

.pc-toast-img {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.pc-toast-body {
    flex: 1 1 auto;
    min-width: 0;
}

.pc-toast-title {
    margin: 0 0 2px;
    color: var(--ch-text);
    font-size: .9rem;
    font-weight: 700;
}

.pc-toast-name {
    margin: 0;
    overflow: hidden;
    color: var(--ch-grey-dark);
    font-size: .82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pc-toast-link {
    flex: 0 0 auto;
    color: var(--ch-red);
    font-size: .85rem;
    font-weight: 700;
    text-decoration: none;
}

.pc-toast-link:hover {
    text-decoration: underline;
}

.pc-toast-close {
    position: absolute;
    top: 6px;
    right: 8px;
    border: 0;
    background: none;
    color: var(--ch-grey);
    font-size: .9rem;
    cursor: pointer;
}

@media (max-width: 640px) {
    .pc-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .pc-media {
        padding: 12px;
    }

    .pc-body {
        padding: 2px 12px 12px;
    }

    .pc-name {
        font-size: .88rem;
    }

    .pc-price strong {
        font-size: 1.05rem;
    }

    .pc-qty-btn {
        width: 40px;
    }

    .pc-view,
    .pc-add {
        font-size: .82rem;
    }

    .pc-toast {
        right: 16px;
        bottom: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pc,
    .pc-media img,
    .pc-toast {
        transition: none;
    }
}

/* Multiple de vente (ps_conditionnement_vente > 1) */
.pc-qty-multiple {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 6px 0 0;
    color: #9a6200;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.3;
    flex: 1 1 100%;
    order: 3;
    margin: 0;
    font-size: .72rem;
}
