/**
 * WooBedding Cart - Optimized Layout v4.1
 */

/* ================================================
   VARIABLES
   ================================================ */
:root {
    --primary: #013366;
    --primary-dark: #002244;
    --border: #e9ecef;
    --gray: #6c757d;
    --text: #212529;
    --bg: #f8f9fa;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ================================================
   BASE
   ================================================ */
* {
    box-sizing: border-box;
}

.woobedding-custom-cart-container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 2rem 1rem;
    font-family: system-ui, -apple-system, sans-serif;
}

/* ================================================
   CART HEADER
   ================================================ */
.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.cart-header h1 {
    font-size: 1.875rem;
    margin: 0;
    color: var(--text);
}

.cart-count {
    color: var(--gray);
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

.continue-shopping {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.continue-shopping:hover {
    color: var(--primary-dark);
}

/* ================================================
   LAYOUT - DESKTOP OTTIMIZZATO
   ================================================ */
.cart-layout {
    width: 100%;
}

/* Mobile */
@media (max-width: 991px) {
    .cart-layout {
        display: block;
    }

    .cart-products,
    .cart-summary {
        width: 100%;
        margin-bottom: 2rem;
    }
}

/* Desktop - 2 colonne ben proporzionate */
@media (min-width: 992px) {
    .cart-layout {
        display: flex !important;
        gap: 2rem;
        align-items: flex-start;
    }

    .cart-products {
        flex: 1;
        min-width: 0;
    }

    .cart-summary {
        width: 380px;
        flex-shrink: 0;
        position: sticky;
        top: 2rem;
    }
}

/* ================================================
   PRODOTTI - LAYOUT COMPATTO
   ================================================ */
.cart-products {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.cart-items {
    margin-bottom: 1rem;
}

/* Layout prodotto - Mobile */
.cart-item {
    display: flex;
    flex-wrap: wrap;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.cart-item:last-child {
    border-bottom: none;
}

/* ================================================
   DESKTOP - LAYOUT DUE RIGHE
   ================================================ */
@media (min-width: 992px) {
    .cart-item {
        display: grid !important;
        grid-template-columns: 100px 1fr 40px !important;
        grid-template-rows: auto auto !important;
        gap: 1rem !important;
        padding: 1.25rem 0;
        align-items: start;
    }

    /* Immagine - occupa entrambe le righe */
    .item-image {
        grid-column: 1;
        grid-row: 1 / 3;
        align-self: center;
        width: 100px;
    }

    /* Dettagli prodotto - prima riga, larghezza piena */
    .item-details {
        grid-column: 2;
        grid-row: 1;
        padding: 0;
    }

    /* Quantità - seconda riga a sinistra */
    .item-quantity {
        grid-column: 2;
        grid-row: 2;
        justify-self: start;
        margin-top: 0;
        width: auto;
    }

    /* Subtotale - seconda riga a destra */
    .item-subtotal {
        grid-column: 2;
        grid-row: 2;
        justify-self: end;
        margin: 0;
        text-align: right;
    }

    /* Pulsante rimuovi - prima riga all'estrema destra */
    .remove-item,
    .item-remove {
        grid-column: 3;
        grid-row: 1;
        position: relative;
        top: 0;
        right: 0;
        margin: 0;
    }
}

/* Immagine */
.item-image {
    width: 90px;
    flex-shrink: 0;
}

.item-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Dettagli prodotto */
.item-details {
    flex: 1;
    min-width: 0;
    padding: 0 1rem;
}

.item-details h4 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 0.375rem 0;
    color: var(--text);
}

.item-details a {
    color: inherit;
    text-decoration: none;
}

.item-details a:hover {
    color: var(--primary);
}

/* Varianti su riga separata */
.item-variations {
    margin-bottom: 0.375rem;
    padding-top: 0.375rem;
    border-top: 1px solid #f0f0f0;
}

.item-variations dl,
.item-variations ul {
    margin: 0;
    padding: 0;
}

.item-variations dt {
    display: inline;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--gray);
    margin-right: 0.25rem;
}

.item-variations dd {
    display: inline;
    font-size: 0.8rem;
    color: var(--text);
    background: var(--bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-right: 0.5rem;
    margin-left: 0;
}

.item-variations dd:after {
    content: "";
    display: block;
    margin-bottom: 0.25rem;
}

/* Meta stagione */
.item-meta {
    font-size: 0.8rem;
    color: var(--gray);
}

.wc-item-meta li {
    list-style: none;
    display: inline;
    margin-right: 0.75rem;
}

/* Quantità */
.item-quantity {
    margin-top: 0.75rem;
    width: 100%;
}

.quantity-wrapper {
    display: inline-flex;
    align-items: center;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: white;
    height: 38px;
}

.qty-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 34px;
    cursor: pointer;
    font-size: 1.125rem;
    color: var(--gray);
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover {
    background: var(--bg);
    color: var(--primary);
}

.qty-input {
    width: 45px;
    border: none;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
}

/* Subtotale */
.item-subtotal {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
    margin-left: auto;
}

/* Bottone rimuovi */
.remove-item,
.item-remove a {
    width: 28px;
    height: 28px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--gray);
    text-decoration: none;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 20px;
    line-height: 1;
    padding: 0;
    text-align: center;
}

/* Nascondi i br dentro il link */
.remove-item br,
.item-remove a br {
    display: none !important;
}

.remove-item:hover,
.item-remove a:hover {
    background: #fee;
    border-color: #dc3545;
    color: #dc3545;
    transform: scale(1.1);
}

/* Mobile layout specifico */
@media (max-width: 991px) {
    .cart-item {
        padding-left: 105px;
        position: relative;
        padding-bottom: 1.5rem;
        min-height: 120px;
    }

    .item-image {
        position: absolute;
        left: 0;
        top: 1.25rem;
        width: 90px;
    }

    .item-details {
        padding: 0;
        padding-right: 35px; /* Spazio per il bottone rimuovi */
        width: 100%;
        margin-bottom: 1rem;
    }

    .item-quantity {
        display: block;
        width: 100%;
        margin-bottom: 0.75rem;
        margin-left: 0;
        clear: both;
    }

    .item-subtotal {
        display: block;
        width: 100%;
        margin-top: 0;
        text-align: left;
        font-size: 1rem;
        clear: both;
    }

    .remove-item,
    .item-remove {
        position: absolute;
        top: 1rem;
        right: 0;
    }
}

/* ================================================
   RIEPILOGO ORDINE
   ================================================ */
.summary-box {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.summary-box h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1.5rem 0;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary);
}

/* Lista prodotti nel riepilogo */
.order-items-summary {
    max-height: 300px;
    overflow-y: auto;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.6rem 0;
    gap: 0.75rem;
}

.summary-item-info {
    flex: 1;
    min-width: 0;
    padding-right: 0.5rem;
}

.summary-item-name {
    display: block;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

/* Raggruppa quantità e prezzo insieme */
.summary-item-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    white-space: nowrap;
}

.summary-item-qty {
    color: var(--gray);
    font-size: 0.75rem;
}

.summary-item-price {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
    white-space: nowrap;
}

/* Totali */
.cart-totals {
    margin-bottom: 1.5rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0;
    font-size: 0.9rem;
}

.total-row:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.total-row span:last-child {
    font-weight: 600;
}

.total-row.total-final {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
    border-top: 2px solid var(--primary);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

/* Coupon discount */
.total-row.coupon-discount {
    background: linear-gradient(90deg, rgba(1,51,102,0.03) 0%, transparent 100%);
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    border-radius: 6px;
}

.total-row.coupon-discount .remove-coupon {
    margin-left: 0.5rem;
    color: var(--gray);
    text-decoration: none;
    font-size: 1.25rem;
}

.total-row.coupon-discount .remove-coupon:hover {
    color: #dc3545;
}

/* Checkout button */
.checkout-button {
    display: block;
    width: 100%;
    padding: 0.9rem;
    background: var(--primary);
    color: white !important;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 600;
    transition: all 0.2s;
}

.checkout-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(1,51,102,0.2);
}

.secure-badge {
    display: block;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    opacity: 0.9;
}

/* Trust badges */
.trust-badges {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.trust-badge {
    margin-bottom: 0.75rem;
}

/* Stile uniforme per wrapper e link */
.trust-badge .badge-wrapper,
.trust-badge a.badge-wrapper {
    display: flex;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
    padding: 0;
    margin: 0;
}

.badge-icon-wrapper {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.badge-icon-wrapper svg {
    width: 24px;
    height: 24px;
    color: white;
}

.badge-content {
    display: flex;
    flex-direction: column;
    padding-top: 4px;
    margin-left: 10px;
}

.badge-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.2;
    margin-bottom: 1px;
}

.badge-subtitle {
    font-size: 0.8rem;
    color: var(--gray);
    line-height: 1.2;
}

/* Hover effect */
.trust-badge:hover .badge-icon-wrapper {
    background: var(--primary-dark);
    transform: scale(1.05);
    transition: all 0.3s ease;
}

/* ================================================
   CARRELLO VUOTO
   ================================================ */
.woobedding-empty-cart {
    text-align: center;
    padding: 3rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.empty-cart-icon svg {
    width: 120px;
    height: 120px;
    margin-bottom: 2rem;
    color: var(--gray);
}

.woobedding-empty-cart h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.woobedding-empty-cart p {
    color: var(--gray);
    margin-bottom: 2rem;
}

.btn-primary, .btn-secondary {
    display: inline-block;
    padding: 0.75rem 2rem;
    margin: 0 0.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary);
    color: white !important;
}

.btn-secondary {
    background: white;
    border: 2px solid var(--primary);
    color: var(--primary);
}

/* ================================================
   COUPON
   ================================================ */
.cart-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.coupon-section {
    display: flex;
    gap: 0.5rem;
    max-width: 350px;
}

.coupon-section input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
}

.button {
    padding: 0.6rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
}

.button:hover {
    background: var(--primary-dark);
}