/* Isolate widget from theme styles */
.asm-bundle-widget,
.asm-bundle-widget *,
.asm-bundle-widget *::before,
.asm-bundle-widget *::after {
    box-sizing: border-box;
}

.asm-bundle-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #37352f;
    line-height: 1.5;
    font-size: 14px;
    margin: 0;
    padding: 0;
}

/* Reset theme overrides on common elements inside widget */
.asm-bundle-widget img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
}

.asm-bundle-widget button {
    font-family: inherit;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    box-shadow: none;
}

.asm-bundle-widget input[type="number"] {
    font-family: inherit;
    box-shadow: none;
    outline: none;
    margin: 0;
    background: #fff;
}

.asm-bundle-widget input[type="checkbox"] {
    margin: 0;
    box-shadow: none;
}

.asm-bundle-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #37352f;
}

.asm-bundle-row {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.asm-bundle-products {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.asm-bundle-card {
    background: #fff;
    border: 1px solid #e9e9e7;
    border-radius: 8px;
    padding: 16px;
    width: 180px;
    text-align: center;
    transition: border-color 0.15s, opacity 0.2s;
    position: relative;
}

.asm-bundle-card:hover {
    border-color: #d3d3d0;
}

.asm-bundle-card-current {
    border: 2px solid #37352f;
}

.asm-bundle-card.unchecked {
    opacity: 0.35;
}

.asm-bundle-card-check {
    position: absolute;
    top: 8px;
    left: 8px;
}

.asm-bundle-card-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.asm-bundle-card-img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    margin-bottom: 8px;
}

.asm-bundle-card-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9b9a97;
    margin-bottom: 4px;
}

.asm-bundle-card-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    color: #37352f;
}

.asm-bundle-card-sku {
    font-size: 11px;
    color: #9b9a97;
    margin-bottom: 2px;
}

.asm-bundle-card-desc {
    font-size: 12px;
    color: #6b6b6b;
    margin: 4px 0;
    line-height: 1.4;
}

.asm-bundle-card-price {
    font-size: 15px;
    font-weight: 600;
    margin: 8px 0;
    color: #37352f;
}

.asm-bundle-divider {
    font-size: 24px;
    font-weight: 300;
    color: #d3d3d0;
    display: flex;
    align-items: center;
    padding: 0 4px;
    user-select: none;
}

.asm-bundle-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid #e9e9e7;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

.asm-bundle-qty button {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    color: #37352f;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s;
    padding: 0;
    line-height: 1;
}

.asm-bundle-qty button:hover {
    background: #f7f6f3;
}

.asm-bundle-qty button:disabled {
    color: #d3d3d0;
    cursor: default;
}

.asm-bundle-qty button:disabled:hover {
    background: transparent;
}

.asm-bundle-qty input {
    width: 36px;
    text-align: center;
    border: none;
    border-left: 1px solid #e9e9e7;
    border-right: 1px solid #e9e9e7;
    font-size: 13px;
    font-weight: 500;
    color: #37352f;
    padding: 0;
    height: 28px;
    -moz-appearance: textfield;
}

.asm-bundle-qty input::-webkit-outer-spin-button,
.asm-bundle-qty input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Sidebar */
.asm-bundle-sidebar {
    width: 300px;
    min-width: 300px;
    position: sticky;
    top: 100px;
    background: #f7f6f3;
    border-radius: 8px;
    padding: 20px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.asm-bundle-sidebar-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #37352f;
}

.asm-bundle-sidebar-items {
    margin-bottom: 12px;
}

.asm-bundle-sidebar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #e9e9e7;
    font-size: 12px;
    transition: opacity 0.2s;
}

.asm-bundle-sidebar-row.hidden {
    display: none;
}

.asm-bundle-sidebar-row img {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.asm-bundle-sidebar-name {
    flex: 1;
    font-weight: 500;
    color: #37352f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asm-bundle-sidebar-qty {
    color: #9b9a97;
    font-size: 11px;
    flex-shrink: 0;
}

.asm-bundle-sidebar-price {
    font-weight: 600;
    color: #37352f;
    flex-shrink: 0;
}

.asm-bundle-sidebar-discount {
    font-size: 13px;
    color: #1c3829;
    background: #dbeddb;
    padding: 6px 10px;
    border-radius: 4px;
    margin: 12px 0;
    font-weight: 500;
}

.asm-bundle-sidebar-total {
    font-size: 18px;
    font-weight: 700;
    margin: 12px 0;
    color: #37352f;
}

.asm-bundle-add-all {
    width: 100%;
    padding: 14px;
    background: #5ba745;
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}

.asm-bundle-add-all:hover {
    background: #4e9a3b;
}

.asm-bundle-add-all:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Navigation bar — hidden on desktop */
.asm-bundle-nav {
    display: none;
}

/* ─── Mobile: Card Carousel ─── */
@media (max-width: 768px) {

    .asm-bundle-row {
        flex-direction: column;
        gap: 0;
        align-items: stretch;
    }

    /* Products — one card at a time */
    .asm-bundle-products {
        flex: none;
        display: block;
        width: 100%;
        overflow: hidden;
        padding: 4px 8px;
    }

    /* All cards hidden by default */
    .asm-bundle-card {
        display: none;
        width: 100%;
        max-width: 100%;
    }

    /* CSS fallback: show first card before JS loads */
    .asm-bundle-products:not(.asm-carousel-init) > .asm-bundle-card:first-child {
        display: block;
    }

    /* JS-controlled visibility */
    .asm-bundle-card.asm-carousel-active {
        display: block;
    }

    /* Hide "+" dividers */
    .asm-bundle-divider {
        display: none;
    }

    /* Slide-in animations */
    @keyframes asm-slide-right {
        from { opacity: 0; transform: translateX(40px); }
        to   { opacity: 1; transform: translateX(0); }
    }

    @keyframes asm-slide-left {
        from { opacity: 0; transform: translateX(-40px); }
        to   { opacity: 1; transform: translateX(0); }
    }

    .asm-bundle-card.slide-next {
        animation: asm-slide-right 0.25s ease-out;
    }

    .asm-bundle-card.slide-prev {
        animation: asm-slide-left 0.25s ease-out;
    }

    /* Navigation bar below card */
    .asm-bundle-nav {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 20px;
        padding: 12px 0;
    }

    .asm-bundle-arrow {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: #fff;
        border: 1px solid #e9e9e7;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
        font-size: 20px;
        color: #37352f;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        line-height: 1;
        transition: background 0.15s;
    }

    .asm-bundle-arrow:active {
        background: #f7f6f3;
    }

    .asm-bundle-arrow:disabled {
        opacity: 0.3;
        cursor: default;
    }

    .asm-bundle-counter {
        font-size: 15px;
        font-weight: 600;
        color: #37352f;
        min-width: 50px;
        text-align: center;
    }

    /* Sidebar → compact action bar */
    .asm-bundle-sidebar {
        position: static;
        width: 100%;
        min-width: 0;
        max-height: none;
        border-radius: 12px;
        padding: 16px;
    }

    .asm-bundle-sidebar-title {
        display: none;
    }

    .asm-bundle-sidebar-items {
        display: none;
    }

    .asm-bundle-sidebar-discount {
        text-align: center;
        margin: 0 0 8px;
        font-size: 13px;
    }

    .asm-bundle-sidebar-total {
        text-align: center;
        font-size: 18px;
        margin: 0 0 12px;
    }
}
