/* ============ CHECKOUT — ADRESSES (step 2) ============
 * Lot 5 (2026-05-08) — feat/theme-v1
 * Sélecteur d'adresses (cards livraison + facturation), formulaire
 * d'ajout/modification, toggle adresse de facturation différente.
 * Loaded at priority 68 (after alter-checkout-auth=66, before
 * alter-cms=65... non, après cms aussi : after auth, alors-cms est 65).
 * Wait : ordre actuel =
 *   alter-checkout=60, base=62, stepper=64, auth=66, cms=65...
 * cms=65 est avant auth=66 ! Donc on prend 67 (entre auth=66 et 70).
 * Final priority 67.
 */

/* ---------- Layout sélecteur d'adresses ---------- */
body#checkout .address-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin: 24px 0 16px 0;
}

body#checkout .address-selector .address-item {
    margin: 0;
}

/* ---------- Card adresse — base ---------- */
body#checkout section.checkout-step .address-item {
    position: relative;
    background-color: #ffffff;
    border: 1.5px solid var(--as-hairline);
    border-radius: 8px;
    transition: border-color .15s ease, box-shadow .15s ease,
                background-color .15s ease;
    overflow: hidden;
}

body#checkout section.checkout-step .address-item:hover:not(.selected) {
    border-color: var(--as-grey-300);
    box-shadow: 0 2px 8px rgba(15, 15, 15, 0.04);
}

/* Override alter-checkout.css : .selected vert plein → border amaranth + bg amaranth-04% */
body#checkout section.checkout-step .address-item.selected {
    background-color: rgba(230, 34, 73, 0.04);
    border: 2px solid var(--as-amaranth);
    box-shadow: 0 0 0 1px var(--as-amaranth);
}

body#checkout section.checkout-step .address-item > header {
    min-height: auto;
    padding: 18px 20px 12px 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 1px solid var(--as-hairline);
    cursor: pointer;
}

body#checkout section.checkout-step .address-item.selected > header {
    border-bottom-color: rgba(230, 34, 73, 0.18);
}

/* Radio dans le header de la card */
body#checkout section.checkout-step .address-item header .custom-radio,
body#checkout section.checkout-step .address-item header > [type="radio"] + span {
    flex-shrink: 0;
    margin-top: 2px;
}

/* Alias name de l'adresse — titre */
body#checkout section.checkout-step .address-item header h4,
body#checkout section.checkout-step .address-item header .h4,
body#checkout section.checkout-step .address-item header strong {
    font-family: var(--as-font-family);
    font-size: 16px;
    font-weight: 600;
    color: var(--as-grey-900);
    margin: 0 0 6px 0;
    line-height: 1.2;
}

/* Body card : adresse postale */
body#checkout section.checkout-step .address-item .address {
    display: block;
    padding: 14px 20px 4px 20px;
    color: var(--as-grey-700);
    font-size: 14px;
    line-height: 1.55;
    text-decoration: none !important;
    font-style: normal;
}

body#checkout section.checkout-step .address-item .address:hover {
    text-decoration: none !important;
}

/* Footer — Modifier / Supprimer */
body#checkout section.checkout-step .address-item .address-footer {
    padding: 12px 20px 16px 20px;
    border-top: 1px solid var(--as-hairline);
    display: flex;
    align-items: center;
    gap: 18px;
    background-color: rgba(15, 15, 15, 0.015);
}

body#checkout section.checkout-step .address-item.selected .address-footer {
    background-color: transparent;
    border-top-color: rgba(230, 34, 73, 0.18);
}

body#checkout section.checkout-step .address-item .address-footer a,
body#checkout section.checkout-step .address-item .edit-address,
body#checkout section.checkout-step .address-item .delete-address {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px !important;
    font-weight: 500;
    color: var(--as-grey-900) !important;
    text-decoration: underline !important;
    text-decoration-color: var(--as-amaranth);
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}

body#checkout section.checkout-step .address-item .address-footer a:hover {
    text-decoration-thickness: 3px !important;
}

body#checkout section.checkout-step .address-item .address-footer .material-icons {
    font-size: 16px;
    color: var(--as-grey-700);
}

/* ---------- "Ajouter nouvelle adresse" lien ---------- */
body#checkout section.checkout-step p.add-address,
body#checkout #checkout .add-address {
    margin: 12px 0 16px 0;
    padding: 0;
}

