/* ==========================================================================
   Panier lateral (drawer) - DoudouPlanet
   Cree le 20/07/2026. Remplace l'ancienne popup colorbox d'ajout au panier.
   Autonome : aucune dependance (pas de jQuery), compatible mobile/tablette/PC.
   ========================================================================== */

:root {
    --ddp-drawer-largeur: 420px;
    --ddp-accent: #2c3e50;          /* boutons principaux */
    --ddp-accent-hover: #1d2b38;
    --ddp-vert: #1e8449;            /* en stock / livraison offerte */
    --ddp-rouge: #c0392b;           /* promo */
    --ddp-gris-bord: #e3e3e3;
    --ddp-gris-texte: #6b6b6b;
}

/* ---------- voile sombre ---------- */
#ddp-drawer-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility .3s ease;
    z-index: 99998;
}
#ddp-drawer-overlay.ddp-ouvert { opacity: 1; visibility: visible; }

/* ---------- panneau lateral ---------- */
#ddp-drawer {
    position: fixed;
    top: 0; right: 0;
    height: 100%;
    width: var(--ddp-drawer-largeur);
    max-width: 100%;
    background: #fff;
    box-shadow: -3px 0 18px rgba(0, 0, 0, .18);
    transform: translateX(100%);
    transition: transform .3s ease;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #333;
}
#ddp-drawer.ddp-ouvert { transform: translateX(0); }

