/* ==========================================================================
   Product Selection — Batterioutlet
   Styles the product Compare tray + modal and the Wishlist (list + header
   link). BEM prefix `bo-compare-*` / `bo-wishlist*`. Prefixed to avoid
   clashing with the Astra parent theme and WooCommerce defaults.

   Design tokens come from the global :root (see assets/header.css). Green /
   red / radii are NOT in the global :root, so they are restated locally on
   `.bo-compare-tray`, `.bo-compare-modal` and `.bo-wishlist` below as
   fallbacks in case a block is used in isolation.

   Overlay / panel feel mirrors assets/side-cart.css; buttons mirror the
   `.bo-card__buy` pill in assets/product-card.css.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   LOCAL TOKENS
   Restated on each top-level block so every descendant can reference them.
   The accent / text / bg / border tokens fall back to the global :root
   values but are duplicated here as literal fallbacks.
   --------------------------------------------------------------------------- */
.bo-compare-tray,
.bo-compare-modal,
.bo-wishlist,
.bo-wishlist-link {
    --bo-green: #17a34a;   /* success / in-stock */
    --bo-red: #dc2626;     /* remove / saved wishlist */
    --bo-radius: 12px;     /* panels / cards */
    --bo-radius-sm: 8px;   /* small controls */
    --bo-pill: 30px;       /* buttons */

    /* Local fallbacks mirroring the global :root */
    --bo-c-accent: var(--bo-accent, #F0C100);
    --bo-c-accent-dark: var(--bo-accent-dark, #B39002);
    --bo-c-text: var(--bo-text, #24262B);
    --bo-c-muted: var(--bo-text-muted, #666);
    --bo-c-bg: var(--bo-bg, #fff);
    --bo-c-bg-2: var(--bo-bg-secondary, #FAFAFA);
    --bo-c-border: var(--bo-border, #eee);

    font-family: var(--bo-font, "Cabinet Grotesque", "Helvetica Neue", Helvetica, Arial, sans-serif);
}

/* ==========================================================================
   COMPARE TRAY
   Centered floating pill near the bottom of the viewport, at ALL widths.
   Hidden until JS removes the `[hidden]` attribute.
   ========================================================================== */
.bo-compare-tray {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 24px;
    /* one below the header (var(--bo-header-z) is 9999) */
    z-index: 9998;
    width: auto;
    max-width: min(560px, calc(100% - 32px));
    background: var(--bo-c-bg, #fff);
    border: 1px solid var(--bo-c-border, #eee);
    border-radius: var(--bo-pill, 30px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
}

/* When JS hasn't revealed it yet, the [hidden] attribute keeps it out of flow */
.bo-compare-tray[hidden] {
    display: none;
}

.bo-compare-tray__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px 8px 20px;
}

/* ----- Label + count pill ----- */
.bo-compare-tray__label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--bo-c-text, #24262B);
}

.bo-compare-tray__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
    color: var(--bo-c-text, #24262B);
    background: var(--bo-c-accent, #F0C100);
    border-radius: var(--bo-pill, 30px);
}

/* ----- Actions cluster ----- */
.bo-compare-tray__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Ghost / text button to empty the tray */
.bo-compare-tray__clear {
    background: none;
    border: none;
    padding: 8px 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--bo-c-muted, #666);
    cursor: pointer;
    border-radius: var(--bo-radius-sm, 8px);
    transition: color 0.15s, background 0.15s;
    /* Parent theme resets */
    font-family: inherit;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: none;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.bo-compare-tray__clear:hover {
    color: var(--bo-c-text, #24262B);
    background: var(--bo-c-bg-2, #FAFAFA);
    box-shadow: none;
}

/* Solid yellow pill that opens the modal */
.bo-compare-tray__open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--bo-c-text, #24262B);
    background: var(--bo-c-accent, #F0C100);
    border: none;
    border-radius: var(--bo-pill, 30px);
    box-shadow: 0 2px 8px rgba(240, 193, 0, 0.3);
    cursor: pointer;
    transition: filter 0.15s, box-shadow 0.15s;
    /* Parent theme resets */
    font-family: inherit;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
}

.bo-compare-tray__open:hover {
    filter: brightness(1.08);
    color: var(--bo-c-text, #24262B);
    box-shadow: 0 3px 10px rgba(240, 193, 0, 0.38);
}

/* Disabled until the minimum number of products is selected */
.bo-compare-tray__open:disabled,
.bo-compare-tray__open.is-disabled {
    opacity: .5;
    cursor: not-allowed;
    filter: none;
    box-shadow: none;
}

.bo-compare-tray__open:disabled:hover,
.bo-compare-tray__open.is-disabled:hover {
    filter: none;
    box-shadow: none;
}

/* ==========================================================================
   COMPARE MODAL
   Centered overlay dialog. Hidden via the `[hidden]` attribute until JS opens
   it. Overlay dim + panel shadow mirror the side-cart drawer feel.
   ========================================================================== */
.bo-compare-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.bo-compare-modal[hidden] {
    display: none;
}

/* Dim backdrop — click target for closing */
.bo-compare-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

/* Panel — flat white card that scrolls internally */
.bo-compare-modal__panel {
    position: relative;
    width: 100%;
    max-width: min(1100px, 94vw);
    max-height: 90vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bo-c-bg, #fff);
    border-radius: var(--bo-radius, 12px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    padding: 24px;
}

/* Round close button, pinned top-right of the panel */
.bo-compare-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bo-c-bg-2, #FAFAFA);
    border: 1px solid var(--bo-c-border, #eee);
    border-radius: 50%;
    color: var(--bo-c-muted, #666);
    cursor: pointer;
    line-height: 0;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    /* Parent theme resets */
    font-family: inherit;
    letter-spacing: 0;
    text-transform: none;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.bo-compare-modal__close:hover {
    color: var(--bo-c-text, #24262B);
    border-color: #ddd;
    background: #fff;
    box-shadow: none;
}

.bo-compare-modal__close svg {
    width: 20px;
    height: 20px;
    display: block;
}

.bo-compare-modal__title {
    margin: 0 40px 18px 0;   /* clear the close button on the right */
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--bo-c-text, #24262B);
}

/* Body wraps the table and provides horizontal scroll on narrow screens */
.bo-compare-modal__body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ----- Loading skeleton (shown while the compare AJAX is in flight) ----- */
.bo-compare-skeleton__cols {
    display: flex;
    gap: 16px;
    margin: 0 0 18px;
}

.bo-compare-skeleton__col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.bo-compare-skeleton__img {
    width: 90px;
    height: 90px;
    border-radius: 8px;
}

.bo-compare-skeleton__line {
    width: 80%;
    height: 12px;
    border-radius: 6px;
}

.bo-compare-skeleton__line--sm {
    width: 50%;
}

.bo-compare-skeleton__row {
    display: block;
    height: 40px;
    border-radius: 6px;
    margin: 0 0 10px;
}

.bo-compare-skeleton__img,
.bo-compare-skeleton__line,
.bo-compare-skeleton__row {
    background: linear-gradient(90deg, #eee 25%, #e2e2e2 37%, #eee 63%);
    background-size: 400% 100%;
    animation: bo-skeleton-shimmer 1.4s ease infinite;
}

@keyframes bo-skeleton-shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: 0 0; }
}

/* Loading / error text fallbacks */
.bo-compare-modal__loading,
.bo-compare-modal__error {
    text-align: center;
    color: var(--bo-c-muted, #666);
    padding: 2rem 1rem;
}

@media (prefers-reduced-motion: reduce) {
    .bo-compare-skeleton__img,
    .bo-compare-skeleton__line,
    .bo-compare-skeleton__row {
        animation: none;
    }
}

/* ==========================================================================
   COMPARE TABLE
   One column per product; the left rail names each attribute row.
   ========================================================================== */
.bo-compare-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.bo-compare-table th,
.bo-compare-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--bo-c-border, #eee);
    vertical-align: middle;
}

/* Body cells (per-product values) are centered */
.bo-compare-table tbody td {
    text-align: center;
    font-size: 0.85rem;
    color: var(--bo-c-text, #24262B);
}

/* Optional zebra striping — very light */
.bo-compare-table tbody tr:nth-child(even) td {
    background: rgba(250, 250, 250, 0.6);
}

/* ----- Left rail: attribute labels ----- */
.bo-compare-table__rowhead {
    width: 140px;
    text-align: left;
    font-weight: 600;
    color: var(--bo-c-muted, #666);
    background: var(--bo-c-bg, #fff);
    font-size: 0.82rem;
}

/* ----- Product column header cells ----- */
.bo-compare-table__head td.bo-compare-table__prod {
    position: relative;
    text-align: center;
    vertical-align: top;
    padding-top: 16px;
}

/* Small round remove (✕) in the top-right of each product header cell */
.bo-compare-table__remove {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--bo-c-muted, #666);
    cursor: pointer;
    line-height: 0;
    transition: color 0.15s, background 0.15s;
    /* Parent theme resets */
    font-family: inherit;
    font-size: 1.5rem;
    letter-spacing: 0;
    text-transform: none;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.bo-compare-table__remove:hover {
    color: var(--bo-red, #dc2626);
    background: #fef2f2;
    box-shadow: none;
}

/* Image + name link stacked in the header cell */
.bo-compare-table__prodlink {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: inherit;
    text-decoration: none;
}

.bo-compare-table__prodlink img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    display: block;
}

.bo-compare-table__name {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--bo-c-text, #24262B);
    /* 2-line clamp */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bo-compare-table__prodlink:hover .bo-compare-table__name {
    color: var(--bo-c-accent-dark, #B39002);
}

/* Price row under the product name — bold accent */
.bo-compare-table__price {
    display: block;
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--bo-c-accent-dark, #B39002);
    white-space: nowrap;
}

/* ----- Actions row: a buy pill per product ----- */
.bo-compare-table__actions td {
    padding-top: 14px;
    padding-bottom: 14px;
}

/* Reuse the card select-button look; provide a solid-yellow fallback here in
   case product-card.css isn't present on the page the modal renders on. */
.bo-compare-table .bo-card__buy--select {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--bo-c-text, #24262B);
    background: var(--bo-c-accent, #F0C100);
    border: none;
    border-radius: var(--bo-pill, 30px);
    box-shadow: 0 2px 8px rgba(240, 193, 0, 0.3);
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s, box-shadow 0.15s;
    /* Parent theme resets */
    font-family: inherit;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
}

.bo-compare-table .bo-card__buy--select:hover {
    filter: brightness(1.08);
    color: var(--bo-c-text, #24262B);
    box-shadow: 0 3px 10px rgba(240, 193, 0, 0.38);
}

/* ==========================================================================
   WISHLIST
   Container + empty state + product grid. The cards inside `.products` are
   styled by product-card.css; here we only own the grid layout and shell.
   ========================================================================== */
.bo-wishlist {
    max-width: var(--bo-container-width, 1200px);
    margin: 0 auto;
    padding: 2rem 0;
    font-family: var(--bo-font, "Cabinet Grotesque", "Helvetica Neue", Helvetica, Arial, sans-serif);
}

/* Empty state — centered muted message with generous breathing room */
.bo-wishlist__empty {
    text-align: center;
    color: var(--bo-c-muted, #666);
    font-size: 0.95rem;
    padding: 4rem 1rem;
    line-height: 1.5;
}

/* Grid of saved products (a `ul.products`) */
.bo-wishlist__items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* WooCommerce/Astra add clearfix pseudo-elements to ul.products — kill them
   so the grid gaps stay clean. */
.bo-wishlist__items::before,
.bo-wishlist__items::after {
    content: none;
}

/* ----- Wishlist loading skeleton (card-shaped placeholders in the grid) ----- */
.bo-wishlist-skel {
    list-style: none;
    background: #fff;
    border: 1px solid var(--bo-c-border, #eee);
    border-radius: 10px;
    overflow: hidden;
}

.bo-wishlist-skel__img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
}

.bo-wishlist-skel__body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px 16px;
}

.bo-wishlist-skel__line {
    height: 12px;
    border-radius: 6px;
}

.bo-wishlist-skel__line--title {
    height: 16px;
    width: 90%;
}

.bo-wishlist-skel__line--sm {
    width: 50%;
}

.bo-wishlist-skel__btn {
    height: 44px;
    border-radius: var(--bo-pill, 30px);
    margin-top: 6px;
}

.bo-wishlist-skel__img,
.bo-wishlist-skel__line,
.bo-wishlist-skel__btn {
    background: linear-gradient(90deg, #eee 25%, #e2e2e2 37%, #eee 63%);
    background-size: 400% 100%;
    animation: bo-skeleton-shimmer 1.4s ease infinite;
}

@media (prefers-reduced-motion: reduce) {
    .bo-wishlist-skel__img,
    .bo-wishlist-skel__line,
    .bo-wishlist-skel__btn {
        animation: none;
    }
}

/* ==========================================================================
   HEADER WISHLIST LINK
   Icon button matching the header account/cart icon sizing, with a small red
   count dot in the top-right corner.
   ========================================================================== */
.bo-wishlist-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--bo-c-text, #24262B);
    text-decoration: none;
    border-radius: 10px;
    transition: background-color 0.15s, color 0.15s;
}

.bo-wishlist-link:hover {
    background: var(--bo-c-bg-2, #FAFAFA);
    color: var(--bo-c-accent-dark, #B39002);
}

.bo-wishlist-link svg {
    flex-shrink: 0;
    pointer-events: none;
}

/* Red count dot, pinned top-right */
.bo-wishlist-link__count {
    position: absolute;
    top: -2px;
    right: -2px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    background: var(--bo-red, #dc2626);
    border-radius: 50%;
}

/* Hidden when the wishlist is empty */
.bo-wishlist-link__count[hidden] {
    display: none;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 767px) {

    /* The compare tray is a centered floating pill at every width now (see the
       base rules); on phones it just narrows via its max-width. */

    /* ----- Modal: leave breathing room on the sides ----- */
    .bo-compare-modal {
        padding: 16px;
    }

    .bo-compare-modal__panel {
        max-width: 100%;
        max-height: calc(100vh - 32px);
        border-radius: var(--bo-radius, 12px);
        padding: 20px 16px;
    }

    /* ----- Compare table: keep a usable product-column width and let the
       modal body scroll horizontally ----- */
    .bo-compare-table {
        min-width: 480px;
    }

    .bo-compare-table__rowhead {
        width: 110px;
        position: sticky;
        left: 0;
        z-index: 1;
        background: var(--bo-c-bg, #fff);
    }

    .bo-compare-table__head td.bo-compare-table__prod,
    .bo-compare-table tbody td {
        min-width: 130px;
    }

    .bo-compare-table__prodlink img {
        width: 70px;
        height: 70px;
    }

    /* ----- Wishlist: 2-up grid on phones ----- */
    .bo-wishlist__items {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* ==========================================================================
   REDUCED MOTION
   Respect the user's preference — drop slide/transition animation.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .bo-compare-tray,
    .bo-compare-tray__clear,
    .bo-compare-tray__open,
    .bo-compare-modal__close,
    .bo-compare-table__remove,
    .bo-compare-table .bo-card__buy--select,
    .bo-wishlist-link {
        transition: none;
    }
}
