/* ==========================================================================
   TERGO FORMS — quantités et lignes de facture (tous secteurs)
   Utilisé avec dist/js/tergo-qty.js
   ========================================================================== */

/* ---------- Plus de petites flèches natives sur les champs marqués ---------- */
input.tg-nospin::-webkit-outer-spin-button,
input.tg-nospin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.tg-nospin[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* ---------- Widget quantité : [ − ][ 12 ][ + ] ---------- */
.tg-qty-wrap {
    display: flex; align-items: stretch; min-width: 118px; width: 100%;
}
.tg-qty-wrap .tg-qty {
    flex: 1 1 auto; min-width: 44px; text-align: center; font-weight: 600;
    border-radius: 0 !important; padding-left: 4px; padding-right: 4px;
}
.tg-qty-wrap .tg-qty-btn {
    flex: 0 0 36px; border: 1px solid #ced4da; background: #F4F7FC; color: #0D2A6B;
    font-size: 1.15rem; font-weight: 700; line-height: 1; padding: 0; cursor: pointer;
    user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.tg-qty-wrap .tg-qty-btn:hover  { background: #E3ECFB; }
.tg-qty-wrap .tg-qty-btn:active { background: #CFDDF7; }
.tg-qty-wrap .tg-qty-minus { border-radius: .25rem 0 0 .25rem; border-right: 0; }
.tg-qty-wrap .tg-qty-plus  { border-radius: 0 .25rem .25rem 0; border-left: 0; }
.form-control-sm + .tg-qty-btn, .tg-qty-wrap .form-control-sm ~ .tg-qty-btn { flex-basis: 30px; font-size: 1rem; }

/* ---------- Lignes de facture : cartes empilées sur téléphone ---------- */
@media (max-width: 767.98px) {
    table.tg-lines, table.tg-lines tbody { display: block; width: 100%; }
    table.tg-lines thead { display: none; }
    table.tg-lines.table-bordered, table.tg-lines.table-bordered td { border: 0; }
    table.tg-lines tbody tr {
        display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px;
        padding: 12px; margin-bottom: 12px; background: #fff;
        border: 1px solid #D9E5FA; border-radius: 10px;
        box-shadow: 0 1px 3px rgba(13, 42, 107, .06); position: relative;
    }
    table.tg-lines tbody td { display: block; padding: 0 !important; border: 0 !important; min-width: 0; }
    table.tg-lines tbody td::before {
        content: attr(data-label); display: block; font-size: .72rem; font-weight: 700;
        text-transform: uppercase; letter-spacing: .03em; color: #6c7a93; margin-bottom: 3px;
    }
    table.tg-lines tbody td[data-label=""]::before { display: none; }
    /* Désignation / description / quantité : pleine largeur */
    table.tg-lines tbody td.tg-full,
    table.tg-lines tbody td:first-child { grid-column: 1 / -1; padding-right: 44px !important; }
    table.tg-lines tbody td.tg-qty-cell { grid-column: 1 / -1; }
    /* Bouton supprimer : coin haut droit de la carte */
    table.tg-lines tbody td.tg-del {
        position: absolute; top: 10px; right: 10px; width: auto;
    }
    table.tg-lines tbody td.tg-del::before { display: none; }
    table.tg-lines tbody td.tg-del .btn { padding: 4px 10px; }
    table.tg-lines .form-control { font-size: 16px; height: 42px; }   /* 16px : pas de zoom iOS */
    table.tg-lines .tg-qty-wrap .tg-qty-btn { flex-basis: 46px; font-size: 1.3rem; }
    table.tg-lines input[readonly] { background: #F4F8FF; font-weight: 700; }
    .table-responsive > table.tg-lines { margin-bottom: 8px; }
}

/* ---------- Barre d'enregistrement collante (mobile) ---------- */
@media (max-width: 767.98px) {
    .tg-sticky-actions {
        position: sticky; bottom: 0; z-index: 20; background: #fff;
        margin: 0 -15px; padding: 10px 15px; border-top: 1px solid #D9E5FA;
        box-shadow: 0 -4px 12px rgba(13, 42, 107, .08);
    }
    .tg-sticky-actions .btn-primary { flex: 1 1 auto; }
}
