/* Suppression scroll horizontal sur toutes les tables */
.table-responsive {
    overflow-x: visible !important;
}

@media (max-width:1100px) {
	/* Masquer complètement les cellules vides sur mobile */
    #trash_datatable td:empty, .datatable td:empty {
        display: none !important;
    }
	.invoice-table
	{
		overflow-x:auto;
	}
	.invoice-table table
	{
		min-width:1100px;
	}
}

.invoice-table table tr td
{
	border: 1px solid #ddd!important;
}

.add-line-btn
{
	margin-bottom: 10px;
}
.business-info
{
	min-height: 170px!important;
}

@font-face {
    font-family: gilliehilda;
    src: url(fonts/gillie_hilda/Gillie_Hilda.ttf);
}
.app-name
{
  font-family: gilliehilda;
  text-transform: initial;
  font-size: 1.8em;
  letter-spacing: 1px;
}
.app-name-title
{
  font-family: gilliehilda;
  text-transform: initial;
  font-weight: 100;
  font-size: 1.4em;
  letter-spacing: 1px;
}

.log-info
{
	text-align: center;
	font-weight: bold;
	color: rgb(51,65,78);
}


/* Affichage par cartes dans la liste de factures dans la version mobile*/
@media (max-width: 768px) {
    .table-responsive {
        padding: 0 !important;
    }
	/* Masquer complètement les cellules vides sur mobile */
    #trash_datatable td:empty, .datatable td:empty {
        display: none !important;
    }

    #trash_datatable, #trash_datatable thead, #trash_datatable tbody, .datatable, .datatable thead, .datatable tbody, .datatable th, .datatable td, #trash_datatable tr, .datatable tr {
        display: block !important;
        width: 100% !important;
    }
    #trash_datatable thead tr, .datatable thead tr { 
        position: absolute !important;
        top: -9999px; left: -9999px;
    }
    #trash_datatable tr, .datatable tr {
        border: 1px solid #ccc !important;
        border-radius: 8px !important;
        margin-bottom: 15px !important;
        background-color: #fff !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }
    /* 1. Comportement par défaut pour TOUTES les tables (aligné à gauche) */
    #trash_datatable td, .datatable td { 
        border: none !important;
        border-bottom: 1px solid #eee !important; 
        position: relative !important;
        min-height: 40px;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important; /* Aligné à gauche */
        text-align: left !important;
        padding: 10px !important; /* Padding normal */
        overflow-wrap: break-word;
    }

    /* 2. Comportement SPÉCIFIQUE si tu as mis un data-label (Factures) */
    #trash_datatable td[data-label], .datatable td[data-label] {
        padding-left: 40% !important; /* Laisse la place au label */
        justify-content: flex-end !important; /* Pousse la valeur à droite */
        text-align: right !important;
    }
    #trash_datatable td:last-child, .datatable td:last-child { border-bottom: 0 !important; }
    #trash_datatable td:before, .datatable td:before {
        content: attr(data-label);
        position: absolute; left: 10px; width: 35%;
        text-align: left; font-weight: bold; color: #555;
    }
    #trash_datatable td.actions-cell, .datatable td.actions-cell {
        justify-content: center !important;
        padding-left: 0 !important;
        flex-wrap: wrap !important;
        gap: 10px !important; /* Espace général entre les boutons augmenté */
    }
    
    #trash_datatable td.actions-cell:before, .datatable td.actions-cell:before {
        display: none !important;
    }
    
    #trash_datatable td.actions-cell .btn, .datatable td.actions-cell .btn {
        display: inline-block !important;
        margin: 5px !important;
        padding: 8px 12px !important;
    }

    /* Corbeille : boutons de sélection côte à côte sur mobile */
    .trash-actions-selection {
        display: flex !important;
        gap: 8px;
    }
    .trash-actions-selection .btn {
        flex: 1 1 0;
        min-width: 0;
        padding-left: 4px !important;
        padding-right: 4px !important;
        white-space: normal !important;
    }

    /* Centrer le badge d'abonnement sur mobile */
    .badge-abonnement {
        float: none !important; /* Force l'annulation du float:right inline */
        display: block !important;
        width: max-content !important;
        margin: 10px auto !important; /* Le margin auto permet le centrage */
        clear: both !important;
    }
}

/* Alignement des boutons d'action du header */
.actions-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center; /* Aligne tout au centre verticalement */
    justify-content: flex-end; /* Garde à droite sur PC */
    gap: 8px; /* Espace identique entre chaque bouton */
}

