/* WooCommerce Comparateur de Produits — compare.css */

/* ── BOUTON COMPARAISON ──────────────────────────────────────────────────── */
.wc-compare-btn {
    display: inline-flex;
    align-items: center;
    gap: .4em;
    margin-top: .75em;
    padding: .5em 1em;
    background: #fff;
    border: 1.5px solid #177058;
    color: #177058;
    border-radius: 4px;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, color .2s;
    line-height: 1;
}
.wc-compare-btn:hover,
.wc-compare-btn.in-compare {
    background: #177058;
    color: #fff;
}
.wc-compare-btn svg { width: 1em; height: 1em; flex-shrink: 0; }

/* ── OVERLAY ─────────────────────────────────────────────────────────────── */
#wc-compare-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
}
#wc-compare-overlay.is-open { display: flex; }

#wc-compare-modal {
    background: #fff;
    border-radius: 8px;
    width: min(95vw, 1100px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

/* ── HEADER MODAL ────────────────────────────────────────────────────────── */
#wc-compare-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}
#wc-compare-modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #111;
}
.wc-compare-header-actions { display: flex; gap: .5rem; }
.wc-compare-header-actions button {
    padding: .4em .9em;
    border-radius: 4px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid currentColor;
    background: transparent;
    transition: background .15s, color .15s;
}
#wc-compare-clear-btn { color: #dc2626; }
#wc-compare-clear-btn:hover { background: #dc2626; color: #fff; }
#wc-compare-close-btn { color: #6b7280; }
#wc-compare-close-btn:hover { background: #6b7280; color: #fff; }

/* ── BODY MODAL ──────────────────────────────────────────────────────────── */
#wc-compare-modal-body {
    overflow-x: auto;
    overflow-y: auto;
    padding: 1rem 1.5rem 1.5rem;
    flex: 1;
}

