/* Page "Nouvelle commande" : version travaillée (bandeau, champs en 2 colonnes, cartes produit, total collant).
   À charger APRÈS styleHeaderFooter.css et styleBase.css : elle remplace la mise en forme de cette page.
   Optionnel mais recommandé : commande-ux.js (boutons − / +, cartes sélectionnées, pastilles de quantité sur les onglets). */

body { overflow-x: clip; }

/* ---------- Bandeau jaune derrière le titre ---------- */
main:has(> .form_passer_commande) {
    position: relative;
    isolation: isolate;
    width: min(1040px, 100% - 2.5rem);
    margin: 0 auto 5rem;
    padding-top: 2.8rem;
}

main:has(> .form_passer_commande)::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: 0;
    left: 50%;
    width: 100vw;
    height: 17rem;
    transform: translateX(-50%);
    background-color: var(--miel);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cg fill='none' stroke='%23C77F00' stroke-opacity='.25' stroke-width='2'%3E%3Cpath d='M28 2l26 15v30L28 62 2 47V17z'/%3E%3Cpath d='M28 62l26 15v20M28 62L2 77v20'/%3E%3C/g%3E%3C/svg%3E"), linear-gradient(135deg, var(--miel-clair), var(--miel) 70%);
    clip-path: polygon(0 0, 100% 0, 100% 80%, 92% 86%, 84% 90%, 75% 90%, 66% 86%, 58% 80%, 50% 77%, 42% 79%, 33% 85%, 25% 90%, 16% 90%, 8% 86%, 0 80%);
}

main > h1 {
    font-size: clamp(2.4rem, 6vw, 4rem);
    margin-bottom: 2.4rem;
    animation: apparition .5s ease both;
}

main > h1::before { background: var(--brun); }

/* ---------- Carte du formulaire : champs en 2 colonnes ---------- */
.form_passer_commande {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    column-gap: 1rem;
    row-gap: .4rem;
    align-items: start;
    padding: clamp(1.4rem, 3.5vw, 2.8rem);
    background: #fff;
    border-radius: 32px;
    box-shadow: 0 12px 0 var(--miel), 0 30px 60px rgba(74, 46, 11, .18);
    animation: apparition .5s .1s ease both;
}

.form_passer_commande br { display: none; }

.form_passer_commande > label {
    align-self: end;
    margin-top: 1rem;
    font-weight: 600;
}

/* placement (ordre actuel des champs : nom, prénom, mail, contact, ville) */
.form_passer_commande > label:nth-of-type(1) { grid-column: 1; grid-row: 1; margin-top: 0; }
#nom                                          { grid-column: 1; grid-row: 2; }
.form_passer_commande > label:nth-of-type(2) { grid-column: 3; grid-row: 1; margin-top: 0; }
#prenom                                       { grid-column: 3; grid-row: 2; }
.form_passer_commande > label:nth-of-type(3) { grid-column: 1; grid-row: 3; }
#addrMail                                     { grid-column: 1; grid-row: 4; }
.form_passer_commande > label:nth-of-type(4) { grid-column: 3; grid-row: 3; }
#contact                                      { grid-column: 3; grid-row: 4; }
.form_passer_commande > label:nth-of-type(5) { grid-column: 1 / -1; grid-row: 5; }
#ville-select                                 { grid-column: 1; grid-row: 6; }
.form_passer_commande > label:nth-of-type(6) { grid-column: 2; grid-row: 6; align-self: center; justify-self: center; margin: 0 .2rem; color: var(--miel-fonce); font-weight: 800; }
#ville-text                                   { grid-column: 3; grid-row: 6; }
.tabs                                         { grid-column: 1 / -1; grid-row: 7; margin-top: 2.2rem; }
.form-footer                                  { grid-column: 1 / -1; grid-row: 8; }

/* ---------- Champs ---------- */
.form_passer_commande input[type="text"],
.form_passer_commande select {
    width: 100%;
    margin: 0;
    padding: .9rem 1rem .9rem 3rem;
    font: inherit;
    color: var(--brun);
    background-color: var(--creme);
    background-repeat: no-repeat;
    background-position: .95rem center;
    border: 2px solid var(--miel-clair);
    border-radius: 16px;
    transition: border-color .2s, box-shadow .2s, background-color .2s;
}

.form_passer_commande input[type="text"]:hover,
.form_passer_commande select:hover { border-color: var(--miel); }

