/* =========================================================================
   CL Cart Summary — Colonna riepilogo ordine (checkout sidebar)
   Palette: Giallo #f5c140 · Blu #0a2838 · Crema #fffef6 · Testo #000
   ========================================================================= */

/* ── STICKY — override per Elementor ────────────────────────────────────── */
/*
 * Per far funzionare position:sticky nella colonna Elementor:
 * - Il widget container deve occupare tutta l'altezza della colonna
 * - overflow:hidden sui parent Elementor blocca lo sticky → override
 */
.elementor-widget-cl-cart-summary {
    align-self: flex-start; /* evita che il widget si estenda oltre il proprio contenuto */
    position: sticky !important;
    top: 24px;
}

.elementor-widget-cl-cart-summary > .elementor-widget-container {
    overflow: visible;
}

/* Rimuove overflow:hidden dalla colonna e dal widget-wrap — bloccherebbe lo sticky */
.elementor-column:has(.elementor-widget-cl-cart-summary),
.elementor-column:has(.elementor-widget-cl-cart-summary) > .elementor-widget-wrap {
    overflow: visible !important;
}

/* ── WRAPPER ─────────────────────────────────────────────────────────────── */
.cl-summary-wrapper {
    background: #f9f9f7;
}

/* ── PRODOTTI ────────────────────────────────────────────────────────────── */
.cl-summary-items {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cl-summary-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #eee;
}

.cl-summary-item:last-child {
    border-bottom: none;
}

/* Thumbnail con badge quantità */
.cl-summary-item-thumb {
    position: relative;
    flex-shrink: 0;
}

.cl-summary-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    display: block;
}

.cl-summary-qty {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #555;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

/* Testi prodotto */
.cl-summary-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cl-summary-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #0a2838;
    line-height: 1.4;
    display: block;
}

.cl-summary-item-meta {
    font-size: 11px;
    color: #0a2838;
    display: block;
}

.cl-summary-item-price {
    font-size: 13px;
    font-weight: 600;
    color: #0a2838;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Pulsante × rimuovi prodotto */
.cl-item-remove {
    background: none;
    border: none;
    padding: 4px 6px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: #0a2838;
    flex-shrink: 0;
    transition: color 0.15s;
    margin-left: 4px;
    align-self: center;
}

.cl-item-remove:hover  { color: #c0392b; }
.cl-item-remove:disabled { opacity: 0.4; cursor: default; }

/* ── BUNDLE — STRUTTURA AD ALBERO ────────────────────────────────────────── */
/* Parent bundle: leggermente sfondo crema, niente border-bottom (continua nei figli) */
.cl-summary-item--bundle-parent {
    border-bottom: none;
    padding-bottom: 8px;
}

.cl-summary-item--bundle-parent .cl-summary-item-name {
    font-weight: 700;
}

/* Figli bundle: indentati con linea ad albero a sinistra */
.cl-summary-item--bundle-child {
    padding: 8px 0 8px 28px;
    border-bottom: none;
    position: relative;
}

/* Linea verticale dell'albero (parte da top, default piena altezza) */
.cl-summary-item--bundle-child::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #d8d8d8;
}

/* Linea orizzontale (gancio dell'albero al 50% verticale) */
.cl-summary-item--bundle-child::after {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    width: 14px;
    height: 1px;
    background: #d8d8d8;
}

/* Ultimo bundle-child di un gruppo: linea verticale solo fino al 50% */
.cl-summary-item--bundle-child:not(:has(+ .cl-summary-item--bundle-child))::before {
    bottom: auto;
    height: 50%;
}

/* Riapri il border-bottom dopo l'ultimo figlio del bundle */
.cl-summary-item--bundle-child:not(:has(+ .cl-summary-item--bundle-child)) {
    border-bottom: 1px solid #eee;
    padding-bottom: 14px;
}

/* Nome del figlio bundle — lievemente attenuato */
.cl-summary-item--bundle-child .cl-summary-item-name {
    color: #0a2838;
    font-size: 12.5px;
}

/* Thumbnail figli leggermente più piccolo per gerarchia visiva */
.cl-summary-item--bundle-child .cl-summary-img {
    width: 48px;
    height: 48px;
}

/* ── BADGE: OMAGGIO / incluso ───────────────────────────────────────────── */
.cl-summary-item-badge {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 5px 10px;
    border-radius: 4px;
    line-height: 1;
}

.cl-summary-item-badge--gift {
    background: #f5c140;
    color: #0a2838;
}

.cl-summary-item-badge--muted {
    background: transparent;
    color: #0a2838;
    font-weight: 500;
    text-transform: lowercase;
    letter-spacing: 0;
    font-size: 12px;
    padding: 0;
}

/* Badge "Bundle" sul parent del bundle — blu brand minimal, no background */
.cl-summary-item-badge--bundle {
    background: transparent;
    color: #0a2838;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    padding: 4px 10px;
    border: 1.5px solid #0a2838;
    border-radius: 4px;
}

/* ── RIGA ARROTONDAMENTO ────────────────────────────────────────────────── */
.cl-summary-rounding-row {
    color: #0a2838;
    font-size: 12.5px;
    font-style: italic;
}

/* ── UPGRADE — prezzo originale barrato + meta "Upgrade dal corso X" ───── */
.cl-summary-item-upgrade {
    display: block;
    font-size: 11px;
    color: #0a2838;
    opacity: 0.6;
    font-style: italic;
    margin-top: 3px;
    line-height: 1.3;
}

/* Wrapper prezzo upgrade — stack verticale (originale sopra, nuovo sotto) */
.cl-summary-item-price--upgrade {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    line-height: 1.2;
}

.cl-summary-item-price-original {
    color: #0a2838;
    opacity: 0.55;
    font-weight: 400;
    font-size: 11.5px;
    text-decoration: line-through;
}

.cl-summary-item-price-new {
    color: #0a2838;
    font-weight: 600;
    font-size: 13px;
}

/* ── DIVISORE ────────────────────────────────────────────────────────────── */
.cl-summary-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 20px 0;
}

