/* =============================================
   Avatex Enhanced Side Cart
   ============================================= */

/* Hide theme's original close button — we have our own in header */
#ts-shopping-cart-sidebar > .ts-sidebar-content > .close {
    display: none !important;
}

/* Override theme padding and right offset on the wrapper */
#ts-shopping-cart-sidebar .ts-sidebar-content {
    padding: 0 !important;
    right: 0 !important;
}

/* Override theme's dropdown-container styles that bleed into our cart */
#ts-shopping-cart-sidebar .cart-dropdown-form.dropdown-container {
    position: static !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* ── Main Layout ── */
.avatex-side-cart {
    display: flex;
    flex-direction: column;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1a1a1a;
    box-sizing: border-box;
    overflow-x: hidden;
}

.avatex-side-cart *,
.avatex-side-cart *::before,
.avatex-side-cart *::after {
    box-sizing: border-box;
}

/* ── Header ── */
.avatex-sc__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.avatex-sc__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.avatex-sc__title svg {
    flex-shrink: 0;
}

.avatex-sc__count {
    font-weight: 400;
    color: #666;
}

/* Close button — clean × without box */
.avatex-sc__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 28px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.15s, color 0.15s;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 0;
}

.avatex-sc__close:hover {
    background-color: #f0f0f0 !important;
    color: #1a1a1a;
}

/* ── Shipping Bar ── */
.avatex-sc__shipping-bar {
    padding: 14px 24px;
    background: #fafafa;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.avatex-sc__sb-text {
    font-size: 13px;
    color: #444;
    margin: 0 0 8px;
    line-height: 1.4;
}

.avatex-sc__sb-text strong {
    color: #1a1a1a;
}

.avatex-sc__sb-text--free {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #16a34a;
    font-weight: 500;
}

.avatex-sc__sb-text--free svg {
    stroke: #16a34a;
}

.avatex-sc__progress {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.avatex-sc__progress-fill {
    height: 100%;
    background: #2563eb;
    border-radius: 3px;
    transition: width 0.4s ease;
    min-width: 0;
}

/* Full bar turns green */
.avatex-sc__sb-text--free + .avatex-sc__progress .avatex-sc__progress-fill {
    background: #16a34a;
}

/* ── Items (scrollable but compact) ── */
.avatex-sc__items {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

/* Override theme's max-height on cart list */
#ts-shopping-cart-sidebar .avatex-side-cart .cart_list {
    max-height: none !important;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ── Single Item ── */
.avatex-sc__item {
    display: flex;
    gap: 14px;
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.avatex-sc__item:last-child {
    border-bottom: none;
}

.avatex-sc__item-img {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    background: #f8f8f8;
}

.avatex-sc__item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatex-sc__item-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.avatex-sc__item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.avatex-sc__item-top .product-name {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}

.avatex-sc__item-top .product-name a {
    color: #1a1a1a;
    text-decoration: none;
}

.avatex-sc__item-top .product-name a:hover {
    color: #2563eb;
}

/* Trash/remove icon */
.avatex-sc__remove {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: #bbb;
    transition: color 0.15s;
    padding: 0;
    background: none !important;
    border: none !important;
}

.avatex-sc__remove:hover {
    color: #ef4444;
}

.avatex-sc__unit-price {
    font-size: 12px;
    color: #888;
}

.avatex-sc__item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    padding-top: 4px;
}

/* ── Quantity Selector ── */
.avatex-sc__qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    height: 32px;
}

.avatex-qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 100%;
    background: #fff;
    border: none;
    font-size: 16px;
    color: #555;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: background-color 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.avatex-qty-btn:hover {
    background: #f5f5f5;
}

.avatex-sc__qty .qty {
    width: 34px;
    height: 100%;
    text-align: center;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    font-size: 13px;
    font-weight: 500;
    color: #1a1a1a;
    padding: 0;
    margin: 0;
    -moz-appearance: textfield;
    -webkit-appearance: none;
    appearance: none;
    background: #fff;
    border-radius: 0;
    box-shadow: none;
}

