/* ═══════════════════════════════════════════════════════
   Will Cart Drawer (4x4AT)
   Ported from Vanimal_CartDrawer with brand colour changes

   NOTE: Rules use !important throughout to override the
   Sm Autostore theme's aggressive global styles in yttheme.css:
   - button.action:not(.action-auth-toggle) { height:35px; color:#fff; background:... }
   - .block-minicart li { padding:10px 0 !important }
   - a.action.primary { color:#fff !important }
   ═══════════════════════════════════════════════════════ */

/* ── Overlay ──────────────────────────────────────────── */
.cart-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1),
                visibility 300ms cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.cart-drawer-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ── Drawer Panel ─────────────────────────────────────── */
.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100%;
    max-width: 100vw;
    background: #ffffff;
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    box-sizing: border-box;
}

.cart-drawer.is-open {
    transform: translateX(0);
}

body.cart-drawer-open {
    overflow: hidden;
}

/* ── Theme reset scope ────────────────────────────────── */
/* Reset all buttons — theme sets button.action { height:35px; line-height:35px; color:#fff; background } */
.cart-drawer button,
.cart-drawer button[type="button"] {
    height: auto !important;
    line-height: normal !important;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    color: inherit !important;
    text-transform: none !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    text-decoration: none !important;
    outline: none;
    box-shadow: none !important;
    display: flex;
    min-height: 0;
    width: auto;
}

/* Reset links */
.cart-drawer a {
    color: inherit;
    text-decoration: none;
}

/* Reset list items — theme sets .block-minicart li { padding:10px 0 !important } */
.cart-drawer li {
    padding: 0 !important;
    border: none !important;
    margin: 0;
    list-style: none;
}

.cart-drawer * {
    box-sizing: border-box;
}

/* ── Header ───────────────────────────────────────────── */
.cart-drawer .cart-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    min-height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.cart-drawer .cart-drawer__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1;
    letter-spacing: -0.01em;
}

.cart-drawer .cart-drawer__count {
    font-weight: 400;
    color: #6b6b6b;
}

.cart-drawer button.cart-drawer__close {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: none !important;
    color: #1a1a1a !important;
    cursor: pointer;
    flex-shrink: 0;
}

.cart-drawer button.cart-drawer__close:hover,
.cart-drawer button.cart-drawer__close:focus {
    color: #6b6b6b !important;
    background: none !important;
}

/* ── Scrollable Items Area ────────────────────────────── */
.cart-drawer .cart-drawer__items {
    flex: 1 1 0%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    min-height: 0;
}

.cart-drawer .cart-drawer__item-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ── Footer ───────────────────────────────────────────── */
.cart-drawer .cart-drawer__footer {
    flex-shrink: 0;
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    background: #ffffff;
}

.cart-drawer .cart-drawer__subtotal {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.cart-drawer .cart-drawer__subtotal-label {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
}

.cart-drawer .cart-drawer__subtotal-price {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
}

.cart-drawer .cart-drawer__subtotal-price .price {
    font-size: inherit !important;
    font-weight: inherit !important;
}

/* Subtotal VAT labels — same cleanup as line items */
.cart-drawer .cart-drawer__subtotal-price .price-including-tax + .price-excluding-tax::before {
    content: none !important;
}

.cart-drawer .cart-drawer__tax-note {
    margin: 0 0 16px;
    font-size: 12px;
    color: #6b6b6b;
}

/* ── CTA Buttons ──────────────────────────────────────── */
.cart-drawer .cart-drawer__actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

/* Shared CTA base — overrides theme's button.action and a.action.primary */
.cart-drawer .cart-drawer__btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 16px !important;
    border: none !important;
    border-radius: 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
    line-height: 44px !important;
    white-space: nowrap;
    width: auto;
}

/* Primary CTA — 4x4AT brand green */
.cart-drawer .cart-drawer__btn--primary,
.cart-drawer button.cart-drawer__btn--primary {
    background: #03b94b !important;
    color: #ffffff !important;
}

.cart-drawer .cart-drawer__btn--primary:hover,
.cart-drawer .cart-drawer__btn--primary:focus,
.cart-drawer button.cart-drawer__btn--primary:hover,
.cart-drawer button.cart-drawer__btn--primary:focus {
    background: #029a3e !important;
    color: #ffffff !important;
    text-decoration: none !important;
}