/* Retire les marges par défaut gênantes de Bootstrap */
.actions-header .btn, 
.actions-header label {
    margin: 0 !important; 
}

@media (max-width: 768px) {
    .actions-header {
        float: none !important;
        clear: both !important;
        width: 100% !important;
        justify-content: flex-start;
        margin-top: 15px;
        gap: 12px !important;
    }
    
    .actions-header .btn {
        flex: 1 1 auto;
        text-align: center;
        margin: 5px !important; 
        padding: 10px 15px !important; 
        font-size: 13px !important; 
    } /* <--- L'accolade manquante était ici ! */

    .actions-header label.toggle-switch-orange {
        height: 40px !important; 
        padding: 0 15px !important;
    }

    .btn-share-mobile {
        display: none !important;
    }
}

/* Le texte "Préparation..." (bouton désactivé pendant le chargement) était en vert clair
   sur fond vert clair (couleurs par défaut de .btn-rounded.btn-success[disabled]) : illisible. */
.btn-share-mobile[disabled] {
    color: #000 !important;
}



/* 1. Masqué partout par défaut */
.btn-share-mobile {
    display: none !important;
}

/* 2. Affiché uniquement sur mobile (doit être placé APRÈS la règle ci-dessus) */
@media (max-width: 768px) {
    .actions-header .btn-share-mobile {
        display: inline-block !important;
    }
}

/* Corbeille : carte pleine largeur sur mobile */
@media (max-width: 768px) {
    #trash_datatable_wrapper {
        width: 100% !important;
        overflow-x: hidden !important;
    }
    #trash_datatable tr {
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 4px !important;
    }
}

/* Corbeille : wrapper DataTables pleine largeur */
#trash_datatable_wrapper {
    width: 100% !important;
    min-width: 0 !important;
}
#trash_datatable_wrapper .dataTables_scroll {
    width: 100% !important;
}

/* Lignes produit des documents en cartes sur mobile
   (saisie : ajout, edit, copy, tofacture, tobondelivraison, groupfacture ; lecture : details) */
