/* ================================================================
   LIGHTWEIGHT COMPARATOR — CSS 3.2.0
   Corrige : panneau latéral visible en permanence (état --closed)
   ================================================================ */

#lwc-sidebar,
#lwc-sidebar *,
#lwc-sidebar *::before,
#lwc-sidebar *::after,
.lwc-compare-page,
.lwc-compare-page *,
.lwc-compare-page *::before,
.lwc-compare-page *::after { box-sizing: border-box; }

/* ---------------------------------------------------------------
   1. BOUTONS « COMPAREZ ! »
   --------------------------------------------------------------- */
.lwc-inject { display: block; margin: 18px 0; }

.lwc-quickview-btn { display: block; margin: 14px 0; }

/*  Gabarit EXACT du bouton wishlist « Ajouter aux favoris » :
    mêmes 46px de haut, même padding, même rayon, même graisse. */
.lwc-btn-compare {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 22px;
    border: 1px solid #141a33;
    border-radius: 999px;
    background: #141a33;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    text-decoration: none;
    transition: background .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
    -webkit-tap-highlight-color: transparent;
}

.lwc-btn-compare:hover,
.lwc-btn-compare:focus-visible {
    background: #2b3563;
    border-color: #2b3563;
    color: #fff;
    box-shadow: 0 6px 18px rgba(20, 26, 51, .25);
    outline: none;
}

.lwc-btn-compare.lwc-added {
    border-color: #16a34a;
    background: #16a34a;
    color: #fff;
}

.lwc-btn-compare.lwc-added:hover { background: #128043; border-color: #128043; }


/* ---------------------------------------------------------------
   BOUTON « COMPARER » COMPACT (à côté du cœur favoris)
   Même gabarit que le cœur (40 px, cercle) mais en bleu : les deux
   se lisent comme une paire d'actions, jamais comme un doublon.
   --------------------------------------------------------------- */
.lwc-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    margin: 0;
    border: 1px solid #b9d3f5;
    border-radius: 50%;
    background: #fff;
    color: #0064d2;
    font-size: 0;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
    box-sizing: border-box;
    transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}

.lwc-icon-btn:hover,
.lwc-icon-btn:focus-visible,
.lwc-icon-btn.lwc-added {
    background: #0064d2;
    border-color: #0064d2;
    color: #fff;
}

.lwc-icon-btn:hover { transform: translateY(-1px); }
.lwc-icon-btn:focus-visible { outline: 3px solid rgba(0, 100, 210, .3); outline-offset: 2px; }

.lwc-icon-btn .lwc-scales-svg { width: 19px; height: 19px; display: block; }
.lwc-icon-btn.lwc-added .lwc-scales-svg { stroke-width: 2.1; }

/* Icône dans le bouton texte « Comparez ! » */
.lwc-btn-compare .lwc-btn-icon { display: inline-flex; align-items: center; }
.lwc-btn-compare .lwc-scales-svg { width: 18px; height: 18px; display: block; }

/* Libellé lisible par les lecteurs d'écran seulement */
.lwc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------------------------------------------------------------
   2. PANNEAU LATÉRAL — fermé par défaut
   --------------------------------------------------------------- */
/*  Pile de boutons flottants, de bas en haut :
      [bouton « UP » du thème] → [comparateur ⚖️] → [favoris ❤️]
    Le comparateur est donc à 92px (au-dessus du bouton UP). */
#lwc-sidebar {
    position: fixed;
    right: 24px;
    /* aligné sur --lwl-stack-base de la wishlist (bouton UP du thème) */
    bottom: 92px;
    z-index: 99997;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.45;
    color: #141a33;
}

/* Plus utilisé : c'est la wishlist qui se place AU-DESSUS du comparateur
   (classe .lwl-sidebar--stacked), et non l'inverse. */
#lwc-sidebar.lwc-sidebar--shifted { bottom: 92px; }

/*  GABARIT COMMUN : identique au bouton favoris (58 px, rayon 50 %, badge 22 px).
    Verrouillé pour qu'aucun thème ne puisse le rendre plus gros que le cœur. */
#lwc-sidebar .lwc-sidebar-toggle {
    width: 58px !important;
    height: 58px !important;
    min-width: 58px !important;
    max-width: 58px !important;
    min-height: 58px !important;
    max-height: 58px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    box-sizing: border-box !important;
}

#lwc-sidebar .lwc-sidebar-toggle svg {
    width: 26px !important;
    height: 26px !important;
    display: block;
}