.cart-drawer .cart-drawer__btn--secondary,
.cart-drawer a.cart-drawer__btn--secondary {
    background: #1a1a1a !important;
    color: #ffffff !important;
}

.cart-drawer .cart-drawer__btn--secondary:hover,
.cart-drawer .cart-drawer__btn--secondary:focus,
.cart-drawer a.cart-drawer__btn--secondary:hover,
.cart-drawer a.cart-drawer__btn--secondary:focus {
    background: #333333 !important;
    color: #ffffff !important;
    text-decoration: none !important;
}

/* Continue Shopping — plain text link, NOT a filled button */
.cart-drawer button.cart-drawer__continue {
    display: block !important;
    width: 100%;
    padding: 10px 0 !important;
    border: none !important;
    background: none !important;
    color: #6b6b6b !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    text-decoration: underline !important;
    text-transform: none !important;
    cursor: pointer;
    text-align: center;
    transition: color 150ms ease;
    height: auto !important;
    line-height: 1.4 !important;
}

.cart-drawer button.cart-drawer__continue:hover,
.cart-drawer button.cart-drawer__continue:focus {
    color: #1a1a1a !important;
    background: none !important;
}

/* ── Empty Wrapper — flex child that expands when cart is empty ── */
.cart-drawer .cart-drawer__empty-wrapper {
    flex: 1 1 0%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ── Empty State ──────────────────────────────────────── */
.cart-drawer .cart-drawer__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 48px 24px;
    text-align: center;
}

.cart-drawer .cart-drawer__empty-icon {
    color: #e0e0e0;
    margin-bottom: 24px;
}

.cart-drawer .cart-drawer__empty-title {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
}

.cart-drawer .cart-drawer__empty-text {
    margin: 0 0 24px;
    font-size: 14px;
    color: #6b6b6b;
    max-width: 280px;
}

.cart-drawer .cart-drawer__empty .cart-drawer__btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 200px;
}

/* ── Cart Item ────────────────────────────────────────── */
.cart-drawer .cart-drawer-item {
    display: flex !important;
    gap: 12px;
    padding: 16px !important;
    border-bottom: 1px solid #e0e0e0 !important;
    align-items: flex-start;
}

.cart-drawer .cart-drawer-item:last-child {
    border-bottom: none !important;
}

/* ── Product Image ────────────────────────────────────── */
.cart-drawer .cart-drawer-item__image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    background: #f5f5f5;
    border: 1px solid #eee;
}

.cart-drawer .cart-drawer-item__image a {
    display: block;
    width: 100%;
    height: 100%;
}