.form_passer_commande input[type="text"]:focus,
.form_passer_commande select:focus {
    outline: none;
    background-color: #fff;
    border-color: var(--miel);
    box-shadow: 0 0 0 5px rgba(244, 180, 26, .3);
}

#nom, #prenom   { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%23C77F00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E"); }
#addrMail       { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%23C77F00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpath d='m22 7-10 6L2 7'/%3E%3C/svg%3E"); }
#contact        { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%23C77F00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E"); }
#ville-text     { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%23C77F00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3C/svg%3E"); }

#ville-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%23C77F00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%234A2E0B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-position: .95rem center, right .95rem center;
    padding-right: 2.6rem;
    cursor: pointer;
}

/* ---------- Onglets : types de miel ---------- */
.tab-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-bottom: 1.4rem;
}

.tab-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    font: inherit;
    font-weight: 700;
    color: var(--brun);
    background: var(--miel-pale);
    border: 2px solid var(--miel-clair);
    border-radius: 999px;
    padding: .7rem 1.5rem;
    cursor: pointer;
    transition: background .2s, transform .2s, box-shadow .2s, color .2s;
}

.tab-button:hover { background: var(--miel-clair); transform: translateY(-2px); }

.tab-button.active {
    color: var(--miel-clair);
    background: var(--brun);
    border-color: var(--brun);
    box-shadow: 0 5px 0 var(--miel);
    transform: none;
}

/* pastille "x produits choisis" (ajoutée par commande-ux.js) */
.tab-badge {
    display: inline-grid;
    place-items: center;
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 .4rem;
    font-size: .85rem;
    font-weight: 800;
    color: var(--brun);
    background: var(--miel);
    border-radius: 999px;
    animation: pop .35s ease both;
}

.tab-badge[hidden] { display: none; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: apparition .35s ease both; }

.tab-content > label {
    display: block;
    margin: 0 0 1.5rem;
    padding: .9rem 1.2rem;
    font-weight: 400;
    background: var(--miel-pale);
    border-left: 6px solid var(--miel);
    border-radius: 0 16px 16px 0;
}

/* ---------- Cartes produit ---------- */
.produits-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1.5rem;
}

.produit-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border: 2px solid var(--miel-clair);
    border-radius: 26px;
    transition: transform .25s, box-shadow .25s, border-color .25s;
}

.produit-card:hover,
.produit-card:focus-within {
    transform: translateY(-6px);
    border-color: var(--miel);
    box-shadow: 0 12px 0 var(--miel-clair), 0 26px 36px rgba(74, 46, 11, .14);
}

.produit-image {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: linear-gradient(135deg, var(--miel-clair), var(--miel));
    transition: transform .6s ease;
}

.produit-card:hover .produit-image { transform: scale(1.08); }

/* le prix flotte en pastille jaune sur la photo */
.produit-prix {
    position: absolute;
    z-index: 2;
    top: .9rem;
    right: .9rem;
    padding: .35rem 1rem;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--brun);
    background: var(--miel);
    border-radius: 999px;
    box-shadow: 0 4px 0 var(--miel-fonce);
    transform: rotate(3deg);
    transition: transform .25s;
}

.produit-card:hover .produit-prix { transform: rotate(-2deg) scale(1.06); }

.produit-info {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: 1.1rem 1.2rem 1.3rem;
}

.produit-nom { font-weight: 700; line-height: 1.3; }

/* carte choisie (classe ajoutée par commande-ux.js) */
.produit-card.selectionne {
    border-color: var(--brun);
    box-shadow: 0 0 0 4px rgba(244, 180, 26, .5);
}

.produit-card.selectionne::after {
    content: "✓";
    position: absolute;
    z-index: 2;
    top: .9rem;
    left: .9rem;
    display: grid;
    place-items: center;
    width: 2.2rem;
    aspect-ratio: 1;
    font-weight: 800;
    color: var(--miel);
    background: var(--brun);
    border-radius: 50%;
    animation: pop .35s ease both;
    pointer-events: none;
}

/* ---------- Quantité ---------- */
.produit-quantite {
    font: inherit;
    font-weight: 800;
    text-align: center;
    color: var(--brun);
    width: 5.5rem;
    margin-top: .5rem;
    padding: .55rem;
    background: var(--creme);
    border: 2px solid var(--miel-clair);
    border-radius: 999px;
}

.produit-quantite:focus {
    outline: none;
    border-color: var(--miel);
    box-shadow: 0 0 0 4px rgba(244, 180, 26, .3);
}