@media (max-width: 768px) {
    .invoice-table {
        overflow: visible; /* sinon la liste du champ Produit est coupée par le conteneur */
        padding: 0 10px; /* mêmes bords que les blocs Notes et Montant */
    }
    .invoice-table table.table-bordered {
        border: none;
        clear: both; /* le bouton + est en pull-right */
    }
    .invoice-table table.table-bordered thead {
        display: none;
    }
    .invoice-table table.table-bordered,
    form .invoice-table .invoice-lines,
    form .invoice-table .invoice-lines tr,
    form .invoice-table .invoice-lines td {
        display: block;
        width: 100%;
        min-width: 0; /* annule ".invoice-table table { min-width:1100px }" en haut du fichier */
    }
    form .invoice-table .invoice-lines tr {
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 6px;
        padding: 12px;
        background: #fff;
    }
    form .invoice-table .invoice-lines td {
        border: none!important;
        padding: 6px 0;
        text-align: left !important;
    }
    /* champs alignés sur leur libellé, Quantité et Unité l'un sous l'autre */
    form .invoice-table .invoice-lines td [class*="col-md-"] {
        float: none; /* col-xs-12 de la colonne Ordre */
        padding-left: 0;
        padding-right: 0;
        margin-bottom: 0;
    }
    form .invoice-table .invoice-lines td [class*="col-md-"] + [class*="col-md-"] {
        margin-top: 10px;
    }
    /* Libellés par position : la colonne TVA n'existe qu'en multi-taux,
       donc Total et Actions se comptent depuis la fin de la ligne. */
    form .invoice-table .invoice-lines td:before {
        display: block;
        font-weight: bold;
        color: #555;
        font-size: 11px;
        text-transform: uppercase;
        margin-bottom: 3px;
    }
    form .invoice-table .invoice-lines td:nth-of-type(1):before { content: "Ordre"; }
    form .invoice-table .invoice-lines td:nth-of-type(2):before { content: "Produit"; }
    form .invoice-table .invoice-lines td:nth-of-type(3):before { content: "Prix"; }
    form .invoice-table .invoice-lines td:nth-of-type(4):before { content: "Quantité"; }
    form .invoice-table .invoice-lines td:nth-of-type(5):nth-last-of-type(3):before { content: "TVA"; }
    form .invoice-table .invoice-lines td:nth-last-of-type(2):before { content: "Total"; }
    form .invoice-table .invoice-lines td:nth-last-of-type(1):before { content: "Actions"; }
    form .invoice-table .add-line-btn {
        width: 100%;
    }
    /* Boutons de validation des documents et des formulaires (classe actions-formulaire) :
       un par ligne sur toute la largeur, les deux derniers côte à côte, au-dessus du bouton de retour en haut */
    form .invoice-table ~ .row .push-down-20,
    form .col-md-12.actions-formulaire {
        padding-bottom: 50px;
    }
    form .col-md-12.actions-formulaire {
        padding-left: 20px; /* alignés sur les champs */
        padding-right: 20px;
        gap: 0 !important; /* Modification produit : gap en style dans la page */
    }
    form .invoice-table ~ .row .push-down-20 .pull-left,
    form .invoice-table ~ .row .push-down-20 .pull-right,
    form .actions-formulaire .pull-left,
    form .actions-formulaire .pull-right {
        float: none !important; /* pull-left et pull-right de Bootstrap */
    }
    form .invoice-table ~ .row .push-down-20 .pull-right,
    form .actions-formulaire .pull-right {
        display: flex;
        flex-wrap: wrap;
        gap: 0 !important; /* Modification produit : gap en style dans la page */
    }
    form .invoice-table ~ .row .push-down-20 .btn,
    form .actions-formulaire .btn {
        display: block;
        width: 100%;
        margin: 10px 0 0 0;
        white-space: normal; /* texte sur deux lignes s'il ne tient pas, plutôt que de déborder */
    }
    form .invoice-table ~ .row .push-down-20 > .btn:first-child,
    form .actions-formulaire > .btn:first-child {
        margin-top: 0;
    }
    /* Modification produit : Annuler est après les boutons dans la page */
    form .actions-formulaire > div:not(.pull-right) {
        order: -1;
    }
    form .actions-formulaire > div:not(.pull-right) .btn {
        margin-top: 0;
    }
    /* Les deux derniers côte à côte, sans icône pour que le texte tienne sur une ligne */
    form .invoice-table ~ .row .push-down-20 .pull-right > .btn:nth-last-child(-n+2):not(:only-child),
    form .actions-formulaire .pull-right > .btn:nth-last-child(-n+2):not(:only-child) {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        padding-left: 4px;
        padding-right: 4px;
        display: flex; /* texte centré quand l'un des deux passe sur deux lignes */
        align-items: center;
        justify-content: center;
    }
    form .invoice-table ~ .row .push-down-20 .pull-right > .btn:last-child:not(:only-child),
    form .actions-formulaire .pull-right > .btn:last-child:not(:only-child) {
        margin-left: 10px;
    }
    form .invoice-table ~ .row .push-down-20 .pull-right > .btn:nth-last-child(-n+2):not(:only-child) .fa,
    form .actions-formulaire .pull-right > .btn:nth-last-child(-n+2):not(:only-child) .fa {
        display: none;
    }
    /* Listes Client et Produit : pas plus large que l'écran (le champ Client commence à 45px),
       noms trop longs coupés par "…", nom complet au survol (footer.php) */
    form .bootstrap-select .dropdown-menu {
        max-width: calc(100vw - 60px);
    }
    form .invoice-lines .bootstrap-select .dropdown-menu {
        max-width: 100%; /* dans une carte, la liste reste à la largeur du champ */
    }
    /* Blocs Client et De l'un sous l'autre : la hauteur commune du bureau ne sert plus */
    .business-info {
        min-height: 0!important;
    }
    /* Remise : type et valeur alignés sur les champs Tva et N°, un seul écart de 10px entre les deux */
    form .invoice-address td .col-xs-6:first-child {
        padding-right: 5px;
    }
    form .invoice-address td .col-xs-6:last-child {
        padding-left: 5px;
    }
    form .invoice-address .remise-value {
        padding-left: 6px;
        padding-right: 6px;
    }
    form .invoice-address .type-remise > .dropdown-toggle {
        padding-left: 6px;
        padding-right: 18px;
    }
    form .invoice-address .type-remise > .dropdown-toggle .caret {
        right: 6px;
    }
    form .bootstrap-select .dropdown-menu li a {
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* Page Détails : le produit en titre, puis un libellé à gauche et sa valeur à droite */
    .invoice-table tbody:not(.invoice-lines),
    .invoice-table tbody:not(.invoice-lines) tr {
        display: block;
        width: 100%;
    }
    .invoice-table tbody:not(.invoice-lines) tr {
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 6px;
        padding: 6px 12px;
        background: #fff;
    }
    .invoice-table tbody:not(.invoice-lines) td {
        display: flex;
        justify-content: space-between;
        border: none!important;
        border-top: 1px solid #eee!important;
        padding: 6px 0;
        text-align: right !important;
    }
    .invoice-table tbody:not(.invoice-lines) td:nth-of-type(1) {
        display: none; /* l'ordre suit déjà celui des cartes */
    }
    .invoice-table tbody:not(.invoice-lines) td:nth-of-type(2) {
        display: block;
        border-top: none!important;
        text-align: left !important;
        font-weight: bold;
    }
    .invoice-table tbody:not(.invoice-lines) td:before {
        font-weight: bold;
        color: #555;
        font-size: 11px;
        text-transform: uppercase;
        margin-right: 10px;
    }
    .invoice-table tbody:not(.invoice-lines) td:nth-of-type(3):before { content: "Prix"; }
    .invoice-table tbody:not(.invoice-lines) td:nth-of-type(4):before { content: "Quantité"; }
    .invoice-table tbody:not(.invoice-lines) td:nth-of-type(5):nth-last-of-type(2):before { content: "TVA"; }
    .invoice-table tbody:not(.invoice-lines) td:nth-last-of-type(1):before { content: "Total"; }
}


/* Back-office : affichage tableau sur mobile, pas de cartes */
@media (max-width: 768px) {
    .admin-body .table-responsive { overflow-x: auto !important; }
    .admin-body .datatable, .admin-body #trash_datatable { display: table !important; width: 100% !important; }
    .admin-body .datatable thead, .admin-body #trash_datatable thead { display: table-header-group !important; width: auto !important; }
    .admin-body .datatable tbody, .admin-body #trash_datatable tbody { display: table-row-group !important; width: auto !important; }
    .admin-body .datatable tr, .admin-body #trash_datatable tr {
        display: table-row !important;
        width: auto !important;
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .admin-body .datatable thead tr, .admin-body #trash_datatable thead tr { position: static !important; }
    .admin-body .datatable th, .admin-body .datatable td, .admin-body #trash_datatable th, .admin-body #trash_datatable td,
    .admin-body .datatable td.actions-cell, .admin-body #trash_datatable td.actions-cell {
        display: table-cell !important;
        width: auto !important;
        min-height: 0;
        padding: 8px !important;
        text-align: left !important;
    }
    .admin-body .datatable td, .admin-body #trash_datatable td { border: 1px solid #ddd !important; }
    .admin-body .datatable td:before, .admin-body #trash_datatable td:before { display: none !important; }
}