.cart-drawer .cart-drawer-item__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ── Product Details ──────────────────────────────────── */
.cart-drawer .cart-drawer-item__details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cart-drawer .cart-drawer-item__name-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.cart-drawer .cart-drawer-item__name {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
    text-decoration: none !important;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.cart-drawer a.cart-drawer-item__name:hover {
    color: #03b94b !important;
}

/* ── Remove Button ────────────────────────────────────── */
.cart-drawer button.cart-drawer-item__remove {
    flex-shrink: 0;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px;
    padding: 0 !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 4px !important;
    background: #ffffff !important;
    color: #999 !important;
    cursor: pointer;
    transition: color 150ms ease, border-color 150ms ease;
}

.cart-drawer button.cart-drawer-item__remove:hover,
.cart-drawer button.cart-drawer-item__remove:focus {
    color: #cc3333 !important;
    border-color: #cc3333 !important;
    background: #fff5f5 !important;
}

/* ── SKU ──────────────────────────────────────────────── */
.cart-drawer .cart-drawer-item__sku {
    display: block;
    font-size: 11px;
    color: #999;
    margin: 0;
    line-height: 1.4;
}

/* ── Configurable Options ─────────────────────────────── */
.cart-drawer .cart-drawer-item__options {
    margin: 4px 0 0;
    padding: 0;
}

.cart-drawer .cart-drawer-item__option {
    display: flex;
    gap: 4px;
    font-size: 12px;
    color: #6b6b6b;
    line-height: 1.4;
}

.cart-drawer .cart-drawer-item__option dt {
    font-weight: 600;
    white-space: nowrap;
}

.cart-drawer .cart-drawer-item__option dt::after {
    content: none;
}

.cart-drawer .cart-drawer-item__option dd {
    margin: 0;
    padding: 0;
}

/* ── Line Price ───────────────────────────────────────── */
.cart-drawer .cart-drawer-item__price {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a1a;
    margin-top: 4px;
    line-height: 1.3;
}

.cart-drawer .cart-drawer-item__price .price {
    font-size: inherit !important;
    font-weight: inherit !important;
    color: inherit !important;
}

/* Inc/Exc VAT price lines — clean up redundant labels.
   ytextend.css adds ::after "excl. VAT" / "incl. VAT" globally.
   m2-styles-m.css adds ::before "Excl. Tax:" on the sibling selector.
   We only want ONE label per line, so kill ::before inside the drawer. */
.cart-drawer .cart-drawer-item__price .price-including-tax,
.cart-drawer .cart-drawer-item__price .price-excluding-tax {
    display: block;
    font-size: 14px !important;
    line-height: 1.4;
}

/* Inc-tax line: bold, normal size */
.cart-drawer .cart-drawer-item__price .price-including-tax .price {
    font-size: 14px !important;
    font-weight: 700 !important;
}

/* Exc-tax line: smaller, lighter */
.cart-drawer .cart-drawer-item__price .price-including-tax + .price-excluding-tax {
    font-size: 12px !important;
    color: #6b6b6b;
    margin-top: 2px;
}

.cart-drawer .cart-drawer-item__price .price-including-tax + .price-excluding-tax .price {
    font-size: 12px !important;
    font-weight: 400 !important;
    color: #6b6b6b !important;
}

/* Remove the "Excl. Tax:" prefix that m2-styles adds via ::before */
.cart-drawer .cart-drawer-item__price .price-including-tax + .price-excluding-tax::before {
    content: none !important;
}

/* Keep the "excl. VAT" / "incl. VAT" suffix from ytextend.css but size it properly */
.cart-drawer .cart-drawer-item__price .price-including-tax::after {
    font-size: 11px !important;
    font-weight: 400;
    color: #6b6b6b;
}

.cart-drawer .cart-drawer-item__price .price-excluding-tax::after {
    font-size: 11px !important;
    font-weight: 400;
}

/* ── Qty Row ──────────────────────────────────────────── */
.cart-drawer .cart-drawer-item__bottom {
    display: flex;
    align-items: center;
    margin-top: 8px;
}

/* ── Qty Adjuster ─────────────────────────────────────── */
.cart-drawer .cart-drawer-item__qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid #e0e0e0;
    height: 36px;
    border-radius: 0;
    overflow: hidden;
}

.cart-drawer button.cart-drawer-item__qty-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 34px !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: #f5f5f5 !important;
    color: #1a1a1a !important;
    cursor: pointer;
    transition: background-color 150ms ease;
    -webkit-user-select: none;
    user-select: none;
    line-height: 1 !important;
    font-size: 14px !important;
}

.cart-drawer button.cart-drawer-item__qty-btn:hover {
    background: #eaeaea !important;
}

.cart-drawer button.cart-drawer-item__qty-btn:focus {
    outline: 2px solid #03b94b !important;
    outline-offset: -2px;
    background: #f5f5f5 !important;
}

.cart-drawer button.cart-drawer-item__qty-btn.is-disabled {
    color: #ccc !important;
    cursor: default;
    pointer-events: none;
    background: #fafafa !important;
}

.cart-drawer .cart-drawer-item__qty-value {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 100%;
    padding: 0 4px;
    font-size: 14px !important;
    font-weight: 600;
    color: #1a1a1a !important;
    text-align: center;
    background: #ffffff;
    border-left: 1px solid #e0e0e0;
    border-right: 1px solid #e0e0e0;
    line-height: 1;
}

/* ── Responsive — Mobile ──────────────────────────────── */
@media (max-width: 767px) {
    .cart-drawer {
        width: 85vw;
        min-width: 300px;
    }

    .cart-drawer button.cart-drawer-item__qty-btn {
        width: 44px !important;
    }

    .cart-drawer .cart-drawer__btn {
        height: 48px !important;
        min-height: 48px !important;
        font-size: 15px !important;
        line-height: 48px !important;
    }

    .cart-drawer .cart-drawer-item__image {
        width: 72px;
        height: 72px;
    }
}

/* ── Responsive — Small phones ────────────────────────── */
@media (max-width: 575px) {
    .cart-drawer .cart-drawer__actions {
        flex-direction: column;
    }

    .cart-drawer .cart-drawer-item {
        gap: 8px;
    }

    .cart-drawer .cart-drawer-item__image {
        width: 64px;
        height: 64px;
    }
}
