/**
 * Byamber Wishlist — persistent storage
 *
 * Covers only styles NOT already in main.css.
 * main.css owns: .ba-product-card-action.is-saved, .ba-wishlist-dialog,
 * .ba-wishlist-content/.ba-wishlist-head/.ba-wishlist-empty, .ba-saved-products,
 * .ba-saved-product, .ba-storefront-modal, .ba-storefront-modal-close.
 *
 * This file adds:
 *  1. Header heart count badge — active filled state
 *  2. Single product page wishlist button (.ba-wishlist-single-btn)
 *  3. Wishlist page full layout (.ba-wishlist-page-*)
 *  4. Drawer additions: sync note, share row, browse button
 *  5. Responsive overrides
 *
 * @package Byamber
 * @since   6.0.29
 */

/* ==========================================================================
   1. HEADER HEART — filled + count badge when items exist
   ========================================================================== */

/* Filled heart when the user has saved items (is-saved mirrors card button) */
.ba-local-wishlist-link.is-saved .ba-action-icon svg,
.ba-local-wishlist-link[data-has-items] .ba-action-icon svg {
    fill: var(--ba-primary, #a563e5);
    stroke: var(--ba-primary, #a563e5);
}

/* Badge that storefront.js populates */
.ba-local-wishlist-link [data-ba-heart-count] {
    position: absolute;
    top: -6px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--ba-primary, #a563e5);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
    pointer-events: none;
    /* Smooth count changes */
    transition: transform .2s cubic-bezier(.34, 1.56, .64, 1);
}

.ba-local-wishlist-link [data-ba-heart-count][hidden] {
    display: none !important;
}

/* Make the header heart link position:relative so the badge places correctly */
.ba-local-wishlist-link {
    position: relative;
}

/* ==========================================================================
   2. DRAWER ADDITIONS (extends main.css .ba-wishlist-*)
   ========================================================================== */

/* "Saved to your account" note — only shown for logged-in users */
.ba-wishlist-sync-note {
    display: inline-flex;
    align-items: center;
    gap: .38rem;
    margin: .35rem 0 0;
    padding: .32rem .7rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--ba-primary, #a563e5) 10%, transparent);
    color: var(--ba-primary, #a563e5);
    font-size: .75rem;
    font-weight: 700;
}

.ba-wishlist-sync-note::before {
    content: "✓";
    font-size: .72rem;
}

/* Share / page link row at the bottom of the drawer */
.ba-wishlist-share {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: 1.1rem;
    padding: .75rem 1rem;
    border-radius: 14px;
    background: var(--ba-surface, #fffdfc);
    border: 1px solid var(--ba-border, #eadfd4);
    font-size: .82rem;
    color: var(--ba-muted, #796b64);
}

.ba-wishlist-page-link {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-weight: 700;
    font-size: .82rem;
    color: var(--ba-primary, #a563e5);
    text-decoration: none;
    white-space: nowrap;
}

.ba-wishlist-page-link::after {
    content: "→";
}

.ba-wishlist-page-link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Browse button inside the empty-state panel */
.ba-wishlist-browse-btn {
    margin-top: 1.25rem;
    font-size: .9rem;
}

/* ==========================================================================
   3. SINGLE PRODUCT PAGE — wishlist button
   ========================================================================== */

.ba-wishlist-single-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    /* Sit next to / below the WhatsApp button — full width like it */
    width: 100%;
    margin: .6rem 0 0;
    padding: .9rem 1.35rem;
    border: 1.5px solid var(--ba-border, #eadfd4);
    border-radius: 999px;
    background: transparent;
    color: var(--ba-text, #000);
    font: inherit;
    font-size: .95rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, color .18s ease,
                box-shadow .18s ease, transform .18s ease;
}

.ba-wishlist-single-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: fill .18s ease, stroke .18s ease;
}

.ba-wishlist-single-btn:hover,
.ba-wishlist-single-btn:focus-visible {
    border-color: var(--ba-primary, #a563e5);
    background: color-mix(in srgb, var(--ba-primary, #a563e5) 8%, transparent);
    color: var(--ba-primary, #a563e5);
    box-shadow: 0 8px 22px color-mix(in srgb, var(--ba-primary, #a563e5) 18%, transparent);
    transform: translateY(-1px);
    outline: none;
}

/* Saved / active state */
.ba-wishlist-single-btn.is-saved {
    border-color: var(--ba-primary, #a563e5);
    background: color-mix(in srgb, var(--ba-primary, #a563e5) 10%, transparent);
    color: var(--ba-primary, #a563e5);
}

.ba-wishlist-single-btn.is-saved svg {
    fill: var(--ba-primary, #a563e5);
    stroke: var(--ba-primary, #a563e5);
}

/* ==========================================================================
   4. WISHLIST FULL PAGE (page-wishlist.php)
   ========================================================================== */

/* ── Page wrapper ── */
.ba-wishlist-page {
    padding: 3rem 0 5rem;
}

/* ── Page header ── */
.ba-wishlist-page-header {
    margin-bottom: 2.4rem;
}

.ba-wishlist-page-header .ba-eyebrow {
    margin: 0 0 .4rem;
    color: var(--ba-primary, #a563e5);
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.ba-wishlist-page-header h1 {
    margin: 0 0 .5rem;
    font-size: clamp(2rem, 5vw, 3.6rem);
    line-height: 1.05;
    letter-spacing: -.04em;
}

.ba-wishlist-page-header p {
    color: var(--ba-muted, #796b64);
    margin: 0;
}

/* ── Toolbar (count + share URL) ── */
.ba-wishlist-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    padding: .9rem 1.1rem;
    margin-bottom: 2rem;
    border-radius: 16px;
    background: var(--ba-surface, #fffdfc);
    border: 1px solid var(--ba-border, #eadfd4);
    box-shadow: var(--ba-shadow-card, 0 14px 42px rgba(31,26,23,.08));
}

.ba-wishlist-count {
    font-size: .88rem;
    font-weight: 700;
    color: var(--ba-muted, #796b64);
}

.ba-wishlist-count strong {
    color: var(--ba-text, #000);
    font-size: 1rem;
}

/* Share URL input group */
.ba-wishlist-share-url {
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
}

.ba-wishlist-share-label {
    font-size: .82rem;
    font-weight: 700;
    color: var(--ba-muted, #796b64);
    white-space: nowrap;
}

.ba-wishlist-share-input {
    width: min(280px, 100%);
    padding: .42rem .75rem;
    border: 1px solid var(--ba-border, #eadfd4);
    border-radius: 999px;
    background: var(--ba-bg, #fbf7f2);
    font: inherit;
    font-size: .82rem;
    color: var(--ba-text, #000);
    cursor: text;
    /* Read-only styling */
    caret-color: transparent;
    user-select: all;
}

.ba-wishlist-share-input:focus {
    outline: 2px solid var(--ba-primary, #a563e5);
    outline-offset: 2px;
}

.ba-wishlist-copy-btn {
    padding: .42rem .9rem;
    border: 1px solid var(--ba-primary, #a563e5);
    border-radius: 999px;
    background: transparent;
    color: var(--ba-primary, #a563e5);
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease;
}

.ba-wishlist-copy-btn:hover,
.ba-wishlist-copy-btn.copied {
    background: var(--ba-primary, #a563e5);
    color: #fff;
}

/* ── Product grid ── */
.ba-wishlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.4rem;
}

/* Individual wishlist page product card */
.ba-wishlist-card {
    position: relative;
    background: var(--ba-surface, #fffdfc);
    border: 1px solid var(--ba-border, #eadfd4);
    border-radius: 24px;
    padding: 1rem;
    box-shadow: var(--ba-shadow-card, 0 14px 42px rgba(31,26,23,.08));
    transition: transform .2s ease, box-shadow .2s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ba-wishlist-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--ba-shadow-hover, 0 24px 74px rgba(31,26,23,.14));
}

/* Remove button — top-right corner */
.ba-wishlist-card-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--ba-border, #eadfd4);
    border-radius: 999px;
    background: rgba(255, 253, 252, .9);
    color: var(--ba-muted, #796b64);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.ba-wishlist-card-remove:hover {
    background: #fee;
    color: #c0392b;
    border-color: #f5c6cb;
}

/* Product image */
.ba-wishlist-card-image {
    display: block;
    aspect-ratio: 4 / 5;
    border-radius: 18px;
    overflow: hidden;
    background: #f7eee8;
    margin-bottom: .9rem;
}

.ba-wishlist-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ba-wishlist-card-image-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 3rem;
    color: var(--ba-muted, #796b64);
    opacity: .35;
}

/* Product copy */
.ba-wishlist-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.ba-wishlist-card-category {
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--ba-muted, #796b64);
}

.ba-wishlist-card-title {
    margin: 0 0 .1rem;
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--ba-text, #000);
}

.ba-wishlist-card-title a {
    color: inherit;
    text-decoration: none;
}

.ba-wishlist-card-title a:hover {
    color: var(--ba-primary, #a563e5);
}

.ba-wishlist-card-price {
    font-size: .95rem;
    font-weight: 800;
    color: var(--ba-primary-dark, #1d216b);
    margin: 0;
}

/* CTA button — pinned to the bottom of the card */
.ba-wishlist-card-cta {
    margin-top: auto;
    padding-top: .9rem;
    display: flex;
    gap: .5rem;
}

.ba-wishlist-card-cta .ba-button {
    flex: 1;
    font-size: .85rem;
    padding: .7rem .9rem;
}

/* ── Empty state — page ── */
.ba-wishlist-page-empty {
    text-align: center;
    padding: 5rem 1rem;
    max-width: 500px;
    margin: 0 auto;
}

.ba-wishlist-page-empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.25rem;
    opacity: .25;
    color: var(--ba-primary, #a563e5);
}

.ba-wishlist-page-empty h2 {
    font-size: clamp(1.65rem, 4vw, 2.2rem);
    margin-bottom: .5rem;
}

.ba-wishlist-page-empty p {
    color: var(--ba-muted, #796b64);
    margin-bottom: 1.5rem;
}

/* ── Guest notice on page ── */
.ba-wishlist-guest-notice {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .9rem 1.1rem;
    margin-bottom: 1.75rem;
    border-radius: 14px;
    background: color-mix(in srgb, #f9c74f 12%, transparent);
    border: 1px solid color-mix(in srgb, #f9c74f 40%, transparent);
    font-size: .88rem;
    color: var(--ba-text, #000);
}

.ba-wishlist-guest-notice-icon {
    flex-shrink: 0;
    font-size: 1.15rem;
    line-height: 1.4;
}

.ba-wishlist-guest-notice a {
    font-weight: 700;
    color: var(--ba-primary-dark, #1d216b);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ── Loading state on page ── */
.ba-wishlist-page-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding: 4rem;
    color: var(--ba-muted, #796b64);
    font-size: .92rem;
}

.ba-wishlist-page-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid rgba(165, 99, 229, .2);
    border-top-color: var(--ba-primary, #a563e5);
    border-radius: 50%;
    animation: ba-wishlist-spin .65s linear infinite;
    flex-shrink: 0;
}

@keyframes ba-wishlist-spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   5. RESPONSIVE
   ========================================================================== */

@media (max-width: 767px) {
    /* Toolbar stacks vertically on mobile */
    .ba-wishlist-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .ba-wishlist-share-url {
        width: 100%;
    }

    .ba-wishlist-share-input {
        flex: 1;
        width: auto;
        min-width: 0;
    }

    /* Single product button full-width already — just tighten text size */
    .ba-wishlist-single-btn {
        font-size: .88rem;
    }

    /* Page grid: 2 cols on mobile */
    .ba-wishlist-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .ba-wishlist-card-cta {
        flex-direction: column;
    }

    .ba-wishlist-card-cta .ba-button {
        width: 100%;
    }
}

@media (max-width: 420px) {
    /* Narrow phones: single column */
    .ba-wishlist-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   6. REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .ba-wishlist-card,
    .ba-wishlist-single-btn,
    .ba-wishlist-card-remove,
    .ba-wishlist-copy-btn {
        transition: none !important;
    }

    .ba-wishlist-page-spinner {
        animation: none;
        border-top-color: var(--ba-primary, #a563e5);
    }
}