#lwc-sidebar .lwc-toggle-count {
    top: -4px !important;
    right: -4px !important;
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    padding: 0 !important;
    line-height: 22px !important;
    font-size: 12px !important;
    box-sizing: border-box !important;
}

/* ⬇️ LA RÈGLE QUI MANQUAIT */
#lwc-sidebar.lwc-sidebar--closed .lwc-sidebar-inner { display: none !important; }

/* Sécurité : si le JS ne tourne pas, on n'affiche pas un panneau brut */
html:not(.lwc-js) #lwc-sidebar .lwc-sidebar-inner { display: none !important; }

.lwc-sidebar-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 58px;
    height: 58px;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #141a33, #2b3563);
    color: #fff;
    font-family: inherit;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(20, 26, 51, .38);
    transition: transform .18s ease, box-shadow .18s ease;
    -webkit-tap-highlight-color: transparent;
}

.lwc-sidebar-toggle:hover { transform: translateY(-2px) scale(1.04); }

.lwc-sidebar-toggle:focus-visible {
    outline: 3px solid rgba(20, 26, 51, .3);
    outline-offset: 3px;
}

.lwc-toggle-icon { pointer-events: none; line-height: 1; }

/* Le libellé texte n'a pas sa place dans un bouton rond */
.lwc-toggle-text { display: none; }

.lwc-toggle-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #e21a72;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    line-height: 22px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(20, 26, 51, .28);
    pointer-events: none;
}

