/**
 * UruShop Frequently Bought Together
 *
 * Three placement variants for A/B testing:
 *   --inline         Right column, horizontal row (default)
 *   --below-gallery  Left column, vertical stack
 *   --below-product  Full width, large horizontal row
 *
 * @see mu-plugins/specs/urushop-fbt.spec.md
 */

/* --------------------------------------------------------------------------
   Container (shared base)
   -------------------------------------------------------------------------- */
.urushop-fbt {
    margin-top: 24px;
    padding: 20px;
    border: 1px solid #E5E7EB;
    border-radius: var(--urushop-radius-lg, 12px);
    background: var(--urushop-white, #FFFFFF);
}

/* --------------------------------------------------------------------------
   Title
   -------------------------------------------------------------------------- */
.urushop-fbt__title {
    font-family: var(--urushop-font-body, 'Inter', sans-serif);
    font-size: 16px;
    font-weight: 700;
    color: var(--urushop-deep-forest, #1B4332);
    margin: 0 0 16px 0;
    padding: 0;
    line-height: 1.3;
}

/* --------------------------------------------------------------------------
   Products Row
   -------------------------------------------------------------------------- */
.urushop-fbt__products {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 16px;
}

/* --------------------------------------------------------------------------
   Individual Product Card
   -------------------------------------------------------------------------- */
.urushop-fbt__product {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
    min-width: 0;
    padding: 0 8px;
}

/* Product info wrapper (used by below-gallery for horizontal layout) */
.urushop-fbt__product-info {
    display: contents; /* Invisible by default — children flow as direct children of product */
}

/* Product image */
.urushop-fbt__product img.urushop-fbt__image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--urushop-radius-sm, 6px);
    border: 1px solid #E5E7EB;
    display: block;
    margin-bottom: 8px;
}

.urushop-fbt__product a {
    text-decoration: none;
}

.urushop-fbt__product a:hover img.urushop-fbt__image {
    border-color: var(--urushop-mate-green, #00A86B);
}

/* --------------------------------------------------------------------------
   "+" Separator
   -------------------------------------------------------------------------- */
.urushop-fbt__separator {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 300;
    color: #9CA3AF;
    padding-top: 36px;
    flex-shrink: 0;
    width: 24px;
}

/* --------------------------------------------------------------------------
   Checkbox + Label
   -------------------------------------------------------------------------- */
.urushop-fbt__checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.3;
}

