/**
 * KB Cross Selling Pro
 * Frontend CSS
 */

/* =====================================================
   Block Container
   ===================================================== */
.kbcs-block {
    margin: 30px 0;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.kbcs-block-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 15px;
}

.kbcs-block-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #232323;
}

/* =====================================================
   Loading State
   ===================================================== */
.kbcs-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #666;
}

.kbcs-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f0f0f0;
    border-top-color: #2fb5d2;
    border-radius: 50%;
    animation: kbcs-spin 0.8s linear infinite;
    margin-bottom: 15px;
}

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

/* =====================================================
   Category Tabs/Filter
   ===================================================== */
.kbcs-category-tabs {
    flex: 1;
    min-width: 200px;
}

.kbcs-tabs-list {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 5px;
}

.kbcs-tab {
    margin: 0;
}

.kbcs-tab a {
    display: block;
    padding: 8px 16px;
    color: #666;
    text-decoration: none;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.kbcs-tab a:hover {
    background: #e8e8e8;
    color: #333;
}

.kbcs-tab.active a {
    background: #2fb5d2;
    color: #fff;
}

/* =====================================================
   Grid Layout
   ===================================================== */
.kbcs-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

@media (max-width: 991px) {
    .kbcs-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767px) {
    .kbcs-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .kbcs-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* =====================================================
   Carousel Layout
   ===================================================== */
.kbcs-carousel-wrapper {
    position: relative;
    padding: 0 45px;
}

.kbcs-carousel {
    overflow: hidden;
}

.kbcs-carousel-track {
    display: flex;
    transition: transform 0.3s ease;
    gap: 20px;
}

.kbcs-layout-carousel .kbcs-product-item {
    flex: 0 0 calc(25% - 15px);
    min-width: calc(25% - 15px);
}

@media (max-width: 991px) {
    .kbcs-layout-carousel .kbcs-product-item {
        flex: 0 0 calc(33.333% - 13.333px);
        min-width: calc(33.333% - 13.333px);
    }
}

@media (max-width: 767px) {
    .kbcs-layout-carousel .kbcs-product-item {
        flex: 0 0 calc(50% - 10px);
        min-width: calc(50% - 10px);
    }

    .kbcs-carousel-wrapper {
        padding: 0 35px;
    }
}

/* Navigation Arrows */
.kbcs-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.kbcs-nav:hover {
    background: #2fb5d2;
    border-color: #2fb5d2;
    color: #fff;
}

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

.kbcs-nav-prev {
    left: 0;
}

.kbcs-nav-next {
    right: 0;
}

.kbcs-nav .material-icons {
    font-size: 24px;
}

/* =====================================================
   Product Card
   ===================================================== */
.kbcs-product-miniature {
    position: relative;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.kbcs-product-miniature:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-color: #ddd;
}

/* Product Thumbnail */
.kbcs-product-thumbnail {
    position: relative;
    padding-top: 100%;
    overflow: hidden;
    background: #f9f9f9;
}

.kbcs-product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.kbcs-product-miniature:hover .kbcs-product-image {
    transform: scale(1.05);
}

/* Product Flags */
.kbcs-product-flags {
    position: absolute;
    top: 10px;
    left: 10px;
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 5;
}

.kbcs-flag {
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 3px;
    background: #333;
    color: #fff;
}

.kbcs-flag-new {
    background: #4caf50;
}

.kbcs-flag-sale,
.kbcs-flag-discount {
    background: #f44336;
}

.kbcs-flag-pack {
    background: #9c27b0;
}

/* Discount Badge */
.kbcs-discount-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #f44336;
    color: #fff;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 3px;
    z-index: 5;
}

/* Product Info */
.kbcs-product-info {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.kbcs-product-title {
    margin: 0 0 10px;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
}

.kbcs-product-title a {
    color: #333;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kbcs-product-title a:hover {
    color: #2fb5d2;
}

/* Price */
.kbcs-product-price-wrapper {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.kbcs-product-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: #232323;
}

.kbcs-product-price-regular {
    font-size: 0.9rem;
    color: #999;
    text-decoration: line-through;
}

/* Rating */
.kbcs-product-rating {
    display: flex;
    gap: 2px;
    margin-bottom: 10px;
}

.kbcs-star-filled {
    color: #ffc107;
    font-size: 16px;
}

.kbcs-star-empty {
    color: #ddd;
    font-size: 16px;
}

/* Product Actions */
.kbcs-product-actions {
    padding: 10px 15px 15px;
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.kbcs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.kbcs-btn-view {
    flex: 1;
    background: #f0f0f0;
    color: #333;
}

.kbcs-btn-view:hover {
    background: #2fb5d2;
    color: #fff;
}

.kbcs-btn-cart {
    width: 44px;
    padding: 10px;
    background: #2fb5d2;
    color: #fff;
}

.kbcs-btn-cart:hover {
    background: #25a0bc;
}

.kbcs-btn-cart .material-icons {
    font-size: 20px;
}

/* No Products Message */
.kbcs-no-products {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 0.95rem;
}

/* =====================================================
   Responsive Adjustments
   ===================================================== */
@media (max-width: 767px) {
    .kbcs-block {
        padding: 15px;
        margin: 20px 0;
    }

    .kbcs-block-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .kbcs-block-title {
        font-size: 1.2rem;
    }

    .kbcs-category-tabs {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .kbcs-tabs-list {
        flex-wrap: nowrap;
    }

    .kbcs-tab a {
        white-space: nowrap;
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .kbcs-product-info {
        padding: 10px;
    }

    .kbcs-product-title {
        font-size: 0.85rem;
    }

    .kbcs-product-price {
        font-size: 1rem;
    }

    .kbcs-product-actions {
        padding: 8px 10px 10px;
    }

    .kbcs-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .kbcs-btn-cart {
        width: 40px;
        padding: 8px;
    }
}

/* =====================================================
   Sort Dropdown
   ===================================================== */
.kbcs-sort-dropdown {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kbcs-sort-dropdown label {
    font-size: 0.9rem;
    color: #666;
    white-space: nowrap;
    margin: 0;
}

.kbcs-sort-select {
    padding: 8px 30px 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 10px center;
    appearance: none;
    cursor: pointer;
    min-width: 150px;
}

.kbcs-sort-select:focus {
    outline: none;
    border-color: #2fb5d2;
}

/* =====================================================
   Tab Layout
   ===================================================== */
.kbcs-tab-layout {
    width: 100%;
}

.kbcs-tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
    padding-bottom: 0;
}

.kbcs-tab-nav .nav-item {
    margin-bottom: -2px;
}

.kbcs-tab-nav .nav-link {
    padding: 12px 20px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: #666;
    font-weight: 500;
    transition: all 0.2s ease;
}

.kbcs-tab-nav .nav-link:hover {
    color: #2fb5d2;
}

.kbcs-tab-nav .nav-link.active {
    color: #2fb5d2;
    border-bottom-color: #2fb5d2;
}

.kbcs-tab-count {
    font-size: 0.8em;
    color: #999;
    margin-left: 5px;
}

.kbcs-tab-content {
    min-height: 200px;
}

.kbcs-tab-pane {
    display: none;
}

.kbcs-tab-pane.active {
    display: block;
}

/* =====================================================
   List Layout
   ===================================================== */
.kbcs-list-layout {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.kbcs-list-item {
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: all 0.2s ease;
}

.kbcs-list-item:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-color: #ddd;
}

.kbcs-list-product {
    display: flex;
    align-items: stretch;
}

.kbcs-list-thumbnail {
    position: relative;
    width: 180px;
    min-width: 180px;
    background: #f9f9f9;
}

.kbcs-list-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.kbcs-list-info {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.kbcs-list-title {
    margin: 0 0 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

.kbcs-list-title a {
    color: #333;
    text-decoration: none;
}

.kbcs-list-title a:hover {
    color: #2fb5d2;
}

.kbcs-list-description {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 10px;
}

.kbcs-list-flags {
    position: static;
    display: flex;
    flex-direction: row;
    margin-bottom: 10px;
}

.kbcs-list-rating {
    display: flex;
    align-items: center;
    gap: 4px;
}

.kbcs-reviews-count {
    font-size: 0.85rem;
    color: #666;
    margin-left: 5px;
}

.kbcs-list-price-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    padding: 20px;
    min-width: 200px;
    border-left: 1px solid #f0f0f0;
    background: #fafafa;
}

.kbcs-list-price-wrapper {
    text-align: right;
    margin-bottom: 15px;
}

.kbcs-list-price {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: #232323;
}

.kbcs-list-price-regular {
    display: block;
    font-size: 0.9rem;
    color: #999;
    text-decoration: line-through;
    margin-bottom: 5px;
}

.kbcs-list-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.kbcs-list-actions .kbcs-btn {
    width: 100%;
    justify-content: center;
}

.kbcs-list-actions .kbcs-btn-cart {
    width: 100%;
    gap: 8px;
}

.kbcs-out-of-stock {
    color: #dc3545;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
}

/* List Layout Responsive */
@media (max-width: 767px) {
    .kbcs-list-product {
        flex-direction: column;
    }

    .kbcs-list-thumbnail {
        width: 100%;
        min-width: 100%;
        height: 200px;
    }

    .kbcs-list-info {
        padding: 15px;
    }

    .kbcs-list-title {
        font-size: 1rem;
    }

    .kbcs-list-price-actions {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 15px;
        border-left: none;
        border-top: 1px solid #f0f0f0;
        min-width: 100%;
    }

    .kbcs-list-price-wrapper {
        margin-bottom: 0;
        text-align: left;
    }

    .kbcs-list-actions {
        flex-direction: row;
        width: auto;
    }

    .kbcs-list-actions .kbcs-btn {
        width: auto;
    }
}

/* =====================================================
   Dark Mode Support (if theme supports it)
   ===================================================== */
@media (prefers-color-scheme: dark) {
    .kbcs-block {
        background: #1e1e1e;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .kbcs-block-title {
        color: #f0f0f0;
    }

    .kbcs-product-miniature {
        background: #2d2d2d;
        border-color: #3d3d3d;
    }

    .kbcs-product-thumbnail {
        background: #252525;
    }

    .kbcs-product-title a {
        color: #e0e0e0;
    }

    .kbcs-product-price {
        color: #f0f0f0;
    }

    .kbcs-tab a {
        background: #333;
        color: #ccc;
    }

    .kbcs-tab a:hover {
        background: #444;
        color: #fff;
    }

    .kbcs-btn-view {
        background: #3d3d3d;
        color: #e0e0e0;
    }

    .kbcs-nav {
        background: #2d2d2d;
        border-color: #3d3d3d;
        color: #e0e0e0;
    }
}