/* Panneau */
.lwc-sidebar-inner {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: 340px;
    max-width: calc(100vw - 32px);
    max-height: min(70vh, 540px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e6e8ef;
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(20, 26, 51, .24);
    overflow: hidden;
    transform-origin: bottom right;
    animation: lwc-slide-in .2s ease;
}

@keyframes lwc-slide-in {
    from { opacity: 0; transform: translateY(10px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.lwc-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #eef0f5;
    background: #141a33;
    color: #fff;
}

.lwc-sidebar-header h3 {
    margin: 0;
    padding: 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.lwc-sidebar-header h3 span { color: #ff8ec0; }

.lwc-btn-clear {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 8px;
    background: transparent;
    color: #fff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.lwc-btn-clear:hover { background: rgba(255, 255, 255, .14); border-color: #fff; }

.lwc-sidebar-list {
    flex: 1 1 auto;
    margin: 0;
    padding: 8px;
    list-style: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.lwc-sidebar-list li { margin: 0; padding: 0; list-style: none; }

.lwc-sidebar-list:empty::after {
    content: "Aucun produit sélectionné";
    display: block;
    padding: 22px 12px;
    text-align: center;
    font-size: 13px;
    color: #8b90a3;
}

.lwc-sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
    transition: background .15s ease;
}

.lwc-sidebar-item:hover { background: #f5f6fa; }

.lwc-sidebar-item img {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 8px;
    object-fit: cover;
    background: #eef0f5;
    display: block;
}

.lwc-sidebar-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}

.lwc-sidebar-info strong {
    font-size: 13px;
    font-weight: 600;
    color: #141a33;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.lwc-btn-remove,
.lwc-card-remove {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #eef0f5;
    color: #6b7186;
    font-family: inherit;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.lwc-btn-remove:hover,
.lwc-card-remove:hover { background: #e21a72; color: #fff; }

.lwc-sidebar-footer {
    padding: 12px 16px 14px;
    border-top: 1px solid #eef0f5;
    background: #fafbfd;
}

.lwc-btn-go {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: 0;
    border-radius: 10px;
    background: #e21a72;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: background .15s ease, opacity .15s ease;
}

.lwc-btn-go:hover:not(:disabled) { background: #bd135e; }

.lwc-btn-go:disabled {
    background: #dfe2ea;
    color: #9aa0b4;
    cursor: not-allowed;
}

/* ---------------------------------------------------------------
   2 bis. TOAST
   --------------------------------------------------------------- */
#lwc-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translate(-50%, 20px);
    z-index: 99999;
    max-width: calc(100vw - 32px);
    padding: 12px 20px;
    border-radius: 999px;
    background: #141a33;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    box-shadow: 0 12px 30px rgba(20, 26, 51, .3);
}

#lwc-toast.lwc-toast--show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------
   3. PAGE COMPARATEUR
   --------------------------------------------------------------- */
.lwc-compare-page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 36px 20px 80px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #141a33;
}

.lwc-compare-header { margin-bottom: 28px; text-align: center; }

.lwc-compare-header h1 {
    margin: 0 0 8px;
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 800;
    line-height: 1.2;
    color: #141a33;
}

.lwc-compare-header p { margin: 0 0 20px; font-size: 15px; color: #6b7186; }

.lwc-search-bar { max-width: 640px; margin: 0 auto; }

.lwc-search-hint { margin: 0 0 10px; font-size: 13px; color: #6b7186; }

.lwc-aps-widget input[type="search"],
.lwc-aps-widget input[type="text"] {
    width: 100%;
    padding: 13px 18px;
    border: 1px solid #dfe2ea;
    border-radius: 999px;
    font-size: 15px;
    background: #fff;
}

.lwc-aps-widget input[type="search"]:focus,
.lwc-aps-widget input[type="text"]:focus {
    border-color: #e21a72;
    outline: none;
    box-shadow: 0 0 0 3px rgba(226, 26, 114, .12);
}

/* Grille des cartes produits */
.lwc-cards,
.lwc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.lwc-card,
.lwc-grid-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #fff;
    border: 1px solid #e6e8ef;
    border-radius: 16px;
    padding: 0 0 16px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(20, 26, 51, .05);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.lwc-card:hover,
.lwc-grid-card:hover {
    transform: translateY(-3px);
    border-color: #f5c2d9;
    box-shadow: 0 14px 34px rgba(20, 26, 51, .12);
}

.lwc-card-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 2px 8px rgba(20, 26, 51, .16);
}

.lwc-card-thumb,
.lwc-card-img {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #f5f6fa;
    overflow: hidden;
}

.lwc-card-thumb img,
.lwc-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease;
}

.lwc-card:hover .lwc-card-thumb img,
.lwc-grid-card:hover .lwc-card-img img { transform: scale(1.04); }

/* Les contenus textuels ont un padding latéral (l'image est full-bleed) */
.lwc-card > *:not(.lwc-card-thumb):not(.lwc-card-remove),
.lwc-grid-card > *:not(.lwc-card-img) { padding-left: 16px; padding-right: 16px; }

.lwc-card-title {
    margin: 4px 0 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    color: #141a33;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.lwc-card-price {
    font-size: 17px;
    font-weight: 800;
    color: #e21a72;
}

.lwc-card-price .lwc-price-old {
    margin-right: 6px;
    font-size: .82em;
    font-weight: 400;
    color: #9aa0b4;
    text-decoration: line-through;
}

.lwc-card-stock {
    align-self: flex-start;
    margin-left: 16px;
    padding: 3px 10px;
    border-radius: 999px;
    background: #e8f7ee;
    color: #128043;
    font-size: 12px;
    font-weight: 700;
}

.lwc-card-stock.lwc-out,
.lwc-card-stock.lwc-na { background: #fdeaea; color: #c02b2b; }
.lwc-card-stock.lwc-in { background: #e8f7ee; color: #128043; }

.lwc-card-rating { font-size: 13px; color: #6b7186; }
.lwc-stars { color: #f5a623; letter-spacing: 1px; }

.lwc-card-desc {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: #6b7186;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.lwc-card-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
}

.lwc-card-actions a,
.lwc-card-actions .lwc-btn-fiche,
.lwc-card-actions .lwc-btn-produit,
.lwc-card-actions .lwc-btn-article,
.lwc-card-actions .lwc-btn-amazon,
.lwc-card-actions .lwc-btn-product {
    display: block;
    padding: 10px 12px;
    border: 1px solid #dfe2ea;
    border-radius: 10px;
    background: #fff;
    color: #141a33;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    text-decoration: none !important;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.lwc-btn-fiche:hover { background: #141a33; border-color: #141a33; color: #fff !important; }

.lwc-btn-produit,
.lwc-btn-amazon {
    border-color: #e21a72 !important;
    background: #e21a72 !important;
    color: #fff !important;
}

.lwc-btn-produit:hover,
.lwc-btn-amazon:hover { background: #bd135e !important; border-color: #bd135e !important; }

/* États */
.lwc-empty {
    grid-column: 1 / -1;
    padding: 56px 24px;
    text-align: center;
    background: #fafbfd;
    border: 1px dashed #d8dce6;
    border-radius: 18px;
    color: #6b7186;
}

.lwc-empty-icon { font-size: 42px; line-height: 1; margin-bottom: 12px; }

.lwc-empty p { margin: 0 0 10px; font-size: 15px; }

.lwc-btn-shop {
    display: inline-block;
    margin-top: 10px;
    padding: 12px 26px;
    border-radius: 999px;
    background: #141a33;
    color: #fff !important;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none !important;
}

.lwc-btn-shop:hover { background: #2b3563; }

.lwc-loading,
.lwc-card-loading {
    grid-column: 1 / -1;
    padding: 40px 0;
    text-align: center;
    font-size: 15px;
    color: #6b7186;
}

/* ---------------------------------------------------------------
   4. TABLEAU COMPARATIF
   --------------------------------------------------------------- */
.lwc-table-section { margin-top: 10px; }

.lwc-table-section h2 {
    margin: 0 0 16px;
    font-size: 20px;
    font-weight: 800;
    color: #141a33;
}

.lwc-table-scroll {
    overflow-x: auto;
    border: 1px solid #e6e8ef;
    border-radius: 16px;
    background: #fff;
}

/*  table-layout: fixed → toutes les colonnes ont la même largeur :
    plus aucun décalage quand un titre de produit est long. */
.lwc-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 14px;
}

.lwc-table thead th {
    position: sticky;
    top: 0;
    padding: 14px 16px;
    background: #141a33;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    vertical-align: middle;
}

/*  Le 1er en-tête restait blanc (règle .lwc-table-label) → texte blanc
    sur fond blanc, illisible. On le repasse en navy. */
.lwc-table thead th.lwc-table-label,
.lwc-table thead th.lwc-table-label a {
    background: #1e2749 !important;
    color: #fff !important;
}

/*  Titres produits tronqués à 2 lignes : le tableau garde une hauteur
    régulière même avec des titres très longs. */
.lwc-table thead th a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-height: calc(1.35em * 2);
    line-height: 1.35;
    color: #fff;
    text-decoration: none;
}

.lwc-table thead th a:hover { text-decoration: underline; }

.lwc-table td {
    padding: 13px 16px;
    border-top: 1px solid #eef0f5;
    vertical-align: top;
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.lwc-table tbody tr:nth-child(even) td { background: #fafbfd; }

.lwc-table-label {
    width: 170px;
    min-width: 150px;
    background: #f5f6fa !important;
    font-weight: 700;
    color: #141a33;
}

.lwc-table-section-header td {
    padding: 12px 16px;
    background: #fdf0f6 !important;
    color: #bd135e;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.lwc-price-cell { font-weight: 800; color: #e21a72; }

.lwc-price-cell .lwc-price-old {
    margin-right: 6px;
    font-size: .85em;
    font-weight: 400;
    color: #9aa0b4;
    text-decoration: line-through;
}

/*  Une ligne de tableau par critère : les valeurs s'alignent
    horizontalement d'une colonne à l'autre. */
.lwc-spec-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lwc-spec-list li {
    margin: 0;
    padding: 0;
    font-size: 14px;
    line-height: 1.45;
    color: #4b5169;
}

.lwc-spec-list li + li {
    padding-top: 6px;
    border-top: 1px dashed #e8ebf2;
}

/* ancien rendu (conservé pour compatibilité) */
.lwc-specs-block { display: flex; flex-direction: column; gap: 6px; }

.lwc-spec-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed #eef0f5;
}

.lwc-spec-row:last-child { border-bottom: 0; padding-bottom: 0; }

.lwc-spec-title {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 700;
    color: #141a33;
}

.lwc-spec-title::after { content: " :"; }

.lwc-spec-value { flex: 1 1 100%; font-size: 13px; color: #4b5169; }

.lwc-na { color: #b8bdcc; }

/* ---------------------------------------------------------------
   5. RESPONSIVE
   --------------------------------------------------------------- */
@media (max-width: 782px) {
    #lwc-sidebar { right: 14px; bottom: 86px; }
    #lwc-sidebar.lwc-sidebar--shifted { bottom: 86px; }

    .lwc-sidebar-toggle { width: 52px; height: 52px; font-size: 20px; }

    .lwc-sidebar-inner {
        bottom: 66px;
        width: calc(100vw - 28px);
        max-width: 380px;
        max-height: 66vh;
    }

    .lwc-compare-page { padding: 26px 14px 60px; }

    .lwc-cards,
    .lwc-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }

    .lwc-card-title { font-size: 14px; }

    .lwc-table-label { width: 120px; min-width: 110px; }
}

@media (prefers-reduced-motion: reduce) {
    .lwc-card,
    .lwc-sidebar-toggle,
    .lwc-btn-compare,
    .lwc-sidebar-inner { transition: none !important; animation: none !important; }
}