.avatex-sc__qty .qty::-webkit-inner-spin-button,
.avatex-sc__qty .qty::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.avatex-sc__line-total {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
}

/* ── Footer — pinned at bottom ── */
.avatex-sc__footer {
    flex-shrink: 0;
    margin-top: auto;
    border-top: 1px solid #eee;
    background: #fff;
}

.avatex-sc__totals {
    padding: 16px 24px 0;
}

.avatex-sc__total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 14px;
    color: #444;
}

.avatex-sc__total-row--grand {
    border-top: 1px solid #eee;
    margin-top: 4px;
    padding-top: 10px;
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
}

.avatex-sc__free-label {
    color: #16a34a;
    font-weight: 600;
}

.avatex-sc__calc-label {
    color: #999;
    font-style: italic;
    font-size: 13px;
}

/* ── Buttons ── */
.avatex-sc__buttons {
    padding: 16px 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.avatex-sc__buttons-row {
    display: flex;
    gap: 10px;
}

.avatex-sc__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none !important;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    padding: 0 16px;
    white-space: nowrap;
    box-sizing: border-box;
}

.avatex-sc__btn--continue {
    flex: 1;
    background: #fff !important;
    color: #1a1a1a !important;
    border: 1.5px solid #1a1a1a !important;
}

.avatex-sc__btn--continue:hover {
    background: #f5f5f5 !important;
    color: #1a1a1a !important;
}

.avatex-sc__btn--view-cart {
    flex: 1;
    background: #fff !important;
    color: #1a1a1a !important;
    border: 1.5px solid #1a1a1a !important;
}

.avatex-sc__btn--view-cart:hover {
    background: #f5f5f5 !important;
    color: #1a1a1a !important;
}

.avatex-sc__btn--checkout {
    width: 100%;
    background: #1a1a1a !important;
    color: #fff !important;
    border: 1.5px solid #1a1a1a !important;
}

.avatex-sc__btn--checkout:hover {
    background: #333 !important;
    color: #fff !important;
}

/* ── Empty State ── */
.avatex-sc__empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 24px;
    text-align: center;
}

.avatex-sc__empty p {
    font-size: 15px;
    color: #888;
    margin: 0;
}

.avatex-sc__empty .avatex-sc__btn {
    flex: 0 0 auto;
    width: auto;
    margin-top: 8px;
    background: #1a1a1a !important;
    color: #fff !important;
    border: 1.5px solid #1a1a1a !important;
    padding: 0 28px;
}

.avatex-sc__empty .avatex-sc__btn:hover {
    background: #333 !important;
    color: #fff !important;
}

/* ── Loading overlay ── */
#ts-shopping-cart-sidebar .blockUI.blockOverlay {
    background: rgba(255, 255, 255, 0.6) !important;
}

#ts-shopping-cart-sidebar.avatex-sc-loading .avatex-side-cart::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    z-index: 100;
    cursor: wait;
}

#ts-shopping-cart-sidebar.avatex-sc-loading .avatex-side-cart {
    position: relative;
    pointer-events: none;
}

#ts-shopping-cart-sidebar.avatex-sc-loading .avatex-side-cart::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid #e5e7eb;
    border-top-color: #1a1a1a;
    border-radius: 50%;
    z-index: 101;
    animation: avatex-spin 0.6s linear infinite;
}

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

/* ── Responsive ── */
@media (max-width: 480px) {
    .avatex-sc__header {
        padding: 16px 16px;
    }

    .avatex-sc__shipping-bar {
        padding: 12px 16px;
    }

    .avatex-sc__item {
        padding: 14px 16px;
        gap: 12px;
    }

    .avatex-sc__item-img {
        width: 70px;
        height: 70px;
    }

    .avatex-sc__totals {
        padding: 14px 16px 0;
    }

    .avatex-sc__buttons {
        padding: 14px 16px 16px;
    }

    .avatex-sc__title {
        font-size: 16px;
    }
}
