/*
 * Liste de souhaits (YITH WooCommerce Wishlist)
 *
 * L'extension rend un tableau de boutique brut : bordures grises, croix rouge
 * en première colonne, bouton d'ajout au panier réduit à un lien encadré. Rien
 * n'y ressemble au reste du site.
 *
 * On reprend l'habillage sans toucher au gabarit de l'extension : ses
 * fonctions AJAX s'appuient sur cette structure de tableau, et la recopier
 * pour la modifier exposerait à une rupture à chaque mise à jour.
 *
 * Sur mobile le tableau devient une pile de fiches. YITH ne pose pas
 * d'attribut data-title sur ses cellules, l'en-tête est donc simplement
 * masquée et chaque cellule reprend un rôle explicite dans la fiche.
 */

.wishlist_table,
.yith-wcwl-form {
    --pdc-vert: var(--wp--preset--color--color-1, #2d7a3c);
    --pdc-rose: var(--wp--preset--color--color-2, #e62ca1);
    --pdc-encre: var(--wp--preset--color--color-text, #1f2937);
    --pdc-gris: #6b7280;
    --pdc-trait: #e5e7eb;
    --pdc-fond: #f9fafb;
    --pdc-rayon: 12px;
}

.wishlist-title h2 {
    margin-bottom: 1.5rem;
}

/* ------------------------------------------------------------------
   Tableau
   ------------------------------------------------------------------ */

.woocommerce table.wishlist_table {
    width: 100%;
    border: 1px solid var(--pdc-trait);
    border-radius: var(--pdc-rayon);
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    font-size: 0.9375rem;
    color: var(--pdc-encre);
}

.woocommerce table.wishlist_table thead th {
    padding: 0.85rem 1rem;
    background: var(--pdc-fond);
    border: 0;
    border-bottom: 1px solid var(--pdc-trait);
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pdc-gris);
}

.woocommerce table.wishlist_table tbody td {
    padding: 1rem;
    border: 0;
    border-bottom: 1px solid var(--pdc-trait);
    vertical-align: middle;
    background: #fff;
}

.woocommerce table.wishlist_table tbody tr:last-child td {
    border-bottom: 0;
}

.woocommerce table.wishlist_table tbody tr:hover td {
    background: var(--pdc-fond);
}

/* Vignette */

.woocommerce table.wishlist_table td.product-thumbnail {
    width: 96px;
}

.woocommerce table.wishlist_table td.product-thumbnail img {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: contain;
    padding: 4px;
    background: #fff;
    border: 1px solid var(--pdc-trait);
    border-radius: 8px;
}

/* Nom */

.woocommerce table.wishlist_table td.product-name a {
    font-weight: 600;
    color: var(--pdc-encre);
    text-decoration: none;
}

.woocommerce table.wishlist_table td.product-name a:hover {
    color: var(--pdc-vert);
    text-decoration: underline;
}

/* Prix */

.woocommerce table.wishlist_table td.product-price {
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Disponibilité : une pastille plutôt qu'une phrase verte. */

.woocommerce table.wishlist_table td.product-stock-status span {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
}

.woocommerce table.wishlist_table td.product-stock-status .wishlist-in-stock {
    background: #e8f4ea;
    color: #1f6b33;
}

.woocommerce table.wishlist_table td.product-stock-status .wishlist-out-of-stock {
    background: #fdecec;
    color: #a4262c;
}

/* Ajout au panier : c'est l'action principale de la ligne. */

.woocommerce table.wishlist_table td.product-add-to-cart a.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1.25rem;
    border: 1px solid var(--pdc-rose);
    border-radius: 24px;
    background: var(--pdc-rose);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s, color 0.2s;
}

.woocommerce table.wishlist_table td.product-add-to-cart a.button:hover {
    background: #fff;
    color: var(--pdc-rose);
}

/* Retrait : action destructrice, donc discrète jusqu'au survol. */

.woocommerce table.wishlist_table td.product-remove {
    width: 56px;
    text-align: center;
}

.woocommerce table.wishlist_table td.product-remove a.remove,
.woocommerce table.wishlist_table td.product-remove a.remove_from_wishlist {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    color: var(--pdc-gris);
    font-size: 1rem;
    line-height: 1;
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
}

.woocommerce table.wishlist_table td.product-remove a.remove:hover,
.woocommerce table.wishlist_table td.product-remove a.remove_from_wishlist:hover {
    background: #fdecec;
    color: #a4262c;
}

/* ------------------------------------------------------------------
   Liste vide
   ------------------------------------------------------------------ */

.wishlist-empty,
.woocommerce .wishlist_table.wishlist_manage_table tbody tr td.wishlist-empty {
    padding: 2.5rem 1.5rem;
    background: var(--pdc-fond);
    border: 1px dashed var(--pdc-trait);
    border-radius: var(--pdc-rayon);
    text-align: center;
    color: var(--pdc-gris);
}

/* ------------------------------------------------------------------
   Mobile : le tableau devient une pile de fiches
   ------------------------------------------------------------------ */

@media (max-width: 768px) {
    .woocommerce table.wishlist_table {
        border: 0;
        border-radius: 0;
    }

    .woocommerce table.wishlist_table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .woocommerce table.wishlist_table,
    .woocommerce table.wishlist_table tbody,
    .woocommerce table.wishlist_table tr,
    .woocommerce table.wishlist_table td {
        display: block;
        width: auto;
    }

    /*
     * La fiche est une grille : vignette à gauche sur deux rangées, nom et
     * prix à droite, puis disponibilité et bouton en pied. Le retrait se cale
     * en haut à droite, hors du flux de lecture.
     */
    .woocommerce table.wishlist_table tbody tr {
        position: relative;
        display: grid;
        grid-template-columns: 88px minmax(0, 1fr);
        grid-template-areas:
            "vignette nom"
            "vignette prix"
            "stock    stock"
            "panier   panier";
        gap: 0.35rem 1rem;
        align-items: center;
        margin-bottom: 1rem;
        padding: 1rem;
        border: 1px solid var(--pdc-trait);
        border-radius: var(--pdc-rayon);
    }

    .woocommerce table.wishlist_table tbody td,
    .woocommerce table.wishlist_table tbody tr:hover td {
        padding: 0;
        border: 0;
        background: transparent;
    }

    .woocommerce table.wishlist_table td.product-thumbnail {
        grid-area: vignette;
    }

    .woocommerce table.wishlist_table td.product-thumbnail img {
        width: 88px;
        height: 88px;
    }

    .woocommerce table.wishlist_table td.product-name {
        grid-area: nom;
        padding-right: 2rem;
    }

    .woocommerce table.wishlist_table td.product-price {
        grid-area: prix;
        font-size: 1.0625rem;
    }

    .woocommerce table.wishlist_table td.product-stock-status {
        grid-area: stock;
        margin-top: 0.5rem;
    }

    .woocommerce table.wishlist_table td.product-add-to-cart {
        grid-area: panier;
        margin-top: 0.25rem;
    }

    .woocommerce table.wishlist_table td.product-add-to-cart a.button {
        width: 100%;
    }

    .woocommerce table.wishlist_table td.product-remove {
        position: absolute;
        top: 0.6rem;
        right: 0.6rem;
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .woocommerce table.wishlist_table a {
        transition: none;
    }
}