body#checkout section.checkout-step p.add-address a,
body#checkout #checkout a.add-address {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    background-color: transparent;
    color: var(--as-grey-900) !important;
    font-family: var(--as-font-family);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none !important;
    border: 1.5px solid var(--as-amaranth);
    border-radius: 8px;
    transition: background-color .15s ease, color .15s ease;
}

body#checkout section.checkout-step p.add-address a:hover,
body#checkout #checkout a.add-address:hover {
    background-color: var(--as-amaranth);
    color: #ffffff !important;
    text-decoration: none !important;
}

body#checkout section.checkout-step p.add-address a .material-icons,
body#checkout #checkout a.add-address .material-icons {
    font-size: 18px;
}

body#checkout section.checkout-step p.add-address a:hover .material-icons {
    color: #ffffff;
}

/* ---------- Lien "Adresse de facturation différente" ---------- */
body#checkout section.checkout-step a[data-link-action="different-invoice-address"],
body#checkout section.checkout-step a[href*="invoice-address"] {
    display: inline-block;
    margin: 8px 0 16px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--as-grey-900);
    text-decoration: underline;
    text-decoration-color: var(--as-amaranth);
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}

body#checkout section.checkout-step a[data-link-action="different-invoice-address"]:hover {
    text-decoration-thickness: 3px;
}

/* ---------- Formulaire add/edit address ---------- */
body#checkout #delivery-address,
body#checkout #invoice-address,
body#checkout .js-address-form {
    background-color: transparent;
    padding: 0;
}

body#checkout #delivery-address form,
body#checkout #invoice-address form,
body#checkout .js-address-form > form {
    display: block;
}

/* Grid 2 col desktop pour les form-groups address */
@media (min-width: 768px) {
    body#checkout .js-address-form form .form-fields,
    body#checkout #delivery-address .form-fields,
    body#checkout #invoice-address .form-fields {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 20px;
    }

    /* Champs full-width : adresse rue, complément, alias, message */
    body#checkout .js-address-form .form-group:has(input[name="address1"]),
    body#checkout .js-address-form .form-group:has(input[name="address2"]),
    body#checkout .js-address-form .form-group:has(input[name="alias"]),
    body#checkout .js-address-form .form-group:has(textarea),
    body#checkout .js-address-form .form-group:has(input[name="company"]),
    body#checkout .js-address-form .form-group:has(input[name="phone"]),
    body#checkout .js-address-form .form-group:has(input[name="vat_number"]) {
        grid-column: 1 / -1;
    }
}

/* Heading h2 step intra (Shipping Address / Invoice Address) */
body#checkout section.checkout-step h2.h4,
body#checkout section.checkout-step .step-content h2,
body#checkout section.checkout-step .content h2.h4 {
    font-family: var(--as-font-family);
    font-size: 18px;
    font-weight: 600;
    color: var(--as-grey-900);
    margin: 12px 0 18px 0;
    padding: 0;
    text-transform: none;
}

/* Note "L'adresse sélectionnée sera utilisée..." */
body#checkout section.checkout-step .js-address-form > form > p:first-child,
body#checkout section.checkout-step .step-content > p:first-of-type {
    margin: 0 0 16px 0;
    color: var(--as-grey-500);
    font-size: 14px;
    line-height: 1.5;
}

/* Erreurs adresse alert */
body#checkout .js-address-error {
    margin: 12px 0;
}

/* Form footer / continue button */
body#checkout #delivery-address .form-footer,
body#checkout #invoice-address .form-footer,
body#checkout .js-address-form .form-footer {
    margin-top: 24px;
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

/* ---------- Mobile (≤ 575px) ---------- */
@media (max-width: 575.98px) {
    body#checkout .address-selector {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    body#checkout section.checkout-step .address-item > header {
        padding: 16px 16px 10px 16px;
    }

    body#checkout section.checkout-step .address-item .address {
        padding: 12px 16px 4px 16px;
    }

    body#checkout section.checkout-step .address-item .address-footer {
        padding: 10px 16px 14px 16px;
        gap: 14px;
    }

    body#checkout section.checkout-step p.add-address a,
    body#checkout #checkout a.add-address {
        width: 100%;
        justify-content: center;
    }
}
