/**
 * KB Frequently Bought Together - Frontend CSS
 *
 * @author    Starter
 * @copyright 2024
 * @license   Commercial
 */

/* Base Block Styles */
.kbfbt-block {
    margin: 30px 0;
    padding: 20px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
}

.kbfbt-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #e5e5e5;
}

/* Bundle Container */
.kbfbt-bundle {
    margin-bottom: 25px;
}

.kbfbt-bundle:last-child {
    margin-bottom: 0;
}

/* Grid Layout */
.kbfbt-grid-layout .kbfbt-products-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.kbfbt-grid-layout .kbfbt-product {
    flex: 0 0 auto;
    width: 140px;
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    position: relative;
}

.kbfbt-plus-sign {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 24px;
    font-weight: bold;
    color: #666;
}

/* Product Styles */
.kbfbt-product-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.kbfbt-product-link:hover {
    text-decoration: none;
}

.kbfbt-product-img-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.kbfbt-product-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.kbfbt-no-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-size: 12px;
}

.kbfbt-product-name {
    font-size: 13px;
    font-weight: 500;
    margin: 0 0 5px 0;
    line-height: 1.3;
    min-height: 34px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.kbfbt-combination {
    display: block;
    font-size: 11px;
    color: #666;
    margin-bottom: 5px;
}

.kbfbt-product-price {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.kbfbt-out-of-stock {
    display: inline-block;
    background: #dc3545;
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-top: 5px;
}

/* Main Product Badge */
.kbfbt-main-badge {
    position: absolute;
    top: 5px;
    left: 5px;
    background: #2196F3;
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Checkbox Styles */
.kbfbt-checkbox {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 10;
}

.kbfbt-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2196F3;
}

.kbfbt-checkbox label {
    display: none;
}

/* Bundle Footer */
.kbfbt-bundle-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding-top: 15px;
    border-top: 1px solid #e5e5e5;
}

.kbfbt-totals {
    flex: 1;
}

.kbfbt-total-row {
    font-size: 16px;
    margin-bottom: 5px;
}

.kbfbt-total-label {
    color: #666;
    margin-right: 10px;
}

.kbfbt-total-value {
    font-weight: 600;
}

.kbfbt-original-price {
    text-decoration: line-through;
    color: #999;
    margin-right: 8px;
}

.kbfbt-discounted-price {
    color: #e74c3c;
    font-weight: 700;
}

.kbfbt-savings-row {
    font-size: 14px;
}

.kbfbt-savings {
    color: #27ae60;
}

.kbfbt-savings strong {
    color: #27ae60;
}

/* Add Button */
.kbfbt-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.kbfbt-add-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.kbfbt-add-btn .material-icons {
    font-size: 18px;
}

/* Carousel Layout */
.kbfbt-carousel-layout .kbfbt-carousel-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.kbfbt-carousel-track {
    flex: 1;
    overflow: hidden;
}

.kbfbt-carousel-items {
    display: flex;
    gap: 15px;
    transition: transform 0.3s ease;
}

.kbfbt-carousel-item {
    flex: 0 0 160px;
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    position: relative;
}

.kbfbt-carousel-nav {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.kbfbt-carousel-nav:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.kbfbt-carousel-nav:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Cart Page Layout */
.kbfbt-cart-layout .kbfbt-cart-bundles {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.kbfbt-cart-bundle {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.kbfbt-cart-products {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.kbfbt-cart-product {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: #fff;
    border-radius: 4px;
    position: relative;
}

.kbfbt-cart-product-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.kbfbt-cart-product-img {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.kbfbt-cart-product-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.kbfbt-cart-product-info {
    flex: 1;
    min-width: 0;
}

.kbfbt-cart-product-info .kbfbt-product-name {
    font-size: 13px;
    min-height: auto;
    margin: 0 0 3px 0;
}

.kbfbt-cart-product-price {
    font-weight: 600;
    white-space: nowrap;
}

.kbfbt-cart-bundle-action {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.kbfbt-cart-total {
    text-align: right;
}

.kbfbt-cart-total .kbfbt-price {
    font-size: 18px;
    font-weight: 600;
}

/* Loading State */
.kbfbt-loading {
    position: relative;
    pointer-events: none;
}

.kbfbt-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kbfbt-add-btn.loading {
    position: relative;
    color: transparent;
}

.kbfbt-add-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: kbfbt-spin 0.8s linear infinite;
}

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

/* Success Message */
.kbfbt-success-msg {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    background: #27ae60;
    color: #fff;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    animation: kbfbt-slideIn 0.3s ease;
}

.kbfbt-success-msg.hide {
    animation: kbfbt-slideOut 0.3s ease forwards;
}

@keyframes kbfbt-slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes kbfbt-slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .kbfbt-grid-layout .kbfbt-product {
        width: 110px;
    }

    .kbfbt-bundle-footer {
        flex-direction: column;
        text-align: center;
    }

    .kbfbt-totals {
        width: 100%;
    }

    .kbfbt-action {
        width: 100%;
    }

    .kbfbt-add-btn {
        width: 100%;
        justify-content: center;
    }

    .kbfbt-cart-bundle {
        flex-direction: column;
    }

    .kbfbt-cart-bundle-action {
        width: 100%;
        align-items: center;
    }

    .kbfbt-carousel-item {
        flex: 0 0 130px;
    }
}

@media (max-width: 480px) {
    .kbfbt-block {
        padding: 15px;
        margin: 20px 0;
    }

    .kbfbt-grid-layout .kbfbt-products-grid {
        flex-direction: column;
    }

    .kbfbt-grid-layout .kbfbt-product {
        width: 100%;
        max-width: 200px;
    }

    .kbfbt-plus-sign {
        transform: rotate(90deg);
    }

    .kbfbt-carousel-container {
        flex-direction: column;
    }

    .kbfbt-carousel-nav {
        display: none;
    }

    .kbfbt-carousel-items {
        flex-wrap: wrap;
        justify-content: center;
    }
}
