/* Panneau latéral du panier. Rendu et règles : inc/header/panier-lateral.php */

.th-cart {
    --th-blue: #2B4678;
    --th-yellow: #F7CA39;
    --th-dark: #242526;
    --th-light: #F8F8F8;
    --th-grey: #515151;
    position: fixed;
    inset: 0;
    z-index: 100000;              /* au-dessus de la recherche (99999) et de l'en-tête */
    font-family: "Roboto", Arial, sans-serif;
    color: var(--th-blue);
}
.th-cart[hidden] { display: none; }
.th-cart *, .th-cart *::before, .th-cart *::after { box-sizing: border-box; }
.th-cart__veil {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    transition: opacity .2s ease;
}
.th-cart__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    width: min(440px, 100%);
    background: var(--th-light);
    border-radius: 24px 0 0 24px;
    box-shadow: -10px 0 40px rgba(43, 70, 120, .25);
    transform: translateX(100%);
    transition: transform .22s ease;
    outline: none;
}
.th-cart.is-open .th-cart__veil { opacity: 1; }
.th-cart.is-open .th-cart__panel { transform: none; }

.th-cart__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 24px 14px;
}
.th-cart__titre { margin: 0; font-family: "Fira Sans", sans-serif; font-size: 22px; font-weight: 700; line-height: 26px; color: var(--th-blue); }
.th-cart button { font-family: inherit; text-transform: none; letter-spacing: normal; cursor: pointer; }
.th-cart .th-cart__close,
.th-cart .th-cart__close:hover,
.th-cart .th-cart__close:focus {
    width: 36px;
    height: 36px;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: var(--th-blue) !important;
    color: #fff !important;
    font-size: 22px;
    line-height: 36px;
}

.th-cart-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding: 4px 24px 20px; /* 4 px en haut : la zone défile et couperait l'anneau (box-shadow) de la 1re carte */
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Confirmation d'ajout */
.th-cart-added {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 0 14px;
    padding: 12px 14px 12px 44px;
    border-radius: 14px;
    background: rgba(247, 202, 57, .25);
    border: 1px solid var(--th-yellow);
    position: relative;
    font-size: 13px;
    line-height: 18px;
    color: var(--th-dark);
    animation: th-cart-pop .25s ease-out;
}
.th-cart-added::before {
    content: "✓";
    position: absolute;
    left: 12px;
    top: 12px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--th-blue);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}
.th-cart-added strong { font-size: 14px; color: var(--th-blue); }
.th-cart-added[hidden] { display: none; }
@keyframes th-cart-pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

.th-cart-empty { margin: 24px 0; font-size: 15px; font-weight: 600; color: var(--th-grey); }

/* Lignes */
.th-cart-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.th-cart-item {
    position: relative;
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 4px 12px;
    padding: 10px 36px 10px 10px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 0 0 1.6px #DCDCDC;
    transition: box-shadow .2s ease, opacity .2s ease;
}
.th-cart-item.is-new { box-shadow: 0 0 0 2px var(--th-yellow); }
.th-cart-item.is-busy { opacity: .45; pointer-events: none; }
.th-cart-item__img {
    grid-row: span 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 62px;
    border-radius: 12px;
    background: #F1F1F1;
}
.th-cart-item__img img { max-width: 82%; max-height: 82%; width: auto; height: auto; object-fit: contain; mix-blend-mode: multiply; }
.th-cart-item__txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.th-cart-item__nom { font-family: "Fira Sans", sans-serif; font-size: 15px; font-weight: 700; line-height: 19px; color: var(--th-blue) !important; text-decoration: none !important; }
.th-cart-item__nom:hover { text-decoration: underline !important; }
.th-cart-item__var { font-size: 12px; font-weight: 600; line-height: 16px; color: var(--th-dark); }
.th-cart-item__ref, .th-cart-item__qte { font-size: 12px; font-weight: 700; line-height: 16px; color: var(--th-grey); opacity: .75; }
.th-cart-item__prix {
    grid-column: 2;
    justify-self: start;
    padding: 2px 10px;
    border-radius: 30px;
    background: var(--th-yellow);
    font-family: "Fira Sans", sans-serif;
    font-size: 15px;
    font-weight: 700;
    line-height: 20px;
    color: var(--th-blue);
}
.th-cart-item__prix small { font-family: "Roboto", sans-serif; font-size: 11px; }
.th-cart .th-cart-item__del,
.th-cart .th-cart-item__del:hover,
.th-cart .th-cart-item__del:focus {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: rgba(43, 70, 120, .08) !important;
    color: var(--th-blue) !important;
    font-size: 16px;
    line-height: 24px;
}
.th-cart .th-cart-item__del:hover { background: var(--th-blue) !important; color: #fff !important; }

.th-cart-total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 16px 0 0;
    padding-top: 14px;
    border-top: 1px solid rgba(43, 70, 120, .14);
    font-size: 15px;
    font-weight: 700;
}
.th-cart-total strong { font-family: "Fira Sans", sans-serif; font-size: 20px; }

.th-cart-actions { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding-top: 18px; }
.th-cart .th-cart-btn {
    display: flex;
    justify-content: center;
    width: 100%;
    height: 48px;
    padding: 0 20px;
    border-radius: 30px;
    background: var(--th-blue);
    color: #FAFAFA !important;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none !important;
}
.th-cart .th-cart-btn:hover { filter: brightness(1.18); }
.th-cart-link { align-self: center; font-size: 14px; font-weight: 600; color: var(--th-blue) !important; text-decoration: underline !important; text-underline-offset: 3px; }
.th-cart .th-cart-continue,
.th-cart .th-cart-continue:hover,
.th-cart .th-cart-continue:focus {
    width: 100%;
    height: 44px;
    padding: 0 20px !important;
    border: 1.5px solid var(--th-blue) !important;
    border-radius: 30px !important;
    background: transparent !important;
    color: var(--th-blue) !important;
    font-size: 14px;
    font-weight: 600;
}
.th-cart .th-cart-continue:hover { background: rgba(43, 70, 120, .06) !important; }

.th-cart-help {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 8px;
    margin: 16px 0 0;
    padding: 12px;
    border-radius: 14px;
    background: rgba(43, 70, 120, .06);
    font-size: 13px;
    font-weight: 600;
    color: var(--th-grey);
    text-align: center;
}
.th-cart-help a { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--th-blue) !important; text-decoration: none !important; }
.th-cart-help svg { width: 13px; height: 13px; color: var(--th-yellow); }

@media (max-width: 600px) {
    .th-cart__panel { border-radius: 0; }
    .th-cart__head, .th-cart-body { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .th-cart__panel, .th-cart__veil, .th-cart-added { transition: none; animation: none; }
}
