/* ===================================================================
   Configurateur BATSIGN — CSS mobile-first (320px+)
   =================================================================== */

:root {
    --orange: #f47216; /* orange du logo */
    --gris: #4f4c4d;   /* gris du logo */
    --c-bg: #f5f6f8;
    --c-surface: #ffffff;
    --c-surface-2: #f9fafb;
    --c-border: #e5e7eb;
    --c-text: #1a1a1a;
    --c-text-light: #6b7280;
    --c-primary: #1f2937;
    --c-primary-hover: #111827;
    --c-accent: #2563eb;
    --c-accent-hover: #1d4ed8;
    --c-success: #059669;
    --c-error: #dc2626;
    --c-warning: #d97706;
    --r-sm: 4px;
    --r-md: 8px;
    --r-lg: 12px;
    --espace-1: 8px;
    --espace-2: 16px;
    --espace-3: 24px;
    --espace-4: 32px;
    --transition: 150ms ease;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px; line-height: 1.5;
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-text-size-adjust: 100%;
}

a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; cursor: pointer; }

/* ===== Entête ===== */
.entete {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--c-primary);
    color: #fff;
    position: sticky; top: 0; z-index: 100;
}
.entete-logo {
    color: #fff; display: flex; align-items: baseline; gap: 8px;
    letter-spacing: 1px;
}
.entete-logo:hover { text-decoration: none; }
.entete-logo strong { font-size: 18px; }
.entete-logo span { font-size: 12px; opacity: 0.7; text-transform: uppercase; }
.entete-nav { display: flex; gap: 12px; }
.lien-panier {
    color: #fff;
    padding: 6px 12px;
    border-radius: var(--r-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.lien-panier:hover { background: rgba(255,255,255,0.1); text-decoration: none; }
.badge-panier {
    background: var(--c-accent);
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    padding: 2px 7px;
    min-width: 18px;
    text-align: center;
}

/* ===== Loader ===== */
.loader-initial {
    text-align: center;
    padding: 60px 20px;
    color: var(--c-text-light);
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--c-border);
    border-top-color: var(--c-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Layout principal ===== */
.configurateur { padding: var(--espace-2); max-width: 1400px; margin: 0 auto; }

.config-layout {
    display: flex;
    flex-direction: column;
    gap: var(--espace-2);
}

@media (min-width: 1024px) {
    .config-layout {
        display: grid;
        grid-template-columns: 1fr 320px;
        grid-template-areas:
            "apercu recap"
            "options recap";
        gap: var(--espace-3);
    }
    .bloc-apercu { grid-area: apercu; }
    .bloc-options { grid-area: options; }
    .bloc-recap { grid-area: recap; }
}

/* ===== Bloc aperçu ===== */
.bloc-apercu {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: var(--espace-2);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.apercu-info {
    margin: 0 0 var(--espace-2);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    color: #dc2626;
    text-align: center;
}
.apercu-info-lien {
    display: inline-block;
    padding: 5px 12px;
    background: var(--c-accent);
    color: #fff;
    border-radius: var(--r-sm);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    transition: var(--transition);
}
.apercu-info-lien:hover { background: var(--c-accent-hover); }
.apercu-conteneur {
    background: linear-gradient(135deg, #f3f4f6 25%, transparent 25%) -10px 0 / 20px 20px,
                linear-gradient(225deg, #f3f4f6 25%, transparent 25%) -10px 0 / 20px 20px,
                linear-gradient(45deg, #f3f4f6 25%, transparent 25%) 0 0 / 20px 20px,
                linear-gradient(315deg, #f3f4f6 25%, #fff 25%) 0 0 / 20px 20px;
    background-color: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    min-height: 200px;
    display: flex; align-items: center; justify-content: center;
    /* visible (et non hidden) pour ne pas couper le panneau popover du fond ;
       l'image a un padding, elle n'atteint jamais les coins arrondis. */
    overflow: visible;
    padding: var(--espace-2);
}
/* Rendu via image PNG generee cote serveur (api/preview.php) */
.apercu-conteneur { position: relative; }
.apercu-image {
    width: 100%;
    height: auto;
    display: block;
    max-height: 500px;
    object-fit: contain;
    transition: opacity 150ms;
}
.apercu-image.charge { opacity: 1; }
.apercu-image.charge-en-cours { opacity: 0.6; }
.apercu-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.apercu-loader[hidden] { display: none; }
.apercu-loader .spinner {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

.apercu-mention {
    margin: 8px 0 0;
    text-align: center;
    font-size: 11px;
    color: var(--c-text-light);
    font-style: italic;
}

/* Selecteur de couleur de fond : pastille unique en bas a droite de l'apercu,
   un clic ouvre un panneau contenant toute la palette (facon v1). */
.fond-selecteur {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 5;
}
.fond-declencheur {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 11px;
    color: var(--c-text-light);
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    transition: var(--transition);
}
.fond-declencheur:hover { background: #fff; }
.fond-pastille {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid var(--c-border);
    flex-shrink: 0;
}
.fond-declencheur-texte { white-space: nowrap; }

.fond-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    width: 340px;
    max-width: 80vw;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    box-shadow: 0 6px 20px rgba(0,0,0,0.18);
}
.fond-panel[hidden] { display: none; }

/* Swatches compacts : 58 couleurs affichees dans le panneau.
   Selecteur volontairement plus specifique (.fond-panel .palette-fonds) pour
   l'emporter sur .palette-couleurs, definie plus bas dans le fichier. */
.fond-panel .palette-fonds {
    grid-template-columns: repeat(auto-fill, minmax(26px, 1fr));
    gap: 5px;
}
.fond-panel .palette-fonds .swatch {
    min-width: 26px;
    min-height: 26px;
    border-width: 2px;
}
.fond-panel .palette-fonds .swatch::after {
    display: none; /* pas d'infobulle (couleurs sans nom) */
}

.dimensions {
    width: 100%;
    margin-top: var(--espace-2);
    border-collapse: collapse;
    font-size: 13px;
}
.dimensions caption {
    text-align: left;
    color: var(--c-text-light);
    font-size: 11px;
    padding: 4px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.dimensions th, .dimensions td {
    padding: 6px 4px;
    text-align: center;
    border-bottom: 1px solid var(--c-border);
}
.dimensions th { font-size: 10px; color: var(--c-text-light); text-transform: uppercase; font-weight: 600; }
.dimensions td { font-family: ui-monospace, monospace; }
.dimensions tbody tr:last-child td { border-bottom: 0; }
/* Valeurs (et non les libellés) en bleu dans le tableau « Valeurs indicatives ». */
.dimensions tbody td span { color: var(--c-accent); font-weight: 700; }
/* Valeurs H et L en bleu dans « Dimensions H × L mm » sous le réglage. */
.echelle-dimensions .dim-bleu { color: var(--c-accent); font-weight: 700; }

/* ===== Bloc options ===== */
.bloc-options {
    display: flex;
    flex-direction: column;
    gap: var(--espace-2);
}

/* Sur grand ecran : grille 2 colonnes pour les fieldsets courts.
   Les fieldsets .option-pleine prennent toute la largeur (matiere, vinyle, fixation...) */
@media (min-width: 768px) {
    .bloc-options {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--espace-2);
    }
    .bloc-options .option-pleine {
        grid-column: 1 / -1;
    }
    /* Les fieldsets courts (texte/police, interlettrage/taille) s'alignent
       a la meme hauteur dans leur rangee. Le contenu est centre verticalement. */
    .bloc-options .option:not(.option-pleine) {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}

/* Interlettrage + Dimensions : sur petit ecran, « Dimensions » s'affiche au-dessus
   d'« Interlettrage » (ordre DOM inverse via column-reverse). Sur grand ecran, le
   conteneur s'efface (display:contents) pour laisser les 2 fieldsets reprendre leur
   place normale dans la grille 2 colonnes. */
.paire-reglages {
    display: flex;
    flex-direction: column-reverse;
    gap: var(--espace-2);
}
@media (min-width: 768px) {
    .paire-reglages { display: contents; }
}
.option {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: var(--espace-2);
    margin: 0;
}
.option legend {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--orange);
    letter-spacing: 0.5px;
    padding: 0 6px;
}
.option input[type=text],
.option input[type=number],
.option select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    font-size: 15px;
    background: #fff;
    min-height: 44px;
}
.option input:focus, .option select:focus {
    outline: none;
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.option .aide {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--c-text-light);
}
.echelle-dimensions {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
}
.echelle-bornes {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: var(--c-text-light);
}

/* Onglets categories matieres : remplaces par la liste deroulante (masques partout) */
.onglets-categories {
    display: none;
}

/* Liste deroulante des categories de matieres (affichee partout) */
.select-categories-mobile {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    font-size: 15px;
    background: #fff;
    min-height: 44px;
    margin-bottom: var(--espace-2);
    display: block;
}
.onglet-categorie {
    padding: 8px 14px;
    border: 1px solid var(--c-border);
    background: var(--c-surface-2);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
    min-height: 44px;
}
.onglet-categorie:hover { background: #fff; }
.onglet-categorie.actif {
    background: var(--c-primary);
    color: #fff;
    border-color: var(--c-primary);
}

/* Palettes de couleurs */
.palette-couleurs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 8px;
}
.swatch {
    aspect-ratio: 1;
    border-radius: var(--r-sm);
    border: 2px solid transparent;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    background-size: cover; background-position: center;
    min-width: 44px; min-height: 44px;
}
.swatch:hover { transform: scale(1.05); }
.swatch.actif {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 2px #fff inset;
}
.swatch[data-clair="1"] { border-color: var(--c-border); }
.swatch[data-clair="1"].actif { border-color: var(--c-accent); }
.swatch::after {
    content: attr(data-titre);
    position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%);
    background: var(--c-primary); color: #fff; padding: 2px 6px;
    font-size: 10px; border-radius: 3px; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: var(--transition);
    z-index: 10;
}
.swatch:hover::after { opacity: 1; }

/* Section Matiere : deux colonnes sur grand ecran (controles ~60% / photo ~40%) */
.matiere-layout {
    display: flex;
    gap: var(--espace-2);
    align-items: flex-start;
}
.matiere-controles {
    flex: 1 1 60%;
    min-width: 0;
}
.matiere-sous-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: var(--espace-1);
}

/* Infobulle informative (icone "i") : survol PC, clic/tap mobile. */
.info-bulle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 5px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--c-accent);
    color: #fff;
    cursor: pointer;
    vertical-align: middle;
    text-transform: none;
}
.info-bulle-icone {
    font: italic 700 11px/1 Georgia, "Times New Roman", serif;
}
.info-bulle-texte {
    position: absolute;
    bottom: calc(100% + 9px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: min(260px, 72vw);
    background: #1f2937;
    color: #fff;
    font: 400 12.5px/1.45 inherit;
    text-transform: none;
    letter-spacing: 0;
    text-align: left;
    padding: 9px 11px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s, visibility .15s;
    z-index: 30;
    pointer-events: none;
}
.info-bulle-texte::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1f2937;
}
.info-bulle:hover .info-bulle-texte,
.info-bulle:focus-visible .info-bulle-texte,
.info-bulle.ouvert .info-bulle-texte {
    opacity: 1;
    visibility: visible;
}
.couleur-matiere-bloc[hidden] { display: none; }
.epaisseur-bloc { margin-bottom: var(--espace-2); }
.matiere-note {
    margin: 0 0 var(--espace-2);
    padding: 8px 12px;
    background: var(--c-surface-2);
    border-left: 3px solid var(--c-accent);
    border-radius: var(--r-sm);
    font-size: 13px;
    color: var(--c-text);
}
.matiere-note[hidden] { display: none; }
.vinyle-bloc { margin-top: var(--espace-2); }
.vinyle-bloc[hidden] { display: none; }
.chant-profil-bloc { margin-top: var(--espace-2); }
.chant-profil-bloc[hidden] { display: none; }
.chant-profil-choix { display: flex; gap: 14px; }
.chant-option {
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    cursor: pointer; padding: 2px;
}
.chant-option input { position: absolute; opacity: 0; pointer-events: none; }
.chant-swatch {
    width: 56px; height: 36px;
    border-radius: var(--r-sm);
    border: 2px solid var(--c-border);
    transition: var(--transition);
}
.chant-swatch-blanc { background: #ffffff; }
.chant-swatch-noir { background: #1a1a1a; }
.chant-option input:checked + .chant-swatch {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 2px var(--c-accent);
}
.chant-nom { font-size: 13px; color: var(--c-text); }

/* Menu deroulant couleur personnalise (pastille + nom) */
.select-couleur { position: relative; }
.select-couleur-declencheur {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    min-height: 44px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    background: #fff;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}
.select-couleur-declencheur:hover { border-color: var(--c-accent); }
.select-couleur-pastille {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 1px solid transparent;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #dc2626;
    font-size: 16px;
    line-height: 1;
}
.select-couleur-pastille[data-clair="1"] { border-color: var(--c-border); }
.select-couleur-nom { flex: 1; }
.select-couleur-fleche { color: var(--c-text-light); flex-shrink: 0; }

.select-couleur-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 280px;
    overflow-y: auto;
    padding: 4px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
.select-couleur-panel[hidden] { display: none; }
.select-couleur-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border: none;
    background: none;
    border-radius: var(--r-sm);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}
.select-couleur-option:hover { background: var(--c-surface-2); }
.select-couleur-option.actif {
    background: rgba(37, 99, 235, 0.1);
    font-weight: 600;
}
.select-couleur-option-nom { flex: 1; }

/* Menu deroulant des polices (chaque nom dans sa propre police) */
.select-police { position: relative; }
.select-police-declencheur {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    min-height: 44px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    background: #fff;
    font-size: 16px;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}
.select-police-declencheur:hover { border-color: var(--c-accent); }
.select-police-nom { flex: 1; line-height: 1.3; }

.select-police-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 320px;
    overflow-y: auto;
    padding: 4px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
.select-police-panel[hidden] { display: none; }
.select-police-option {
    width: 100%;
    display: block;
    padding: 9px 10px;
    border: none;
    background: none;
    border-radius: var(--r-sm);
    font-size: 18px;
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
}
.select-police-option:hover { background: var(--c-surface-2); }
.select-police-option.actif {
    background: rgba(37, 99, 235, 0.1);
}

.apercu-matiere {
    flex: 0 0 40%;
    display: flex;
    justify-content: center;
}
.apercu-matiere[hidden] { display: none; }
.apercu-matiere-photo {
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    border-radius: var(--r-sm);
    border: 1px solid var(--c-border);
    background: var(--c-surface-2);
    display: block;
}

/* Petit ecran : on empile (photo sous les controles) */
@media (max-width: 767px) {
    .matiere-layout { flex-direction: column; }
    .matiere-controles { flex: 1 1 auto; width: 100%; }
    .apercu-matiere { flex: 1 1 auto; width: 100%; }
    .apercu-matiere-photo { max-width: 260px; }
    /* Plus de place pour l'apercu sur petit ecran */
    .apercu-conteneur { padding: var(--espace-1); }
}

/* Vinyles options supplémentaires */
.vinyle-options {
    margin-top: var(--espace-2);
    padding-top: var(--espace-2);
    border-top: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    gap: var(--espace-2);
}
.vinyle-options[hidden] { display: none; }
.radio-group { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-group[hidden] { display: none; }
.radio-group label {
    display: inline-flex; align-items: center; gap: 6px;
    cursor: pointer; min-height: 44px; padding: 4px 0;
    font-size: 14px;
}
.pose-mention { color: var(--c-text-light); font-size: 12px; }
.checkbox-line {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; min-height: 44px; padding: 4px 0;
    font-size: 14px;
}
.checkbox-line[hidden] { display: none; }
/* Vignette de la raclette de pose, a cote de l'option (vinyle seul). */
.raclette-img { width: 56px; height: 56px; object-fit: contain; flex: 0 0 auto; border-radius: var(--r-sm); }

/* Grille de fixations */
.grille-fixations {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}
.fixation-item {
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    padding: 8px;
    text-align: center;
    cursor: pointer;
    background: #fff;
    transition: var(--transition);
    font-size: 13px;
}
.fixation-item:hover { background: var(--c-surface-2); }
.fixation-item.actif {
    border-color: var(--c-accent);
    background: #eff6ff;
    color: var(--c-accent);
}
.fixation-item-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    background-size: cover; background-repeat: no-repeat; background-position: center;
    border-radius: 6px;
    margin: 0 0 6px;
}

/* Champ range avec valeur a droite (interlettrage) */
.champ-range {
    display: flex;
    align-items: center;
    gap: 10px;
}
.champ-range input[type=range] {
    flex: 1;
    min-height: 44px;
}
.champ-range .valeur-range {
    flex: 0 0 auto;
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--c-text);
}

/* Champ controle nombre avec - / + (agrandissement) */
.champ-controle-nombre {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}
.champ-controle-nombre input[type=number] {
    width: 90px;
    padding: 8px 8px;
    text-align: center;
    min-height: 40px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.btn-controle {
    width: 40px; height: 40px;
    border: 1px solid var(--c-border);
    background: #fff;
    border-radius: var(--r-sm);
    font-size: 20px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.btn-controle:hover { background: var(--c-surface-2); }
.btn-controle:disabled { opacity: 0.4; cursor: not-allowed; }

/* Champ hauteur : barre (slider) + boutons - / + + valeur */
.champ-hauteur {
    display: flex;
    align-items: center;
    gap: 10px;
}
.champ-hauteur input[type=range] {
    flex: 1;
    min-height: 44px;
    min-width: 0;
}
.champ-hauteur .valeur-hauteur {
    flex: 0 0 auto;
    min-width: 52px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--c-text);
}
.champ-hauteur .valeur-hauteur::after { content: ' mm'; font-weight: 400; color: var(--c-text-light); }

/* ===== Bloc récap ===== */
.bloc-recap {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: var(--espace-3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: sticky;
    top: 70px;
    align-self: flex-start;
}
/* Sous 768px (le récap est empilé sous les options) : pleine largeur. */
@media (max-width: 767px) {
    .bloc-recap { align-self: stretch; }
}
.ral-personnalise {
    width: 100%;
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    font-size: 13px;
    font-family: inherit;
}
.ral-personnalise:focus { outline: none; border-color: var(--c-accent); }

.bloc-recap h2 {
    margin: 0 0 var(--espace-2);
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--orange);
}
.recap-liste { margin: 0; padding: 0; }
.recap-liste div {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--c-border);
    font-size: 13px;
}
.recap-liste div:last-child { border-bottom: 0; }
.recap-liste dt { color: var(--c-text-light); flex: 0 0 auto; }
.recap-liste dd {
    margin: 0;
    text-align: right;
    font-weight: 500;
    /* Permet de casser un texte sans espace (genre "MMMMMMMM...") au lieu de deborder */
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.recap-totaux {
    margin-top: var(--espace-3);
    padding-top: var(--espace-2);
    border-top: 2px solid var(--c-text);
}
.recap-total-ligne {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.recap-total-ligne + .recap-total-ligne { margin-top: 2px; }
.recap-prix-label { font-size: 13px; font-weight: 600; text-transform: uppercase; color: var(--c-text-light); }
.recap-montant-ht { font-size: 26px; font-weight: 700; }
.recap-montant-ttc { font-size: 17px; font-weight: 600; color: var(--c-text-light); }
.recap-prix-tva {
    margin: 4px 0 var(--espace-2);
    text-align: right;
    color: var(--c-text-light);
    font-size: 12px;
}

.btn-principal {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: var(--c-accent);
    color: #fff;
    border: 0;
    border-radius: var(--r-md);
    font-size: 15px;
    font-weight: 600;
    transition: var(--transition);
    min-height: 50px;
}
.btn-principal:hover { background: var(--c-accent-hover); }
.btn-principal:disabled {
    background: var(--c-border);
    color: var(--c-text-light);
    cursor: not-allowed;
}

.btn-secondaire {
    display: inline-block;
    padding: 12px 20px;
    background: #fff;
    color: var(--c-text);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    font-size: 14px;
    transition: var(--transition);
}
.btn-secondaire:hover { background: var(--c-surface-2); text-decoration: none; }

.recap-message {
    margin-top: var(--espace-2);
    padding: 10px 12px;
    border-radius: var(--r-sm);
    font-size: 13px;
}
.recap-message.succes { background: #d1fae5; color: #065f46; }
.recap-message.erreur { background: #fee2e2; color: var(--c-error); }

/* ===== Alertes flottantes ===== */
.alertes {
    position: fixed;
    bottom: 20px; right: 20px;
    z-index: 1000;
    display: flex; flex-direction: column;
    gap: 8px;
    max-width: 90%;
}
.alerte {
    padding: 12px 16px;
    border-radius: var(--r-sm);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 14px;
    background: #fff;
    border-left: 4px solid var(--c-accent);
    animation: slideIn 0.2s ease;
}
.alerte-erreur { border-left-color: var(--c-error); color: var(--c-error); }
.alerte-succes { border-left-color: var(--c-success); color: var(--c-success); }
.alerte-info { border-left-color: var(--c-accent); color: var(--c-text); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Page connexion requise ===== */
.page-info { background: var(--c-bg); }
.bloc-info {
    max-width: 560px;
    margin: 28px auto;
    background: var(--c-surface);
    padding: var(--espace-4);
    border-radius: var(--r-lg);
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.bloc-info h1 { margin-top: 0; }
.bloc-info-actions {
    display: flex;
    gap: var(--espace-2);
    justify-content: center;
    margin: var(--espace-3) 0;
    flex-wrap: wrap;
}
.bloc-info-retour { font-size: 13px; }
.bloc-info-aide { font-size: 12px; color: var(--c-text-light); margin-top: var(--espace-3); }

/* ===== Petits écrans (320-480) ===== */
@media (max-width: 480px) {
    .configurateur { padding: var(--espace-1); }
    .entete-logo strong { font-size: 16px; }
    .entete-logo span { display: none; }
    .recap-montant-ht { font-size: 22px; }
    .dimensions { font-size: 11px; }
    .dimensions th, .dimensions td { padding: 4px 2px; }
}

/* Sur mobile, la palette de fond s'ouvre vers le BAS (sinon, le déclencheur étant
   en haut de l'aperçu, le panneau déborde au-dessus de l'écran et les premières
   rangées de couleurs sont coupées). */
@media (max-width: 600px) {
    .fond-panel { top: calc(100% + 8px); bottom: auto; max-height: 50vh; }
}

/* ===== Très petits écrans (320px exact) ===== */
@media (max-width: 360px) {
    .palette-couleurs { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }
    .swatch { min-width: 40px; min-height: 40px; }
    /* La palette de fonds reste compacte (58 couleurs) meme sur petit ecran */
    .fond-panel .palette-fonds { grid-template-columns: repeat(auto-fill, minmax(28px, 1fr)); }
    .fond-panel .palette-fonds .swatch { min-width: 28px; min-height: 28px; }
    .grille-fixations { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Lien 'Acceder au panier' (sous le bouton d'ajout) ===== */
.lien-acceder-panier {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    margin-top: 10px; padding: 8px 12px;
    color: var(--orange); font-weight: 600; font-size: 15px;
    text-decoration: none; border-radius: var(--r-sm);
    transition: background 0.15s ease, color 0.15s ease;
}
.lien-acceder-panier:hover { background: rgba(244, 114, 22, 0.08); text-decoration: underline; }
.lien-acceder-panier img { width: 20px; height: 20px; object-fit: contain; }

/* Titres de page en orange (charte) ===== */
h1 { color: var(--orange); }