.urushop-fbt__checkbox input[type="checkbox"] {
    accent-color: var(--urushop-mate-green, #00A86B);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}

.urushop-fbt__checkbox input[type="checkbox"]:disabled {
    cursor: default;
}

/* --------------------------------------------------------------------------
   Product Name
   -------------------------------------------------------------------------- */
.urushop-fbt__name {
    font-size: 12px;
    font-weight: 500;
    color: var(--urushop-deep-forest, #1B4332);
    line-height: 1.3;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
}

a.urushop-fbt__name:hover {
    color: var(--urushop-mate-green, #00A86B);
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Price
   -------------------------------------------------------------------------- */
.urushop-fbt__price {
    font-size: 13px;
    font-weight: 600;
    color: var(--urushop-deep-forest, #1B4332);
    margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Footer — Total + Button
   -------------------------------------------------------------------------- */
.urushop-fbt__footer {
    border-top: 1px solid #F3F4F6;
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.urushop-fbt__total {
    font-size: 14px;
    color: var(--urushop-deep-forest, #1B4332);
    margin: 0;
}

.urushop-fbt__total strong {
    font-size: 16px;
    color: var(--urushop-mate-green, #00A86B);
}

/* --------------------------------------------------------------------------
   "Add all to basket" Button
   -------------------------------------------------------------------------- */
.urushop-fbt__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 20px;
    border: none;
    border-radius: var(--urushop-radius-sm, 6px);
    background: var(--urushop-mate-green, #00A86B);
    color: #FFFFFF;
    font-family: var(--urushop-font-body, 'Inter', sans-serif);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--urushop-transition-fast, 0.15s) ease;
}

.urushop-fbt__button:hover {
    background: #009960;
}

.urushop-fbt__button:disabled {
    background: #9CA3AF;
    cursor: not-allowed;
}

/* Loading state */
.urushop-fbt__button--loading {
    pointer-events: none;
    opacity: 0.7;
}

.urushop-fbt__button--loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: urushop-fbt-spin 0.6s linear infinite;
}

@keyframes urushop-fbt-spin {
    to { transform: rotate(360deg); }
}

/* Success state */
.urushop-fbt__button--success {
    background: #059669;
}

/* --------------------------------------------------------------------------
   Single companion variant (2 items total)
   -------------------------------------------------------------------------- */
.urushop-fbt--single .urushop-fbt__product {
    flex: 0 0 auto;
}

.urushop-fbt--single .urushop-fbt__products {
    justify-content: center;
}

/* --------------------------------------------------------------------------
   Unchecked product — dimmed
   -------------------------------------------------------------------------- */
.urushop-fbt__product--unchecked {
    opacity: 0.4;
}

.urushop-fbt__product--unchecked img.urushop-fbt__image {
    filter: grayscale(0.5);
}

/* ==========================================================================
   VARIANT A: Inline (right column, horizontal row)
   Default layout — products side by side with "+" separators.
   ========================================================================== */
.urushop-fbt--inline {
    /* Uses base styles as-is */
}

/* ==========================================================================
   VARIANT B: Below Gallery (left column, vertical stack)
   Narrower column — products stack vertically with image + info side by side.
   ========================================================================== */
.urushop-fbt--below-gallery {
    margin-top: 20px;
    padding: 16px;
}

.urushop-fbt--below-gallery .urushop-fbt__products {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.urushop-fbt--below-gallery .urushop-fbt__product {
    flex-direction: row;
    align-items: center;
    text-align: left;
    padding: 8px 0;
    gap: 10px;
}

.urushop-fbt--below-gallery .urushop-fbt__product img.urushop-fbt__image {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    margin-bottom: 0;
}

.urushop-fbt--below-gallery .urushop-fbt__product-info {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.urushop-fbt--below-gallery .urushop-fbt__separator {
    padding-top: 0;
    width: auto;
    font-size: 18px;
    padding: 2px 0;
    justify-content: flex-start;
    padding-left: 37px;
}

.urushop-fbt--below-gallery .urushop-fbt__name {
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    font-size: 13px;
}

.urushop-fbt--below-gallery .urushop-fbt__checkbox {
    margin-bottom: 0;
}

.urushop-fbt--below-gallery .urushop-fbt__price {
    font-size: 14px;
}

/* ==========================================================================
   VARIANT C: Below Product (full width, Amazon-style)
   CSS Grid: title spans top, products on left, total+button column on right.
   ========================================================================== */
.urushop-fbt--below-product {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto 1fr;
    gap: 0 24px;
    margin-top: 32px;
    margin-bottom: 8px;
    padding: 24px 0 16px;
    border: none;
    border-top: 1px solid #E5E7EB;
    border-radius: 0;
    background: transparent;
}

.urushop-fbt--below-product .urushop-fbt__title {
    grid-column: 1 / -1;
    font-size: 18px;
    margin-bottom: 16px;
}

/* Products row — left side */
.urushop-fbt--below-product .urushop-fbt__products {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
    margin-bottom: 0;
    gap: 0;
}

.urushop-fbt--below-product .urushop-fbt__product {
    flex: 0 0 auto;
    padding: 0 12px;
    max-width: 180px;
}

.urushop-fbt--below-product .urushop-fbt__product img.urushop-fbt__image {
    width: 150px;
    height: 150px;
    margin-bottom: 10px;
}

.urushop-fbt--below-product .urushop-fbt__separator {
    font-size: 28px;
    padding-top: 56px;
    width: 28px;
}

.urushop-fbt--below-product .urushop-fbt__name {
    max-width: 160px;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    font-size: 13px;
    line-height: 1.4;
}

.urushop-fbt--below-product .urushop-fbt__price {
    font-size: 15px;
}

/* Footer — right column, vertically centered */
.urushop-fbt--below-product .urushop-fbt__footer {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-top: none;
    border-left: 1px solid #F3F4F6;
    padding: 16px 0 16px 24px;
    min-width: 200px;
    gap: 12px;
}

.urushop-fbt--below-product .urushop-fbt__total {
    font-size: 15px;
}

.urushop-fbt--below-product .urushop-fbt__total strong {
    font-size: 20px;
    display: block;
    margin-top: 2px;
}

.urushop-fbt--below-product .urushop-fbt__button {
    width: 100%;
    padding: 12px 24px;
    font-size: 14px;
}

/* --------------------------------------------------------------------------
   Responsive — Mobile (all variants collapse to inline-style)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .urushop-fbt {
        margin-top: 16px;
        padding: 16px;
    }

    .urushop-fbt__product img.urushop-fbt__image {
        width: 80px;
        height: 80px;
    }

    .urushop-fbt__separator {
        font-size: 20px;
        padding-top: 28px;
        width: 16px;
    }

    .urushop-fbt__name {
        max-width: 80px;
        font-size: 11px;
    }

    .urushop-fbt__price {
        font-size: 12px;
    }

    /* Below-product reverts to single-column on mobile */
    .urushop-fbt--below-product {
        display: block;
    }

    .urushop-fbt--below-product .urushop-fbt__footer {
        border-left: none;
        border-top: 1px solid #F3F4F6;
        padding: 12px 0 0;
    }

    .urushop-fbt--below-product .urushop-fbt__products {
        margin-bottom: 16px;
    }
}
