/**
 * Frequently Bought Together - Frontend Styles
 * Matches vivaia.com design
 */

/* Container */
.vivaia-fbt-container {
    position: relative;
    padding: 25px 20px;
    background: #fff;
    border: none;
    margin: 20px 0;
    box-sizing: border-box;
}

/* Header */
.vivaia-fbt-header {
    text-align: left;
    margin-bottom: 20px;
}

.vivaia-fbt-title {
    font-size: 18px;
    font-weight: 600;
    color: #000;
    margin: 0 0 5px 0;
    line-height: 1.3;
}

.vivaia-fbt-subtitle {
    font-size: 12px;
    color: #888;
    margin: 0;
}

/* Products Row */
.vivaia-fbt-products {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 10px;
}

/* Individual Product */
.vivaia-fbt-product {
    flex: 0 0 auto;
    width: 120px;
    text-align: center;
    position: relative;
    background: #fff;
    padding: 5px;
    border: 1px solid #e5e5e5;
}

.vivaia-fbt-product.vivaia-fbt-main {
    border-color: #e5e5e5;
}

/* Checkbox */
.vivaia-fbt-product-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0;
}

.vivaia-fbt-product-checkbox input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    margin: 0;
    accent-color: #000;
    border: 1px solid #ccc;
}

.vivaia-fbt-product-checkbox input[type="checkbox"]:disabled {
    cursor: default;
    opacity: 1;
}

.vivaia-fbt-product-checkbox label {
    font-size: 10px;
    font-weight: 600;
    color: #333;
    margin: 0;
    cursor: pointer;
}

.vivaia-fbt-main-label {
    background: #000;
    color: #fff !important;
    padding: 1px 5px;
    font-size: 9px !important;
    text-transform: capitalize;
    margin-left: 6px !important;
    font-weight: 400 !important;
}

/* Product Image */
.vivaia-fbt-product-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    margin: 22px 0 8px;
    overflow: hidden;
    background: #f8f8f8;
}

.vivaia-fbt-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Product Info */
.vivaia-fbt-product-info {
    min-height: 50px;
}

.vivaia-fbt-product-name {
    font-size: 11px;
    font-weight: 400;
    color: #333;
    margin: 0 0 5px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.vivaia-fbt-product-price {
    font-size: 13px;
    font-weight: 600;
    color: #000;
    display: block;
    margin-bottom: 6px;
    line-height: 1.4;
}

.vivaia-fbt-product-price del {
    color: #999;
    font-weight: 400;
    font-size: 12px;
    text-decoration: line-through;
    display: block;
}

.vivaia-fbt-product-price ins {
    text-decoration: none;
    color: #c41230;
    display: block;
}

/* Plus Separator */
.vivaia-fbt-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 300;
    color: #999;
    padding: 0 8px;
    flex-shrink: 0;
    margin-top: 50px;
}

/* Variation Dropdown */
.vivaia-fbt-variation-dropdown,
.vivaia-fbt-variation-sync {
    margin-top: 4px;
}

.fbt-variation-select,
.fbt-main-variation-display {
    width: 100%;
    padding: 5px 20px 5px 8px;
    font-size: 11px;
    border: 1px solid #ddd;
    border-radius: 0;
    background: #fff;
    color: #333;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23666' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}

.fbt-main-variation-display {
    background-color: #fff;
    cursor: default;
}

.fbt-variation-select:focus {
    outline: none;
    border-color: #999;
}

/* Footer */
.vivaia-fbt-footer {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-top: 20px;
    padding-top: 0;
    border-top: none;
    flex-wrap: wrap;
    gap: 20px;
}

.vivaia-fbt-click-all {
    flex: 0 0 auto;
}

.vivaia-fbt-click-all label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    gap: 6px;
}

.vivaia-fbt-click-all input[type="checkbox"] {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: #000;
}

.fbt-click-all-text {
    font-weight: 500;
    color: #000;
}

.vivaia-fbt-selected-count {
    color: #888;
    font-weight: 400;
}

.vivaia-fbt-subtotal {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
}

.vivaia-fbt-subtotal-label {
    color: #000;
    margin-right: 5px;
    font-weight: 600;
}

.vivaia-fbt-subtotal-amount {
    color: #000;
}

/* Buy Button - Match site's Add to Cart style */
.vivaia-fbt-buy-button {
    display: inline-block;
    width: auto;
    background: #000;
    color: #fff;
    border: 0;
    font-size: calc(1.4rem * var(--rio-typo-ratio, 1));
    font-weight: 600;
    line-height: 4.5rem;
    padding: 0 3.5em;
    vertical-align: middle;
    border-radius: 3px;
    text-transform: none;
    cursor: pointer;
    transition: background 0.3s ease, color 0.3s ease;
    flex: 0 0 auto;
}

.vivaia-fbt-buy-button:hover {
    color: #fff !important;
    background-color: #804C1A !important;
}

.vivaia-fbt-buy-button:disabled,
.vivaia-fbt-buy-button.loading {
    background: #ccc;
    cursor: not-allowed;
}

.vivaia-fbt-buy-button.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    margin-left: 8px;
    animation: fbt-spin 0.8s linear infinite;
    vertical-align: middle;
}

/* Loading Overlay */
.vivaia-fbt-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.vivaia-fbt-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #eee;
    border-top-color: #000;
    border-radius: 50%;
    animation: fbt-spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .vivaia-fbt-container {
        padding: 20px 15px;
        margin: 15px 0;
    }

    .vivaia-fbt-title {
        font-size: 16px;
    }

    .vivaia-fbt-products {
        justify-content: flex-start;
        gap: 0;
        padding-bottom: 10px;
        margin: 0 -15px;
        padding-left: 15px;
        padding-right: 15px;
    }

    .vivaia-fbt-product {
        width: 110px;
        padding: 5px;
    }

    .vivaia-fbt-product-image {
        margin: 18px 0 6px;
    }

    .vivaia-fbt-separator {
        font-size: 18px;
        padding: 0 5px;
        margin-top: 40px;
    }

    .vivaia-fbt-product-price {
        font-size: 12px;
    }

    .vivaia-fbt-footer {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
        gap: 12px;
    }

    .vivaia-fbt-click-all label {
        justify-content: flex-start;
    }

    .vivaia-fbt-subtotal {
        font-size: 14px;
    }

    .vivaia-fbt-buy-button {
        width: 100%;
        padding: 0 2em;
    }
}

@media (max-width: 480px) {
    .vivaia-fbt-product {
        width: 100px;
    }

    .vivaia-fbt-product-checkbox {
        top: 5px;
        left: 5px;
    }

    .vivaia-fbt-product-checkbox input[type="checkbox"] {
        width: 14px;
        height: 14px;
    }

    .vivaia-fbt-main-label {
        font-size: 8px !important;
        padding: 1px 4px;
    }

    .fbt-variation-select {
        font-size: 10px;
        padding: 4px 18px 4px 6px;
    }
}

/* Scrollbar styling for products container */
.vivaia-fbt-products::-webkit-scrollbar {
    height: 3px;
}

.vivaia-fbt-products::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.vivaia-fbt-products::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

.vivaia-fbt-products::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}
