/* =========================================================================
   Frozberries Smart Stock Alternatives — Frontend CSS
   v2.6.0 — Better visibility, full-width OOS badge, AJAX support
   Porto theme compatible with inline styles fallback
   ========================================================================= */

/* -------------------------------------------------------
   1. SHOP PAGE — Professional OOS Product Card
   Inspired by Woolworths, Wyman's, Coles premium patterns
   ------------------------------------------------------- */

/* Hide WooCommerce native "OUT OF STOCK" text on shop pages */
.fbsa-oos-product-wrap .stock.out-of-stock,
.fbsa-oos-product-wrap .outofstock-label,
.fbsa-oos-product-wrap .out-of-stock,
.fbsa-oos-product-wrap .froz-stock,
.fbsa-oos-product-wrap span.onsale+.out-of-stock {
    display: none !important;
}

/* Wrapper for OOS products on shop/archive pages */
.fbsa-oos-product-wrap {
    position: relative;
}

/* Make the image container position:relative so badge/link can be absolute inside it */
.fbsa-oos-product-wrap .product-image,
.fbsa-oos-product-wrap .product-inner .product-image,
.fbsa-oos-product-wrap .woocommerce-loop-product__link,
.fbsa-oos-product-wrap>a:first-child,
.fbsa-oos-product-wrap .product-loop-image,
.fbsa-oos-product-wrap .product-thumbnail,
.fbsa-oos-product-wrap .product-image-container,
.fbsa-oos-product-wrap .porto-product-thumbnail {
    position: relative !important;
    overflow: hidden !important;
}

/* Subtle image desaturation for OOS products — kept mild so product is visible */
.fbsa-oos-product-wrap img {
    filter: saturate(0.7) brightness(0.92) !important;
    transition: filter 0.3s ease !important;
}

.fbsa-oos-product-wrap:hover img {
    filter: saturate(0.85) brightness(0.96) !important;
}

/* ---- OOS Badge (full-width top banner for visibility) ---- */
.fbsa-oos-badge {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 15 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: #DC2626;
    color: #fff !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 6px 8px !important;
    line-height: 1 !important;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.fbsa-oos-badge svg {
    flex-shrink: 0;
    opacity: 0.9;
    width: 11px;
    height: 11px;
}

/* ---- Container for multiple alternative link bars ---- */
.fbsa-alt-link-bars {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 15 !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}

/* ---- Alternative Product Link Bar (bottom of image) ---- */
.fbsa-alt-link-bar {
    display: flex !important;
    align-items: center !important;
    gap: 6px;
    background: linear-gradient(135deg, #15803d 0%, #16a34a 100%) !important;
    color: #fff !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 7px 10px !important;
    text-decoration: none !important;
    transition: all 0.25s ease;
    line-height: 1.2;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Bars inside the stacked container must be relative (not absolute) */
.fbsa-alt-link-bars .fbsa-alt-link-bar {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    z-index: auto !important;
    box-shadow: none !important;
}

/* Standalone single bar (not inside container — legacy fallback) */
a.fbsa-alt-link-bar:only-child,
.fbsa-alt-link-bar:not(.fbsa-alt-link-bars *) {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 15 !important;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}

.fbsa-alt-link-bar:hover {
    background: linear-gradient(135deg, #166534 0%, #15803d 100%) !important;
    color: #fff !important;
    padding-left: 18px !important;
}

.fbsa-alt-link-label {
    color: rgba(255, 255, 255, 0.8) !important;
    font-weight: 500 !important;
    flex-shrink: 0;
    font-size: 10px !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fbsa-alt-link-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    font-weight: 700 !important;
    color: #fff !important;
    font-size: 12px !important;
}

.fbsa-alt-link-bar svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.fbsa-alt-link-bar:hover svg {
    transform: translateX(3px);
    opacity: 1;
}

/* ---- "See Alternative" / "View Options" button (replaces Add to Cart) ---- */
.fbsa-see-alternative-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #16a34a !important;
    color: #fff !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 10px 16px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: 0.3px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none !important;
    width: 100%;
    box-sizing: border-box;
}

.fbsa-see-alternative-btn:hover {
    background: #15803d !important;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(22, 163, 74, 0.3);
}

.fbsa-view-options-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent !important;
    color: #6b7280 !important;
    border: 2px solid #d1d5db !important;
    border-radius: 6px !important;
    padding: 9px 16px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: 0.3px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none !important;
    width: 100%;
    box-sizing: border-box;
}

.fbsa-view-options-btn:hover {
    border-color: #9ca3af !important;
    color: #374151 !important;
    background: #f9fafb !important;
}

/* -------------------------------------------------------
   2. SINGLE PRODUCT PAGE — OOS Block (in product summary)
   ------------------------------------------------------- */

/* The main container — sits where Add to Cart would be */
.fbsa-oos-block {
    margin: 20px 0 10px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Status bar — red bar showing "Currently Unavailable" */
.fbsa-status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.fbsa-status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #DC2626;
    flex-shrink: 0;
    animation: fbsa-pulse 2s ease-in-out infinite;
}

.fbsa-status-icon svg {
    stroke: #DC2626;
}

@keyframes fbsa-pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.85);
    }
}