/* ---------- entete ---------- */
.ddp-drawer-entete {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--ddp-gris-bord);
    flex: 0 0 auto;
}
.ddp-drawer-entete .ddp-panier-icone { position: relative; font-size: 26px; line-height: 1; }
.ddp-drawer-entete .ddp-badge {
    position: absolute; top: -6px; right: -8px;
    background: var(--ddp-vert); color: #fff;
    border-radius: 50%;
    min-width: 18px; height: 18px;
    font-size: 11px; font-weight: bold;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
}
.ddp-drawer-titre { flex: 1; font-size: 17px; font-weight: bold; text-transform: uppercase; letter-spacing: .3px; margin: 0; }
.ddp-drawer-fermer {
    background: none; border: 0; cursor: pointer;
    font-size: 26px; line-height: 1; color: #555; padding: 0 4px;
}
.ddp-drawer-fermer:hover { color: #000; }

/* ---------- bandeau stock / vider ---------- */
.ddp-drawer-sousentete {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 18px 12px;
    border-bottom: 1px solid var(--ddp-gris-bord);
    flex: 0 0 auto;
}
.ddp-stock-ok { color: var(--ddp-vert); font-size: 13px; }
.ddp-vider { font-size: 13px; color: var(--ddp-gris-texte); text-decoration: underline; cursor: pointer; background: none; border: 0; }
.ddp-vider:hover { color: var(--ddp-rouge); }

/* ---------- liste des articles (zone scrollable) ---------- */
.ddp-drawer-corps {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 18px;
}
.ddp-article { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid #f0f0f0; }
.ddp-article-img { flex: 0 0 70px; }
.ddp-article-img img { width: 70px; height: auto; display: block; border: 1px solid #eee; }
.ddp-article-infos { flex: 1; min-width: 0; }
.ddp-article-nom { font-weight: bold; line-height: 1.3; margin: 0 0 3px; font-size: 13.5px; }
.ddp-article-nom a { color: #333; text-decoration: none; }
.ddp-article-nom a:hover { text-decoration: underline; }
.ddp-article-attr { font-size: 12px; color: var(--ddp-gris-texte); margin-bottom: 4px; }
.ddp-article-stock { font-size: 12px; color: var(--ddp-vert); margin-bottom: 8px; }
.ddp-article-stock.ddp-alerte { color: #b9770e; }

.ddp-article-bas { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ddp-qte { display: inline-flex; align-items: center; border: 1px solid var(--ddp-gris-bord); border-radius: 3px; overflow: hidden; }
.ddp-qte button {
    background: #fafafa; border: 0; width: 30px; height: 30px;
    font-size: 17px; line-height: 1; cursor: pointer; color: #444;
}
.ddp-qte button:hover:not(:disabled) { background: #ececec; }
.ddp-qte button:disabled { opacity: .35; cursor: not-allowed; }
.ddp-qte .ddp-qte-val { min-width: 32px; text-align: center; font-size: 14px; }

.ddp-article-prix { text-align: right; white-space: nowrap; }
.ddp-prix-barre { text-decoration: line-through; color: #999; font-size: 12px; margin-right: 4px; }
.ddp-prix-remise { color: var(--ddp-rouge); font-size: 12px; font-weight: bold; margin-right: 4px; }
.ddp-prix-final { font-weight: bold; font-size: 15px; }
.ddp-supprimer { background: none; border: 0; cursor: pointer; color: #999; font-size: 16px; padding: 2px 4px; }
.ddp-supprimer:hover { color: var(--ddp-rouge); }

/* ---------- panier vide ---------- */
.ddp-vide { text-align: center; padding: 48px 20px; color: var(--ddp-gris-texte); }
.ddp-vide .ddp-vide-icone { font-size: 46px; display: block; margin-bottom: 12px; }

/* ---------- pied : promo, total, actions ---------- */
.ddp-drawer-pied {
    flex: 0 0 auto;
    border-top: 1px solid var(--ddp-gris-bord);
    padding: 12px 18px 16px;
    background: #fff;
}
.ddp-promo-lien { font-size: 13px; color: var(--ddp-accent); text-decoration: underline; cursor: pointer; background: none; border: 0; padding: 0; }
.ddp-promo-zone { display: none; margin: 10px 0 4px; }
.ddp-promo-zone.ddp-visible { display: flex; gap: 6px; }
.ddp-promo-zone input {
    flex: 1; min-width: 0; padding: 8px 10px;
    border: 1px solid var(--ddp-gris-bord); border-radius: 3px; font-size: 13px;
}
.ddp-promo-zone button {
    background: var(--ddp-accent); color: #fff; border: 0;
    padding: 8px 14px; border-radius: 3px; cursor: pointer; font-size: 13px;
}
.ddp-promo-msg { font-size: 12px; margin-top: 6px; }
.ddp-promo-msg.ddp-ok { color: var(--ddp-vert); }
.ddp-promo-msg.ddp-ko { color: var(--ddp-rouge); }

.ddp-livraison-offerte {
    background: #eaf7ef; color: var(--ddp-vert);
    border-radius: 3px; padding: 8px 10px; margin: 10px 0;
    font-size: 13px; text-align: center;
}
.ddp-total { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 0 4px; }
.ddp-total-libelle { font-weight: bold; font-size: 14px; }
.ddp-total-libelle small { font-weight: normal; color: var(--ddp-gris-texte); }
.ddp-total-valeur { font-weight: bold; font-size: 19px; }

.ddp-btn-valider {
    display: block; width: 100%; box-sizing: border-box;
    background: var(--ddp-accent); color: #fff;
    border: 0; border-radius: 3px;
    padding: 14px; margin-top: 10px;
    font-size: 15px; font-weight: bold; text-align: center;
    text-decoration: none; cursor: pointer;
}
.ddp-btn-valider:hover { background: var(--ddp-accent-hover); color: #fff; text-decoration: none; }
.ddp-continuer { display: block; text-align: center; margin-top: 12px; font-size: 13px; color: var(--ddp-gris-texte); text-decoration: underline; cursor: pointer; background: none; border: 0; width: 100%; }

/* ---------- indicateur de chargement ---------- */
.ddp-drawer-chargement {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, .6);
    display: none; align-items: center; justify-content: center;
    z-index: 5;
}
#ddp-drawer.ddp-charge .ddp-drawer-chargement { display: flex; }
.ddp-spinner {
    width: 34px; height: 34px;
    border: 3px solid #ddd; border-top-color: var(--ddp-accent);
    border-radius: 50%;
    animation: ddp-tourne .8s linear infinite;
}
@keyframes ddp-tourne { to { transform: rotate(360deg); } }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* tablette */
@media (max-width: 900px) {
    :root { --ddp-drawer-largeur: 380px; }
}

/* mobile : le panneau occupe presque tout l'ecran */
@media (max-width: 600px) {
    :root { --ddp-drawer-largeur: 100%; }
    #ddp-drawer { width: 100%; }
    .ddp-drawer-entete { padding: 14px 14px 10px; }
    .ddp-drawer-corps { padding: 4px 14px; }
    .ddp-drawer-pied { padding: 10px 14px 14px; }
    .ddp-article-img { flex: 0 0 60px; }
    .ddp-article-img img { width: 60px; }
    /* cibles tactiles plus grandes */
    .ddp-qte button { width: 34px; height: 34px; }
    .ddp-supprimer { font-size: 18px; padding: 6px; }
    .ddp-btn-valider { padding: 15px; }
}

/* evite que la page defile derriere le panneau ouvert */
body.ddp-drawer-ouvert { overflow: hidden; }

/* respect des preferences d'accessibilite */
@media (prefers-reduced-motion: reduce) {
    #ddp-drawer, #ddp-drawer-overlay { transition: none; }
    .ddp-spinner { animation: none; }
}