/* version avec boutons − / + */
.qte {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin-top: .6rem;
    overflow: hidden;
    background: var(--creme);
    border: 2px solid var(--miel-clair);
    border-radius: 999px;
    transition: background .25s, border-color .25s;
}

.qte button {
    width: 2.8rem;
    height: 2.8rem;
    font: inherit;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    color: var(--brun);
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: background .2s, color .2s;
}

.qte button:hover:not(:disabled) { background: var(--miel); color: var(--brun); }
.qte button:disabled { opacity: .3; cursor: not-allowed; }

.qte .produit-quantite {
    width: 3.2rem;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.qte .produit-quantite::-webkit-inner-spin-button,
.qte .produit-quantite::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.produit-card.selectionne .qte { background: var(--brun); border-color: var(--brun); }
.produit-card.selectionne .qte button,
.produit-card.selectionne .qte .produit-quantite { color: var(--miel-clair); }
.produit-card.selectionne .qte button:hover:not(:disabled) { background: var(--miel); color: var(--brun); }

/* ---------- Total + envoi : barre qui reste visible en bas pendant le défilement ---------- */
.form-footer {
    position: sticky;
    bottom: 1rem;
    z-index: 6;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 2rem;
    margin-top: 2.2rem;
    padding: 1.1rem 1.5rem 1.1rem 2rem;
    color: var(--creme);
    background: var(--brun);
    border-radius: 999px;
    box-shadow: 0 16px 34px rgba(74, 46, 11, .38);
}

.form-footer strong { font-size: clamp(1.1rem, 2.4vw, 1.5rem); }

#montant-total {
    display: inline-block;
    color: var(--miel);
    font-size: 1.25em;
    font-variant-numeric: tabular-nums;
}

#montant-total.bump { animation: bump .35s ease; }

#btn-commande {
    font: inherit;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--brun);
    background: var(--miel);
    border: 0;
    border-radius: 999px;
    padding: .95rem 2.2rem;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--miel-fonce);
    transition: transform .2s, box-shadow .2s, background .2s;
}

#btn-commande:not(:disabled) { animation: halo 2.6s ease-in-out infinite; }

#btn-commande:hover:not(:disabled) {
    background: var(--miel-clair);
    transform: translateY(-2px);
    box-shadow: 0 7px 0 var(--miel-fonce);
}

#btn-commande:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--miel-fonce); }

#btn-commande:disabled {
    color: #d9cdb4;
    background: #8a7350;
    box-shadow: none;
    cursor: not-allowed;
}

.tab-button:focus-visible,
.qte button:focus-visible,
#btn-commande:focus-visible { outline: 3px solid var(--miel); outline-offset: 3px; }

/* ---------- Animations ---------- */
@keyframes apparition { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop        { 0% { transform: scale(0); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes bump       { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes halo       { 0%, 100% { box-shadow: 0 5px 0 var(--miel-fonce), 0 0 0 0 rgba(244, 180, 26, .55); }
                         50%      { box-shadow: 0 5px 0 var(--miel-fonce), 0 0 0 10px rgba(244, 180, 26, 0); } }

/* ---------- Tablette / mobile ---------- */
@media (max-width: 720px) {
    main:has(> .form_passer_commande)::before { height: 14rem; }

    /* une seule colonne : on annule le placement en grille */
    .form_passer_commande { grid-template-columns: minmax(0, 1fr); }
    .form_passer_commande > * { grid-column: 1 !important; grid-row: auto !important; }
    .form_passer_commande > label:nth-of-type(n) { margin-top: 1rem; justify-self: start; }
    .form_passer_commande > label:nth-of-type(1) { margin-top: 0; }
    .form_passer_commande > label:nth-of-type(6) { margin: .6rem 0; justify-self: center; }

    .tab-buttons { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .5rem; }
    .tab-button { white-space: nowrap; }

    .produits-container { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
    .produit-info { padding: .9rem; }

    /* barre du total plus compacte : total à gauche, bouton à droite */
    .form-footer { bottom: .6rem; flex-direction: row; flex-wrap: nowrap; gap: .6rem; padding: .6rem .6rem .6rem 1.1rem; text-align: left; }
    .form-footer strong { font-size: 1rem; white-space: nowrap; }
    #btn-commande { width: auto; padding: .75rem .9rem; font-size: .85rem; white-space: nowrap; }
}

@media (max-width: 440px) {
    .produits-container { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 440px) {
    #btn-commande { white-space: normal; line-height: 1.2; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}