/* ============================================================
   Cart Drawer — slide-in da destra
   ============================================================ */

.creatilab-cart-drawer {
    --cl-line: #eae3d7;
    --cl-muted: #7e766a;
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    justify-content: flex-end;
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0s linear .32s;
    font-family: var(--font-body), sans-serif;
    color: var(--cl-ink);
}

.creatilab-cart-drawer.is-open {
    visibility: visible;
    pointer-events: auto;
    transition: visibility 0s;
}

.creatilab-cart-drawer__overlay {
    position: absolute;
    inset: 0;
    background: rgba(35, 34, 29, .48);
    cursor: pointer;
    opacity: 0;
    transition: opacity .28s ease;
}

.creatilab-cart-drawer.is-open .creatilab-cart-drawer__overlay {
    opacity: 1;
}

.creatilab-cart-drawer__panel {
    position: relative;
    width: min(440px, 100vw);
    height: 100%;
    height: 100dvh;
    background: var(--cl-paper, #faf7f0);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: -24px 0 60px rgba(35, 34, 29, .18);
    transform: translateX(100%);
    transition: transform .32s cubic-bezier(.22, .8, .24, 1);
}

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

.creatilab-cart-drawer *,
.creatilab-cart-drawer *::before,
.creatilab-cart-drawer *::after {
    box-sizing: border-box;
}

.creatilab-cart-drawer :focus-visible {
    outline: 3px solid #836000;
    outline-offset: 2px;
}

/* ── Testata ── */
.creatilab-cart-drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--cl-line);
    flex-shrink: 0;
    background: #fff;
}

.creatilab-cart-drawer__title {
    font-family: var(--font-baloo), sans-serif;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--cl-ink);
    margin: 0;
}

.creatilab-cart-drawer__count {
    font-family: var(--font-body), sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--cl-muted);
}

.creatilab-cart-drawer__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--cl-muted);
    border-radius: 50%;
    transition: background .15s, color .15s;
}

.creatilab-cart-drawer__close:hover {
    background: #f5f0e8;
    color: var(--cl-ink);
}

.creatilab-cart-drawer__error {
    margin: 12px 22px 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: #fdecea;
    color: #8a1f11;
    font-size: 13px;
}

/* ── Corpo ── */
.cl-cart-drawer-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.cl-mc__items {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    list-style: none;
    margin: 0;
    padding: 6px 0;
}

.cl-mc__item {
    display: grid;
    grid-template-columns: 84px 1fr;
    gap: 14px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--cl-line);
    transition: opacity .2s;
}

.cl-mc__item:last-child {
    border-bottom: 0;
}

.cl-mc__item.is-loading {
    opacity: .45;
    pointer-events: none;
}

.cl-mc__thumb {
    width: 84px;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--cl-line);
}

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

.cl-mc__thumb .cl-cart-thumb--preview {
    object-fit: contain;
    background: #fff;
}

.cl-mc__info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cl-mc__row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.cl-mc__name {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--cl-ink);
    text-decoration: none;
}

a.cl-mc__name:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cl-mc__price {
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

/* Dati personalizzazione (wc_get_formatted_cart_item_data) */
.cl-mc__meta dl.variation,
.cl-cart-meta dl.variation {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 8px;
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--cl-muted, #7e766a);
}

.cl-mc__meta dl.variation dt,
.cl-cart-meta dl.variation dt {
    font-weight: 600;
    margin: 0;
}

.cl-mc__meta dl.variation dd,
.cl-cart-meta dl.variation dd {
    margin: 0;
    color: var(--cl-ink);
    overflow-wrap: anywhere;
}

.cl-mc__meta dl.variation dd p,
.cl-cart-meta dl.variation dd p {
    margin: 0;
}

.cl-cf-photo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cl-cf-photo img {
    width: 34px;
    height: 34px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #eae3d7;
}

.cl-mc__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding-top: 4px;
}

.cl-mc__qty-fixed {
    font-size: 12px;
    color: var(--cl-muted);
}

/* Stepper condiviso (drawer + pagina carrello) */
.cl-stepper {
    display: inline-flex;
    align-items: center;
    height: 36px;
    border: 1px solid #d8cdb9;
    border-radius: 999px;
    background: #fff;
}

.cl-stepper__btn {
    width: 34px;
    height: 34px;
    border: 0;
    background: none;
    color: var(--cl-ink);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
}

.cl-stepper__btn:hover:not(:disabled) {
    background: #f5f0e8;
}

.cl-stepper__btn:disabled {
    color: #cfc6b8;
    cursor: not-allowed;
}

.cl-stepper__value {
    min-width: 26px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
}

.cl-mc__remove {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 0;
    background: none;
    padding: 6px 0;
    color: var(--cl-muted);
    font: 600 12px/1 var(--font-body), sans-serif;
    cursor: pointer;
}

.cl-mc__remove:hover {
    color: #a3281a;
}

/* ── Footer: totale + CTA ── */
.cl-mc__foot {
    flex-shrink: 0;
    padding: 18px 22px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--cl-line);
    background: #fff;
    box-shadow: 0 -10px 30px rgba(35, 34, 29, .05);
}

.cl-mc__subtotal {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 15px;
    font-weight: 600;
}

.cl-mc__subtotal strong {
    font-size: 19px;
    font-weight: 800;
}

.cl-mc__note {
    margin: 4px 0 14px;
    font-size: 12px;
    color: var(--cl-muted);
}

.cl-mc__checkout.cl-button {
    display: flex;
    width: 100%;
    gap: 10px;
    min-height: 52px;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    text-transform: none;
    letter-spacing: 0;
}

.cl-mc__cart-link {
    display: block;
    margin-top: 10px;
    padding: 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--cl-ink);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ── Vuoto ── */
.cl-mc__empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 48px 28px;
    text-align: center;
    color: var(--cl-muted);
    font-size: 14px;
}

.cl-mc__empty p {
    margin: 0;
}

.cl-mc__empty-title {
    margin-top: 10px !important;
    font-family: var(--font-baloo), sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--cl-ink);
}

.cl-mc__empty .cl-button {
    margin-top: 16px;
    text-decoration: none;
}

/* ── Pagina prodotto: errori inline + stato loading ── */
.cl-atc-error {
    flex-basis: 100%;
    margin: 10px 0 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: #fdecea;
    color: #8a1f11;
    font-size: 13px;
    font-weight: 600;
}

.single_add_to_cart_button.loading {
    opacity: .6;
    cursor: progress;
}

/* Link "Visualizza carrello" di wc-add-to-cart: sostituito dal drawer */
a.added_to_cart.wc-forward {
    display: none !important;
}

/* Badge header: vuoto a carrello vuoto */
.cl-cart-badge:empty {
    display: none;
}

/* Blocca scroll body quando drawer aperto */
body.cl-cart-open {
    overflow: hidden;
}

/* ── Responsive ── */
@media (max-width: 639px) {
    .creatilab-cart-drawer__panel {
        width: 100vw;
    }
    .cl-mc__item {
        grid-template-columns: 72px 1fr;
        padding: 14px 16px;
    }
    .cl-mc__thumb {
        width: 72px;
    }
    .creatilab-cart-drawer__head,
    .cl-mc__foot {
        padding-left: 16px;
        padding-right: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .creatilab-cart-drawer,
    .creatilab-cart-drawer__overlay,
    .creatilab-cart-drawer__panel {
        transition: none;
    }
}