.fbsa-status-text {
    font-size: 14px;
    font-weight: 700;
    color: #991b1b;
    flex: 1;
}

/* Notify Me link inside status bar */
.fbsa-notify-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid #DC2626;
    color: #DC2626;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1;
}

.fbsa-notify-link:hover {
    background: #DC2626;
    color: #fff;
}

.fbsa-notify-link svg {
    flex-shrink: 0;
}

/* -------------------------------------------------------
   3. INLINE ALTERNATIVES — Product rows
   ------------------------------------------------------- */

/* Section header */
.fbsa-inline-alts-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 0 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid #e5e7eb;
    color: #16a34a;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fbsa-inline-alts-header svg {
    flex-shrink: 0;
    stroke: #16a34a;
}

/* Individual alternative product row */
.fbsa-alt-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

.fbsa-alt-row:last-of-type {
    border-bottom: none;
}

.fbsa-alt-row:hover {
    background: #f9fafb;
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
    border-radius: 8px;
}

/* Product thumbnail */
.fbsa-alt-row-img {
    position: relative;
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    display: block;
    text-decoration: none;
}

.fbsa-alt-row-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* In stock dot label */
.fbsa-stock-dot {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(255, 255, 255, 0.95);
    color: #16a34a;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1.3;
    letter-spacing: 0.3px;
}

/* Product details column */
.fbsa-alt-row-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fbsa-alt-row-name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    text-decoration: none;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fbsa-alt-row-name:hover {
    color: #DC2626;
    text-decoration: none;
}

.fbsa-alt-row-meta {
    font-size: 12px;
    color: #9ca3af;
    font-weight: 500;
}

.fbsa-alt-row-price {
    font-size: 15px;
    font-weight: 700;
    color: #DC2626;
    line-height: 1.3;
}

.fbsa-alt-row-price del {
    color: #9ca3af;
    font-weight: 400;
    font-size: 12px;
}

.fbsa-alt-row-price ins {
    text-decoration: none;
}

/* Action column — Add to Cart button */
.fbsa-alt-row-action {
    flex-shrink: 0;
}

.fbsa-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #DC2626;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fbsa-add-btn:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.fbsa-add-btn:active {
    transform: translateY(0);
}

.fbsa-add-btn svg {
    flex-shrink: 0;
}

/* Adding state */
.fbsa-add-btn.fbsa-adding {
    opacity: 0.7;
    pointer-events: none;
}

/* Added state — green checkmark */
.fbsa-add-btn.fbsa-added {
    background: #16a34a;
    pointer-events: none;
}

/* Select Options for variable products */
.fbsa-select-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #374151;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fbsa-select-btn:hover {
    background: #1f2937;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
}

/* Browse link at bottom */
.fbsa-browse-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    padding: 12px 0 4px;
    transition: color 0.2s;
}

.fbsa-browse-link:hover {
    color: #DC2626;
    text-decoration: none;
}

.fbsa-browse-link svg {
    transition: transform 0.2s;
}

.fbsa-browse-link:hover svg {
    transform: translateX(3px);
}

/* No alternatives message */
.fbsa-no-alts-msg {
    padding: 12px 0;
    color: #6b7280;
    font-size: 14px;
}

.fbsa-no-alts-msg a {
    color: #DC2626;
    font-weight: 600;
    text-decoration: none;
}

.fbsa-no-alts-msg a:hover {
    text-decoration: underline;
}

/* -------------------------------------------------------
   4. TOAST / FEEDBACK
   ------------------------------------------------------- */

.fbsa-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #16a34a;
    color: #fff;
    padding: 14px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 99999;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fbsa-toast.fbsa-show {
    transform: translateY(0);
    opacity: 1;
}

.fbsa-toast a {
    color: #fff;
    text-decoration: underline;
    font-weight: 700;
    margin-left: 4px;
}

/* -------------------------------------------------------
   5. RESPONSIVE — Mobile-first adjustments
   ------------------------------------------------------- */

@media (max-width: 768px) {

    /* Status bar stacks on phone */
    .fbsa-status-bar {
        flex-wrap: wrap;
        padding: 10px 14px;
    }

    .fbsa-status-text {
        font-size: 13px;
    }

    .fbsa-notify-link {
        font-size: 11px;
        padding: 5px 12px;
    }

    /* Alt rows slightly more compact */
    .fbsa-alt-row {
        gap: 10px;
        padding: 12px 0;
    }

    .fbsa-alt-row-img {
        width: 64px;
        height: 64px;
        border-radius: 8px;
    }

    .fbsa-stock-dot {
        font-size: 8px;
        padding: 1px 4px;
    }

    .fbsa-alt-row-name {
        font-size: 13px;
    }

    .fbsa-alt-row-price {
        font-size: 14px;
    }

    /* Stack the Add to Cart below details on very small screens */
    .fbsa-alt-row {
        flex-wrap: wrap;
    }

    .fbsa-alt-row-action {
        width: 100%;
        padding-left: 74px;
        /* aligns with detail text, past the image */
    }

    .fbsa-add-btn,
    .fbsa-select-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
        font-size: 13px;
    }

    /* Toast bottom left on mobile */
    .fbsa-toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
        border-radius: 10px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .fbsa-alt-row-action {
        padding-left: 74px;
    }

    .fbsa-alt-row-img {
        width: 56px;
        height: 56px;
    }

    .fbsa-alt-row-action {
        padding-left: 66px;
    }
}