/* Liste des BL : case de sélection et bouton "Facturer la sélection" */
.bl-select-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    vertical-align: middle;
}
@media (max-width: 768px) {
    .bl-select-checkbox {
        width: 24px;
        height: 24px;
    }
    /* sous le bouton Ajouter, aligné sur son bord droit */
    #groupfacture-submit {
        clear: right;
        margin: 10px 0 0 !important;
    }
    /* flottant en bas de l'écran dès qu'un BL est coché */
    #groupfacture-submit.is-floating {
        position: fixed;
        left: 15px;
        right: 69px; /* 15px de marge + 44px du bouton de retour en haut + 10px d'écart */
        bottom: 15px;
        z-index: 1000;
        height: 44px;
        margin: 0 !important;
        padding: 0 12px;
        font-size: 15px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    /* le bouton flottant ne cache pas la dernière carte */
    body.bl-selection {
        padding-bottom: 75px;
    }
}

/* Champ N° du document sur fond blanc, pour qu'il ne paraisse pas désactivé */
.form-control.ref-input {
    background-color: #fff;
}

/* Bouton de retour en haut : foncé pour se détacher du fond gris clair, mêmes marges et même hauteur que le bouton flottant */
#topcontrol {
    right: 15px !important; /* le script le place en ligne à 10px */
    bottom: 15px !important;
    z-index: 1000;
}
#topcontrol .to-top {
    width: 44px;
    height: 44px;
    line-height: 42px;
    box-sizing: border-box;
    background: #33414e;
    border-color: #33414e;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
#topcontrol .to-top:hover {
    background: #1b2631;
    color: #fff;
}

/* En-tête : libellé « Paramètres » à côté de l'icône Entreprise, seulement sur les écrans larges (sinon la barre passe à la ligne) */
.x-navigation.x-navigation-horizontal .xn-parametres > a .libelle-parametres {
    display: none;
}
@media (min-width: 1280px) {
    .x-navigation.x-navigation-horizontal .xn-parametres > a {
        width: auto;
    }
    .x-navigation.x-navigation-horizontal .xn-parametres > a .libelle-parametres {
        display: inline;
        margin-left: 6px;
    }
}