/* ── COUPON ──────────────────────────────────────────────────────────────── */
.cl-summary-coupon {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.cl-coupon-input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 14px;
    color: #0a2838;
    background: #fff;
    outline: none;
    transition: border-color 0.15s;
}

.cl-coupon-input:focus {
    border-color: #0a2838;
}

.cl-coupon-input::placeholder {
    color: #aaa;
}

.cl-coupon-apply {
    padding: 10px 16px;
    border: 1.5px solid #0a2838;
    background: transparent;
    color: #0a2838;
    font-size: 13px;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.cl-coupon-apply:hover:not(:disabled) {
    background: #0a2838;
    color: #fff;
}

.cl-coupon-apply:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Messaggi feedback coupon */
.cl-coupon-message {
    font-size: 13px;
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 4px;
}

.cl-coupon-message .woocommerce-message,
.cl-msg-ok {
    background: #f0f8f0;
    color: #2a7a2a;
    border: 1px solid #b8e0b8;
}

.cl-coupon-message .woocommerce-error,
.cl-msg-err {
    background: #fce8e8;
    color: #c0392b;
    border: 1px solid #f5c0c0;
}

/* WC notice list inside message */
.cl-coupon-message ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* ── TOTALI ──────────────────────────────────────────────────────────────── */
.cl-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 14px;
    color: #0a2838;
    margin-bottom: 8px;
}

.cl-summary-row:last-child {
    margin-bottom: 0;
}

/* Riga sconto coupon / fee progressivo / promo — colore primario brand */
.cl-summary-discount-row {
    color: #0a2838;
    font-weight: 600;
}

.cl-summary-discount-row > span:first-child {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Pulsante × rimuovi coupon */
.cl-coupon-remove {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: #0a2838;
    transition: color 0.15s;
}

.cl-coupon-remove:hover { color: #c0392b; }

/* Riga totale */
.cl-summary-total-row {
    font-size: 16px;
    font-weight: 700;
    color: #0a2838;
    padding-top: 14px;
    margin-top: 6px;
    border-top: 1.5px solid #d0d0d0;
    margin-bottom: 4px;
}

/* Note IVA */
.cl-summary-vat {
    font-size: 12px;
    color: #0a2838;
    text-align: right;
    margin-top: 2px;
}

/* ── MOBILE ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .elementor-widget-cl-cart-summary {
        position: static !important;
    }

    .cl-summary-wrapper {
        position: static;
    }

    .cl-summary-coupon {
        flex-wrap: wrap;
    }

    .cl-coupon-input {
        width: 100%;
        flex: 0 0 100%;
    }

    .cl-coupon-apply {
        width: 100%;
        flex: 0 0 100%;
        text-align: center;
    }
}
