/* ═══════════════════════════════════════
   LOADING STATES — compteur + barre progression
   Technique Shopify : feedback immédiat, shimmer pendant chargement
   ═══════════════════════════════════════ */

/* ─── Overlay gris — bloque les clics pendant chargement ─── */
.tp-cart-overlay-loading {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.55);
    z-index: 9999;
    cursor: wait;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    border-radius: inherit;
}
.tp-cart-overlay-loading.tp-loading {
    opacity: 1;
    visibility: visible;
}

/* ─── Barre de chargement en haut du panneau ─── */
.tp-cart-loader {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 10000;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.tp-cart-loader.tp-loading {
    opacity: 1;
}
.tp-cart-loader.tp-loading::after {
    content: '';
    display: block;
    height: 100%;
    width: 40%;
    background: #C9A84C;
    border-radius: 0 2px 2px 0;
    animation: tp-loader-slide 1.2s ease infinite;
}
@keyframes tp-loader-slide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* Compteur panier : pulse pendant chargement */
.tp-cart-count.tp-count-loading {
    animation: tp-count-pulse 0.8s ease infinite;
}
@keyframes tp-count-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* Barre progression : shimmer pendant chargement */
.tp-progress-fill.tp-progress-loading::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.45) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: tp-shimmer 1.2s ease infinite;
}
@keyframes tp-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ─── Ligne bundle groupée dans le side cart ─── */
.tp-sidecart-bundle-imgs {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    width: 72px;
    height: 88px;
    flex-shrink: 0;
    align-content: flex-start;
}
.tp-sidecart-bundle-imgs img {
    width: 34px;
    height: 34px;
    object-fit: cover;
    border-radius: 5px;
    flex-shrink: 0;
}
.tp-sidecart-bundle-imgs img:only-child {
    width: 72px;
    height: 72px;
}
.tp-sidecart-bundle-names {
    font-size: 11px;
    color: #888;
    margin: 2px 0 4px;
    line-height: 1.4;
}

/* ─── Prix barré + réduit pour items bundle ─── */
.tp-price-original {
    text-decoration: line-through;
    color: #bbb;
    font-size: 11px;
    margin-right: 4px;
    font-weight: 400;
}
.tp-price-bundle {
    color: #C9A84C;
    font-weight: 700;
}

/* ═══════════════════════════════════════
   SIDE CART — Slide-in from right
   ═══════════════════════════════════════ */

.tp-sidecart-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.4);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.tp-sidecart-overlay.open { opacity: 1; visibility: visible; }

.tp-sidecart {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: 420px;
    max-width: 85vw;
    background: var(--white);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 16px rgba(0,0,0,0.08);
}
.tp-sidecart.open { transform: translateX(0); }

/* Header */
.tp-sidecart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
}
.tp-sidecart-header h3 {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.tp-sidecart-close {
    font-size: 20px;
    color: var(--gray-500);
    padding: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}
.tp-sidecart-close:hover { color: var(--black); background: var(--gray-100); }

/* Progress */
.tp-sidecart-progress {
    padding: 10px 20px;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
}

/* Items container */
.tp-sidecart-items {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Single item */
.tp-sidecart-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid #e5e5e5;
    position: relative;
    animation: tp-item-in 0.2s ease;
}
.tp-sidecart-item:last-child { border-bottom: none; }

@keyframes tp-item-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tp-sidecart-item-img {
    width: 72px;
    height: 88px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--gray-100);
    flex-shrink: 0;
}
.tp-sidecart-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tp-sidecart-item-info {
    flex: 1;
    min-width: 0;
}
.tp-sidecart-item-info h4 {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.3;
    margin-bottom: 4px;
}

.tp-sidecart-badge-bundle {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--gold);
    color: var(--white);
    padding: 2px 6px;
    border-radius: 3px;
    margin-bottom: 4px;
}

.tp-sidecart-item-price {
    font-size: 12px;
    font-weight: 500;
    display: block;
    margin-bottom: 8px;
}

/* Quantity controls */
.tp-sidecart-item-qty {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #e5e5e5;
    border-radius: 0;
    width: fit-content;
}
.tp-qty-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--black);
    transition: background 0.2s;
}
.tp-qty-btn:hover { background: var(--gray-100); }
.tp-qty-value {
    width: 32px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
}

/* Remove button */
.tp-sidecart-item-remove {
    position: absolute;
    top: 14px;
    right: 0;
    color: var(--gray-500);
    padding: 4px;
    transition: color 0.2s;
}
.tp-sidecart-item-remove:hover { color: #c0392b; }

/* Empty state */
.tp-sidecart-empty {
    text-align: center;
    padding: 40px 0;
}
.tp-sidecart-empty p {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

/* Upsell section */
.tp-sidecart-upsell {
    padding: 12px 20px;
    border-top: 1px solid #e5e5e5;
    flex-shrink: 0;
    max-height: 200px;
    overflow-y: auto;
}
.tp-sidecart-upsell h4 {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.tp-sidecart-upsell-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tp-sidecart-upsell-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tp-sidecart-upsell-img {
    width: 56px;
    height: 68px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--gray-100);
}
.tp-sidecart-upsell-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tp-sidecart-upsell-info {
    flex: 1;
    min-width: 0;
}
.tp-sidecart-upsell-name {
    display: block;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
}
.tp-sidecart-upsell-price {
    font-size: 11px;
    font-weight: 600;
}
.tp-sidecart-upsell-teaser {
    display: block;
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 2px;
}
.tp-sidecart-upsell-teaser strong {
    color: var(--black);
    font-weight: 700;
}

/* Upsell supprimé — caché si présent dans le HTML */
.tp-sidecart-upsell { display: none !important; }

/* Footer — total uniquement, le bouton Commander est dans la sticky bar */
.tp-sidecart-footer {
    padding: 12px 20px;
    border-top: 1px solid #e5e5e5;
    flex-shrink: 0;
    background: #fafafa;
}

.tp-sidecart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    width: 100%;
}
.tp-sidecart-total strong {
    font-size: 16px;
    margin-left: auto;
    text-align: right;
}

/* ── Barre Commander sticky ────────────────────────────────────────────────
   Alignée sur le panneau side cart (right:0, même largeur).
   Apparaît uniquement quand le panier est ouvert avec des items.
   iOS safe area : padding-bottom avec env(safe-area-inset-bottom).     */
#tp-checkout-sticky-bar {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 420px;
    max-width: 85vw;
    padding: 12px 20px;
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 12px);
    background: #fff;
    border-top: 1px solid #e5e5e5;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.10);
    z-index: 10000;
    transform: translateY(100%);
    transition: transform 0.25s ease;
}
#tp-checkout-sticky-bar.tp-sticky-visible {
    transform: translateY(0);
}

/* Espace sous les items pour ne pas masquer le footer avec la sticky bar.
   Sur iOS (env(safe-area-inset-bottom) ≈ 34px), la sticky bar fait ~90px — le
   padding doit en tenir compte pour que le total reste entièrement visible. */
.tp-sidecart.tp-cart-open-items {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
}