/* ── TABLE COMPARAISON ───────────────────────────────────────────────────── */
.wc-compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.wc-compare-table thead th {
    padding: .75rem;
    text-align: center;
    vertical-align: top;
    border-bottom: 2px solid #e5e7eb;
    min-width: 200px;
}
.wc-compare-table thead th img {
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    display: block;
    margin: 0 auto .5rem;
}
.wc-compare-table thead th .wc-product-name {
    font-weight: 700;
    font-size: .95rem;
    line-height: 1.3;
    color: #111;
    display: block;
    margin-bottom: .25rem;
    text-decoration: none;
}
.wc-compare-table thead th .wc-product-name:hover { text-decoration: underline; }
.wc-compare-table thead th .wc-remove-from-compare {
    margin-top: .5rem;
    padding: .2em .6em;
    font-size: .75rem;
    color: #6b7280;
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.wc-compare-table thead th .wc-remove-from-compare:hover { color: #dc2626; border-color: #dc2626; }

.wc-compare-table tbody tr:nth-child(odd) { background: #f9fafb; }
.wc-compare-table tbody td,
.wc-compare-table tbody th {
    padding: .7rem .75rem;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}
.wc-compare-table tbody th {
    text-align: left;
    font-weight: 700;
    color: #374151;
    white-space: nowrap;
    background: #f3f4f6;
    min-width: 120px;
}
.wc-compare-table tbody td { text-align: center; color: #374151; }

/* Prix WooCommerce */
.wc-compare-price .price { font-weight: 700; color: #177058; font-size: 1rem; }
.wc-compare-price del    { color: #9ca3af; font-size: .875rem; }

/* Étoiles */
.wc-stars        { color: #f59e0b; font-size: 1rem; letter-spacing: .05em; }
.wc-rating-count { font-size: .75rem; color: #6b7280; }

/* États vide / chargement */
.wc-compare-empty,
.wc-compare-loading {
    text-align: center;
    padding: 3rem;
    color: #6b7280;
    font-size: 1rem;
}

/* Badge compteur (classe utilitaire — ex: dans le thème ou un menu) */
.wc-compare-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dc2626;
    color: #fff;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    min-width: 1.3em;
    height: 1.3em;
    padding: 0 .3em;
    margin-left: .3em;
    vertical-align: middle;
    line-height: 1;
}

/* ── WIDGET SIDEBAR ──────────────────────────────────────────────────────── */
.wc-compare-widget-body {
    font-size: .875rem;
}

.wc-compare-widget-list {
    list-style: none;
    margin: 0 0 .75rem;
    padding: 0;
}
.wc-compare-widget-list li {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem 0;
    border-bottom: 1px solid #e5e7eb;
}
.wc-compare-widget-list li:last-child { border-bottom: none; }

.wc-compare-widget-list img {
    object-fit: contain;
    border-radius: 3px;
    border: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.wc-widget-item-name {
    flex: 1;
    font-size: .8rem;
    line-height: 1.3;
    color: #111;
    text-decoration: none;
}
.wc-widget-item-name:hover { text-decoration: underline; }

.wc-widget-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 1rem;
    line-height: 1;
    padding: 0 .2rem;
    flex-shrink: 0;
    transition: color .15s;
}
.wc-widget-remove:hover { color: #dc2626; }

.wc-compare-widget-empty {
    color: #9ca3af;
    font-size: .8rem;
    margin: 0 0 .5rem;
}

/* Bouton d'ajout dans le widget (fiche produit uniquement) */
.wc-compare-widget-add {
    display: flex;
    width: 100%;
    justify-content: center;
    margin-top: 0;
    margin-bottom: .5rem;
}

/* Bouton "Voir la comparaison" */
.wc-compare-widget-open {
    display: inline-flex;
    align-items: center;
    gap: .4em;
    width: 100%;
    justify-content: center;
    padding: .5em 1em;
    background: #177058;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
}
.wc-compare-widget-open:hover { background: #013525; }

/* ── TOAST non-bloquant (remplace window.alert) ─────────────────────────── */
#wc-compare-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(1rem);
    background: rgba(0, 0, 0, .82);
    color: #fff;
    padding: .6em 1.2em;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    white-space: nowrap;
    z-index: 9999999;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
}
#wc-compare-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    #wc-compare-modal {
        border-radius: 0;
        max-height: 100dvh;
        width: 100vw;
    }
    .wc-compare-table thead th { min-width: 140px; }
    .wc-compare-table thead th img { width: 80px; height: 80px; }
}

/* ── BOUTON « + Comparer » OVERLAY SUR L'IMAGE PRODUIT ──────────────────── */

/* Span wrapper injecté par JS directement autour du <img> — indépendant du thème */
span.wc-compare-img-wrapper {
    display: block;
    position: relative;
    line-height: 0;        /* supprime l'espace fantôme sous l'img */
}
span.wc-compare-img-wrapper img {
    display: block;
    width: 100%;
    height: auto;
}

.wc-compare-card-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 10;
    padding: 8px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    white-space: nowrap;
    backdrop-filter: blur(2px);
    box-shadow: 0 1px 4px rgba(0,0,0,.35);
    transition: background .18s, opacity .18s;
    opacity: 0;
    pointer-events: none;
}
/* Révéler au survol du span wrapper — sélecteur fiable car injecté par nous */
span.wc-compare-img-wrapper:hover .wc-compare-card-btn,
span.wc-compare-img-wrapper:focus-within .wc-compare-card-btn {
    opacity: 1;
    pointer-events: auto;
}
/* Toujours visible sur mobile */
@media (hover: none) {
    .wc-compare-card-btn {
        opacity: 1;
        pointer-events: auto;
    }
}
.wc-compare-card-btn:hover {
    background: rgba(0, 0, 0, .75);
}
.wc-compare-card-btn.in-compare {
    background: rgba(22, 163, 74, .85);
}
.wc-compare-card-btn:disabled {
    background: rgba(107, 114, 128, .65);
    cursor: not-allowed;
}
