/**
 * 2008-2025 Prestaworld
 *
 * NOTICE OF LICENSE
 *
 * The source code of this module is under a commercial license.
 * Each license is unique and can be installed and used on only one website.
 * Any reproduction or representation total or partial of the module, one or more of its components,
 * by any means whatsoever, without express permission from us is prohibited.
 *
 * DISCLAIMER
 *
 * Do not alter or add/update to this file if you wish to upgrade this module to newer
 * versions in the future.
 *
 * @author    prestaworld
 * @copyright 2008-2025 Prestaworld
 * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
 * International Registered Trademark & Property of prestaworld
 */

@media (min-width: 768px) {
    /* --- LAYOUT GLOBAL --- */

    /* Message de vérification manuelle */
    #customer-form .tf-verification-message {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        background-color: #e3f2fd !important;
        color: #1976d2 !important;
        padding: 12px 20px !important;
        border-radius: 4px !important;
        margin-bottom: 15px !important;
        text-align: center !important;
        font-size: 14px !important;
        font-weight: 400 !important;
        border: 1px solid #bbdefb !important;
    }
    
    /* Message d'information email sous le bouton */
    #customer-form .tf-email-notification-message {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        background-color: #e3f2fd !important;
        color: #1976d2 !important;
        padding: 12px 20px !important;
        border-radius: 4px !important;
        margin-top: 15px !important;
        margin-bottom: 0 !important;
        text-align: left !important;
        font-size: 14px !important;
        font-weight: 400 !important;
        border: 1px solid #bbdefb !important;
        display: block !important;
    }

    /* Container principal en grille 2 colonnes */
    #customer-form>div:first-child,
    #customer-form section {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 5px 30px !important;
        align-items: start !important;
    }

    /* --- STYLE DES CHAMPS (FORM GROUPS) --- */

    /* Réduire tous les espacements par défaut */
    #customer-form .form-group.row,
    #customer-form .form-group {
        display: block !important;
        margin-bottom: 5px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        width: 100% !important;
    }
    
    /* Réduire les espacements des conteneurs de colonnes */
    #customer-form .row {
        margin-bottom: 0 !important;
        margin-top: 0 !important;
    }
    
    #customer-form .col-md-6,
    #customer-form .col-md-3 {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    /* LABEL: 100% largeur, au-dessus */
    #customer-form .form-group.row .col-md-3:first-child,
    #customer-form .form-group.row .form-control-label,
    #customer-form .form-group .form-control-label {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding: 0 !important;
        margin-bottom: 3px !important;
        margin-top: 0 !important;
        text-align: left !important;
        float: none !important;
    }

    /* INPUT CONTAINER: 100% largeur, en dessous */
    #customer-form .form-group.row .col-md-6,
    #customer-form .form-group.row .js-input-column {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding: 0 !important;
        float: none !important;
    }

    /* Masquer la colonne de commentaire (droite) */
    #customer-form .form-group.row .col-md-3.form-control-comment {
        display: none !important;
    }
    
    /* Masquer les messages d'aide sous Prénom et Nom (complété par JavaScript) */
    #customer-form .form-group.row:has(input[name="firstname"]) .form-control-comment,
    #customer-form .form-group.row:has(input[name="lastname"]) .form-control-comment,
    #customer-form .form-group:has(input[name="firstname"]) .form-control-comment,
    #customer-form .form-group:has(input[name="lastname"]) .form-control-comment {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        opacity: 0 !important;
    }

    /* --- TYPOGRAPHIE ET STYLE --- */

    /* Label en gras et noir */
    #customer-form .form-control-label {
        font-weight: 700 !important;
        font-size: 14px !important;
        color: #333 !important;
        text-transform: none !important;
    }

    /* Inputs stylisés */
    #customer-form .form-control {
        display: block !important;
        width: 100% !important;
        height: 45px !important;
        padding: 10px 15px !important;
        border: 1px solid #ddd !important;
        border-radius: 0 !important;
        /* Style carré comme l'image */
        font-size: 14px !important;
        background-color: #f9f9f9 !important;
        color: #555 !important;
    }

    #customer-form .form-control:focus {
        background-color: #fff !important;
        border-color: #ff9900 !important;
        outline: none !important;
        box-shadow: 0 0 0 2px rgba(255, 153, 0, 0.2) !important;
    }
    
    /* Champ adresse en lecture seule */
    #customer-form input[name="address1"][readonly],
    #customer-form input[name="address1"] {
        background-color: #f5f5f5 !important;
        cursor: not-allowed !important;
        color: #666 !important;
    }
    
    #customer-form input[name="address1"][readonly]:focus {
        background-color: #f5f5f5 !important;
        border-color: #ddd !important;
        box-shadow: none !important;
        cursor: not-allowed !important;
    }

    /* --- ELEMENTS PLEINE LARGEUR --- */

    /* Titre / Genre */
    #customer-form .form-group.row:has(input[type="radio"]) {
        grid-column: 1 / -1 !important;
    }

    /* Checkboxes (Conditions générales) */
    #customer-form .form-group.row:has(input[type="checkbox"]) {
        grid-column: 1 / -1 !important;
    }

    /* Mot de passe */
    #customer-form .field-password-policy {
        grid-column: 1 / -1 !important;
    }

    /* Si le mot de passe est dans un form-group standard */
    #customer-form .form-group.row:has(input[type="password"]) {
        grid-column: 1 / -1 !important;
    }

    /* Pays (Select) - Prendre une colonne (à droite de l'email) */
    #customer-form .form-group.row:has(select[name="id_country"]) {
        grid-column: span 1 !important;
    }

    /* Masquer le Numéro d'identification fiscale, Date de naissance et Offres partenaires (optin) */
    #customer-form .form-group.row:has(input[name="siret"]),
    #customer-form .form-group.row:has(input[name="dni"]),
    #customer-form .form-group.row:has(input[name="vat_number"]),
    #customer-form .form-group.row:has(input[name="birthday"]),
    #customer-form .form-group.row:has(input[name="optin"]) {
        display: none !important;
    }
    
    /* Masquer le champ Société du formulaire client standard (garder seulement tf_company du module) */
    /* Masquer tous les champs avec name="company" */
    #customer-form .form-group.row:has(input[name="company"]) {
        display: none !important;
    }
    
    /* Exception : réafficher le champ tf_company du module */
    #customer-form .form-group.row:has(input[name="tf_company"]) {
        display: block !important;
    }
    
    /* Fallback si :has() ne fonctionne pas - masquer directement l'input company standard */
    #customer-form input[name="company"]:not([name="tf_company"]) {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        opacity: 0 !important;
    }
    
    #customer-form .form-group.row:has(> .col-md-6 > input[name="company"]:not([name="tf_company"])) {
        display: none !important;
    }
    
    /* S'assurer que le champ "other" (Complément) est visible */
    #customer-form .form-group.row:has(input[name="other"]),
    #customer-form .form-group:has(input[name="other"]) {
        display: block !important;
        visibility: visible !important;
    }
    
    #customer-form input[name="other"] {
        display: block !important;
        visibility: visible !important;
    }

    /* Fallback si :has() ne fonctionne pas pour optin */
    #customer-form input[name="optin"],
    #customer-form input[name="optin"]+span,
    #customer-form input[name="optin"]~label,
    #customer-form label[for="optin"],
    #customer-form .custom-checkbox:has(input[name="optin"]) {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        opacity: 0 !important;
    }

    /* Cacher le conteneur parent direct si possible sans :has */
    #customer-form div:has(> .custom-checkbox > label > input[name="optin"]) {
        display: none !important;
    }

    /* --- MISE EN PAGE SPÉCIFIQUE (PAYS, CGV, BOUTON) --- */

    /* 1. PAYS : Prendre une colonne (à droite de l'email) */
    #customer-form .form-group:has(select[name="id_country"]) {
        grid-column: span 1 !important;
        width: 100% !important;
    }
    
    /* Email : Prendre une colonne (à gauche du Pays) */
    #customer-form .form-group:has(input[name="email"]),
    #customer-form .form-group:has(input[type="email"]) {
        grid-column: span 1 !important;
        width: 100% !important;
    }

    /* 2. CGV (Conditions) : Pleine largeur, avec espacement aéré */
    #customer-form .form-group:has(input[name="psgdpr"]),
    #customer-form .form-group.row:has(input[name="psgdpr"]) {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        margin-top: 20px !important;
        margin-bottom: 20px !important;
        padding-top: 10px !important;
        padding-bottom: 10px !important;
        display: block !important;
        /* S'assurer qu'il n'est pas caché */
    }

    /* 3. BOUTON VALIDER : Dans un form-group row, pleine largeur et aligné à GAUCHE */
    #customer-form .form-group.row:has(input[name="submitCreate"]),
    #customer-form .form-group.row:has(button[name="submitCreate"]),
    #customer-form .form-group:has(input[name="submitCreate"]) {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        margin-top: 15px !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
        clear: both !important;
        display: block !important;
    }

    /* Conteneur du bouton dans form-group row - aligné à gauche */
    #customer-form .form-group.row:has(input[name="submitCreate"]) .text-center,
    #customer-form .form-group.row:has(button[name="submitCreate"]) .text-center,
    #customer-form .form-group:has(input[name="submitCreate"]) .text-center {
        text-align: left !important;
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
    
    /* Colonnes dans le form-group row du bouton */
    #customer-form .form-group.row:has(input[name="submitCreate"]) .col-md-6,
    #customer-form .form-group.row:has(button[name="submitCreate"]) .col-md-6 {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
    }

    /* Style du bouton ENREGISTRER */
    #customer-form button[name="submitCreate"],
    #customer-form button[type="submit"].btn-primary,
    #customer-form .btn-primary[type="submit"] {
        background-color: #ff9900 !important;
        background: linear-gradient(to bottom, #ff9900, #e68a00) !important;
        color: white !important;
        border: none !important;
        padding: 14px 50px !important;
        font-size: 16px !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        border-radius: 6px !important;
        cursor: pointer !important;
        display: inline-block !important;
        margin: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        min-width: 220px !important;
        text-align: center !important;
        transition: all 0.3s ease !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
        line-height: 1.4 !important;
    }

    #customer-form button[name="submitCreate"]:hover,
    #customer-form button[type="submit"].btn-primary:hover,
    #customer-form .btn-primary[type="submit"]:hover {
        background: linear-gradient(to bottom, #e68a00, #cc7700) !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
        transform: translateY(-1px) !important;
    }

    /* Footer du formulaire */
    #customer-form footer,
    #customer-form .form-footer {
        grid-column: 1 / -1 !important;
        text-align: left !important;
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        clear: both !important;
    }
    
    /* Aligner tous les boutons du footer à gauche */
    #customer-form footer .btn-primary,
    #customer-form .form-footer .btn-primary,
    #customer-form footer button[type="submit"],
    #customer-form .form-footer button[type="submit"],
    #customer-form footer .btn,
    #customer-form .form-footer .btn {
        margin-left: 0 !important;
        margin-right: auto !important;
        float: none !important;
        display: inline-block !important;
    }

    /* Alertes et Footer */
    #customer-form .alert {
        grid-column: 1 / -1 !important;
    }

    /* --- SPECIFIQUES --- */

    /* Radio buttons (Genre) alignés horizontalement */
    #customer-form .form-group.row:has(input[type="radio"]) .col-md-6 {
        display: flex !important;
        gap: 10px !important;
        align-items: center !important;
    }

    #customer-form .radio-inline {
        display: flex !important;
        align-items: center !important;
        margin: 0 !important;
    }

    /* Checkboxes (Conditions, Newsletter, Optin) - CORRECTION ROBUSTE */
    #customer-form .form-group.row:has(input[type="checkbox"]) {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        display: block !important;
    }

    /* Masquer le label col-md-3 pour les checkboxes */
    #customer-form .form-group.row:has(input[type="checkbox"]) .col-md-3 {
        display: none !important;
    }

    /* Forcer la colonne input à prendre toute la largeur */
    #customer-form .form-group.row:has(input[type="checkbox"]) .col-md-6,
    #customer-form .form-group.row:has(input[type="checkbox"]) .js-input-column {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        display: block !important;
        padding: 0 !important;
    }

    /* NEUTRALISER LA CLASSE CUSTOM-CHECKBOX DU THÈME */
    #customer-form .custom-checkbox {
        display: flex !important;
        align-items: center !important;
        /* Centrer verticalement */
        width: 100% !important;
        position: static !important;
        height: auto !important;
        min-height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        background: transparent !important;
        outline: none !important;
        box-shadow: none !important;
    }

    /* FORCER L'INPUT NATIF */
    #customer-form .custom-checkbox input[type="checkbox"] {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px !important;
        min-height: 20px !important;
        margin-right: 10px !important;
        appearance: checkbox !important;
        -webkit-appearance: checkbox !important;
        border: 1px solid #ccc !important;
        background: #fff !important;
        display: inline-block !important;
        vertical-align: middle !important;
        margin-top: 0 !important;
        flex-shrink: 0 !important;
        opacity: 1 !important;
        position: static !important;
        cursor: pointer !important;
        z-index: 10 !important;
    }

    /* MASQUER TOUS LES ÉLÉMENTS PARASITES (TRAITS, FAUSSES CASES, CARRÉS NOIRS) */
    /* 1. On cache le span qui suit immédiatement l'input (la fausse case) */
    #customer-form .custom-checkbox input[type="checkbox"]+span,
    #customer-form .custom-checkbox input[type="checkbox"]:checked+span {
        display: none !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
        content: none !important;
    }

    /* 2. On cache les icônes material */
    #customer-form .custom-checkbox i.material-icons {
        display: none !important;
    }

    /* 3. NETTOYAGE NUCLÉAIRE DES PSEUDO-ÉLÉMENTS */
    /* C'est LUI le coupable : le ::after sur le conteneur principal */
    #customer-form .custom-checkbox::after,
    #customer-form .custom-checkbox::before {
        content: none !important;
        display: none !important;
        width: 0 !important;
        height: 0 !important;
        opacity: 0 !important;
        background: transparent !important;
        border: none !important;
    }

    /* Nettoyage aussi sur le label et le texte */
    #customer-form .custom-checkbox label::before,
    #customer-form .custom-checkbox label::after,
    #customer-form .custom-checkbox label>span::before,
    #customer-form .custom-checkbox label>span::after {
        content: none !important;
        display: none !important;
        width: 0 !important;
        height: 0 !important;
        opacity: 0 !important;
        background: transparent !important;
        border: none !important;
    }

    /* 4. On s'assure que le texte lui-même n'a pas de fond ou de bordure */
    #customer-form .custom-checkbox label>span {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }

    /* Sauf pour l'input qui a besoin de sa bordure */
    #customer-form .custom-checkbox input[type="checkbox"] {
        border-color: #ccc !important;
    }

    /* STYLE DU LABEL */
    #customer-form .custom-checkbox label {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        text-align: left !important;
        width: 100% !important;
        white-space: normal !important;
        margin: 0 !important;
        padding: 0 !important;
        position: static !important;
        border: none !important;
        gap: 0 !important;
        /* On gère l'espace via le margin de l'input */
        background: transparent !important;
        /* Sécurité */
        cursor: pointer !important;
        /* Curseur main */
    }

    /* Curseur main aussi sur le texte */
    #customer-form .custom-checkbox label>span {
        cursor: pointer !important;
    }

    /* ANTI-LIGNE : Suppression de tout soulignement ou bordure parasite */
    #customer-form .custom-checkbox,
    #customer-form .custom-checkbox label,
    #customer-form .custom-checkbox span {
        text-decoration: none !important;
        border-bottom: none !important;
    }

    /* Spécifique pour le champ Optin (Partenaires) : on cache tous les spans après l'input */
    /* Car le texte "Recevoir les offres..." est un noeud texte direct, donc on peut cacher les spans sans peur */
    #customer-form .custom-checkbox input[name="optin"]~span {
        display: none !important;
    }

    /* Bouton Mot de passe (Afficher) - Remplacer le texte par une icône d'œil */
    #customer-form .input-group-btn .btn {
        background-color: #ff9900 !important;
        color: white !important;
        border: none !important;
        height: 45px !important;
        width: 45px !important;
        min-width: 45px !important;
        border-radius: 0 !important;
        padding: 0 !important;
        font-weight: 600 !important;
        text-transform: uppercase !important;
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Masquer le texte du bouton et les éléments enfants */
    #customer-form .input-group-btn .btn {
        font-size: 0 !important;
        line-height: 0 !important;
    }
    
    #customer-form .input-group-btn .btn > * {
        display: none !important;
    }
    
    /* Ajouter l'icône d'œil avec SVG via un pseudo-élément */
    #customer-form .input-group-btn .btn::before {
        content: "" !important;
        display: block !important;
        width: 20px !important;
        height: 20px !important;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z'/%3E%3C/svg%3E") !important;
        background-size: contain !important;
        background-repeat: no-repeat !important;
        background-position: center !important;
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
    
    /* Icône d'œil fermé quand le mot de passe est visible */
    #customer-form .input-group-btn .btn.password-visible::before {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z'/%3E%3C/svg%3E") !important;
    }

    /* Bouton Valider (Footer) */
    #customer-form footer .btn-primary,
    #customer-form .form-footer .btn-primary {
        background-color: #ff9900 !important;
        border-color: #ff9900 !important;
        color: white !important;
        text-transform: uppercase !important;
        font-weight: bold !important;
        padding: 10px 30px !important;
        border-radius: 4px !important;
        margin-left: 0 !important;
        margin-right: auto !important;
        float: left !important;
    }
    
    /* Aligner le conteneur clearfix à gauche */
    #customer-form footer.clearfix,
    #customer-form .form-footer.clearfix {
        text-align: left !important;
        display: flex !important;
        justify-content: flex-start !important;
        align-items: flex-start !important;
    }
    
    /* Annuler tout alignement à droite */
    #customer-form footer .pull-right,
    #customer-form .form-footer .pull-right,
    #customer-form footer .float-right,
    #customer-form .form-footer .float-right {
        float: left !important;
        margin-left: 0 !important;
        margin-right: auto !important;
    }
}

/* Mobile : une seule colonne */
@media (max-width: 767px) {
    /* Message de vérification manuelle sur mobile */
    #customer-form .tf-verification-message {
        width: 100% !important;
        background-color: #e3f2fd !important;
        color: #1976d2 !important;
        padding: 12px 20px !important;
        border-radius: 4px !important;
        margin-bottom: 15px !important;
        text-align: center !important;
        font-size: 14px !important;
        font-weight: 400 !important;
        border: 1px solid #bbdefb !important;
    }
    
    /* Message d'information email sur mobile */
    #customer-form .tf-email-notification-message {
        width: 100% !important;
        background-color: #e3f2fd !important;
        color: #1976d2 !important;
        padding: 12px 20px !important;
        border-radius: 4px !important;
        margin-top: 15px !important;
        margin-bottom: 0 !important;
        text-align: left !important;
        font-size: 14px !important;
        font-weight: 400 !important;
        border: 1px solid #bbdefb !important;
    }
    
    #customer-form>div:first-child {
        display: block !important;
    }

    #customer-form .form-group.row,
    #customer-form .form-group {
        margin-bottom: 5px !important;
    }
}