/* 
 * FIX TABELLE GESTIONALE - Ottimizzazione layout tabelle
 * Risolve problema pulsanti azioni che escono dalla cella
 */

/* FORZA table-layout fixed per tutte le tabelle principali */
.table {
    table-layout: fixed !important;
}

/* Ottimizza padding celle tabella */
.table td,
.table th {
    vertical-align: middle !important;
    padding: 0.5rem !important;
}

/* Colonna azioni ottimizzata */
.table td:last-child,
.table th:last-child {
    width: 180px !important;
    min-width: 180px !important;
    max-width: 180px !important;
    padding: 0.3rem 0.2rem !important;
    text-align: center !important;
    white-space: nowrap !important;
}

/* Ottimizza btn-group in tutte le tabelle */
.table .btn-group {
    display: inline-flex !important;
    gap: 2px !important;
    flex-wrap: nowrap !important;
}

/* Pulsanti azioni super compatti */
.table .btn-group .btn,
.table .btn-group a.btn {
    padding: 0.2rem 0.35rem !important;
    font-size: 0.7rem !important;
    line-height: 1.2 !important;
    border-width: 1px !important;
    border-radius: 3px !important;
    min-width: 28px !important;
    flex-shrink: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* TUTTI i pulsanti nell'ultima colonna (azioni) - anche fuori btn-group */
.table td:last-child .btn,
.table td:last-child a.btn,
.table td:last-child button.btn,
.table tbody td:last-child .btn,
.table tbody td:last-child a.btn,
.table tbody td:last-child button.btn {
    padding: 0.2rem 0.35rem !important;
    font-size: 0.7rem !important;
    line-height: 1.2 !important;
    border-width: 1px !important;
    border-radius: 3px !important;
    min-width: 28px !important;
    max-height: 26px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 1px !important;
}

/* Override specifico per btn-sm che potrebbe essere applicato */
.table td:last-child .btn-sm,
.table td:last-child a.btn-sm,
.table tbody td:last-child .btn-sm,
.table tbody td:last-child a.btn-sm {
    padding: 0.2rem 0.35rem !important;
    font-size: 0.7rem !important;
    line-height: 1.2 !important;
}

/* Override per tutte le varianti di colore Bootstrap */
.table td:last-child .btn-primary,
.table td:last-child .btn-secondary,
.table td:last-child .btn-success,
.table td:last-child .btn-danger,
.table td:last-child .btn-warning,
.table td:last-child .btn-info,
.table td:last-child .btn-light,
.table td:last-child .btn-dark,
.table td:last-child .btn-outline-primary,
.table td:last-child .btn-outline-secondary,
.table td:last-child .btn-outline-success,
.table td:last-child .btn-outline-danger,
.table td:last-child .btn-outline-warning,
.table td:last-child .btn-outline-info {
    padding: 0.2rem 0.35rem !important;
    font-size: 0.7rem !important;
    line-height: 1.2 !important;
    max-height: 26px !important;
}

/* Icone nei pulsanti */
.table .btn-group .btn i,
.table .btn-group a.btn i,
.table td:last-child .btn i,
.table td:last-child a.btn i {
    font-size: 0.7rem !important;
    margin: 0 !important;
}

/* Responsività: su schermi piccoli riduci ulteriormente */
@media (max-width: 1200px) {
    .table .btn-group .btn,
    .table .btn-group a.btn {
        padding: 0.15rem 0.25rem !important;
        font-size: 0.65rem !important;
        min-width: 24px !important;
    }
    
    .table .btn-group .btn i,
    .table .btn-group a.btn i {
        font-size: 0.65rem !important;
    }
}

/* Badge nelle tabelle */
.table .badge {
    font-size: 0.7rem !important;
    padding: 0.25rem 0.5rem !important;
}

/* Previeni overflow contenuto celle */
.table td {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Tranne ultima colonna (azioni) che deve vedere i pulsanti */
.table td:last-child {
    overflow: visible !important;
}

/* Fix scrollbar orizzontale ricerca ricambio */
#section-ricambi-costi {
    overflow-x: hidden !important;
}

#ricambio_dropdown {
    border-top: 0 !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    word-wrap: break-word !important;
}

#ricambio_results {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* Previeni overflow sui risultati ricerca */
#ricambio_results .list-group-item {
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* Container ricambi senza overflow orizzontale */
#ricambi-container {
    overflow-x: hidden !important;
    max-width: 100% !important;
}

#sezione-ricambi {
    overflow-x: hidden !important;
    max-width: 100% !important;
}