/* -------------------------------------------------------
   6. HIDE DEFAULT WOOCOMMERCE OOS ELEMENTS
   ------------------------------------------------------- */

/* Hide WooCommerce default out-of-stock text when our plugin handles it */
.fbsa-oos-block~.out-of-stock,
.fbsa-oos-block~.stock.out-of-stock {
    display: none !important;
}

/* -------------------------------------------------------
   7. ADMIN CUSTOMIZATION SUPPORT (CSS Variables)
   ------------------------------------------------------- */

:root {
    --fbsa-badge-color: #DC2626;
    --fbsa-green: #16a34a;
    --fbsa-red: #DC2626;
}
/* =========================================================================
   2.8.0 - Shop cards: sold-out products, Woolworths-style
   The red bar and green "TRY / OR" bars no longer cover the photo. The photo
   is greyed with a small corner tag; one in-stock alternative sits under the
   price, then a disabled "Out of stock" button keeps the card aligned.
   ========================================================================= */
.fbsa-oos-product-wrap .product-image img,
.fbsa-oos-product-wrap .product-image picture img {
    filter: grayscale(0.55) !important;
    opacity: 0.55 !important;
}
.fbsa-oos-product-wrap:hover .product-image img { filter: grayscale(0.3) !important; opacity: 0.75 !important; }

.fbsa-oos-pill {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    padding: 4px 9px;
    border-radius: 6px;
    background: #374151;
    color: #fff !important;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: .2px;
    pointer-events: none;
}
/* The sale label would sit under the tag; a sold-out product is not on offer to buy. */
.fbsa-oos-product-wrap .labels .onsale { display: none !important; }

.fbsa-oos-actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.fbsa-try {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    background: #f0fdf4;
    color: #14532d !important;
    text-decoration: none !important;
    line-height: 1.25;
    transition: border-color .15s, background .15s;
}
.fbsa-try:hover { border-color: #16a34a; background: #dcfce7; }
.fbsa-try-img { width: 40px !important; height: 40px !important; object-fit: contain; border-radius: 6px; background: #fff; flex-shrink: 0; }
.fbsa-try-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.fbsa-try-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #15803d; }
.fbsa-try-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fbsa-try-price { font-size: 13px; font-weight: 700; flex-shrink: 0; }
.fbsa-try-price .amount { color: #14532d !important; }

.fbsa-oos-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border-radius: 8px;
    background: #e5e7eb;
    color: #4b5563 !important;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    cursor: default;
}
.fbsa-oos-btn:hover { background: #d1d5db; color: #374151 !important; cursor: pointer; }

/* Old overlay pieces, in case a cached page still has them. */
.fbsa-oos-product-wrap .fbsa-alt-link-bars,
.fbsa-oos-product-wrap .fbsa-oos-badge { display: none !important; }
/* The card's own add-links ("See Alternative") duplicate the new actions. */
.fbsa-oos-product-wrap .fbsa-see-alternative-btn,
.fbsa-oos-product-wrap .fbsa-view-options-btn { display: none !important; }
/* The theme's own centred "OUT OF STOCK" label on the photo duplicates the corner tag. */
ul.products li.outofstock .product-image .stock.out-of-stock,
ul.products li.outofstock .product-image .out-of-stock { display: none !important; }
/* Theme rules stretch every card image to full width; keep the thumbnail small. */
ul.products li.product-col .fbsa-try img.fbsa-try-img {
    width: 40px !important; height: 40px !important; max-width: 40px !important; min-width: 40px !important; margin: 0 !important;
}
/* Try-instead card: label + price on the first line, the name gets two full
   lines beside the thumbnail (it was cut to "The Good A..." on narrow cards). */
.fbsa-try {
    display: grid !important;
    grid-template-columns: 40px 1fr auto;
    grid-template-areas: "img label price" "img name name";
    column-gap: 8px;
    row-gap: 2px;
    align-items: center;
}
.fbsa-try-img { grid-area: img; align-self: start; }
.fbsa-try-text { display: contents; }
.fbsa-try-label { grid-area: label; }
.fbsa-try-price { grid-area: price; font-size: 12px; }
.fbsa-try-name {
    grid-area: name;
    white-space: normal !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.3;
}
@media (max-width: 575px) {
    .fbsa-try { grid-template-columns: 32px 1fr auto; padding: 6px; }
    ul.products li.product-col .fbsa-try img.fbsa-try-img { width: 32px !important; height: 32px !important; min-width: 32px !important; max-width: 32px !important; }
    .fbsa-try-label { font-size: 9px; }
    .fbsa-try-name { font-size: 11.5px; }
    .fbsa-oos-btn { min-height: 36px; font-size: 13px; }
    .fbsa-oos-pill { top: 6px; left: 6px; font-size: 10px; padding: 3px 7px; }
}
