body {
    background: #f8f9fa;
}

h1 {
    margin: 20px 0 30px 0;
}

#calendar {
    margin-top: 30px;
}

/* evidenzia modalità copia su entrambe le viste */
.van-copy-mode .van-day-table,
.van-copy-mode .dashboard-table {
    outline: 2px dashed #b02a37;
    outline-offset: 4px;
}

/* messaggini */
.van-copy-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    line-height: 1.4;
    color: #b02a37;
    background: #ffe5e9;
    padding: 8px 12px;
    border-radius: 6px;
    margin: 12px 0 0;
    font-weight: 600;
}

/* Sticky header e contenitori scrollabili per calendario desktop */

#dashboardStickyHeader {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #f8f9fa;
    padding-top: 10px;
}

.calendar-scroll {
    overflow: auto;
    max-height: calc(100vh - 130px);
    position: relative; /* ensure sticky context in Chrome */
    margin-bottom: 16px;
}

.dashboard-table thead th {
    position: sticky;
    top: 0;
    z-index: 5; /* higher so it stays above cells in Chrome */
    background: #f5f5f5; /* paint over content */
}


/* Sticky per intestazione mobile (annullato su richiesta) */

.table th,
.table td {
    vertical-align: middle !important;
}

#modals .modal {
    z-index: 1050;
}


/* Chrome desktop: avoid clipped text inside selects in Bootstrap modals */
.modal select.form-control {
    height: auto !important;
    min-height: 40px;
    line-height: normal;
    white-space: normal;
    overflow: visible;
    text-overflow: initial;
    padding: 10px 32px 10px 12px;
    -webkit-appearance: auto;
    appearance: auto;
}

/* Ensure containers don’t clip native controls */
.modal .form-group,
.modal-body,
.modal-content {
    overflow: visible;
}


/* Nascondi modali di assegnazione su desktop (non tablet) */


/*@media (min-width: 1025px) {
    #modals .modal[id*="asgn"]:not(#asgnEditModal),
    #modals .modal[id*="assignment"]:not(#asgnEditModal),
    #modals .modal[id*="slot"]:not(#asgnEditModal) {
        display: none !important;
    }
}*/


/* Nascondi modali di assegnazione su mobile (sotto 768px) */

@media (max-width: 767px) {

    #modals .modal[id*="asgn"]:not(#asgnEditModal),
    #modals .modal[id*="assignment"]:not(#asgnEditModal),
    #modals .modal[id*="slot"]:not(#asgnEditModal) {
        display: none !important;
    }
}


/* Mostra modali di assegnazione su tablet (768px-1024px) */

@media (min-width: 768px) and (max-width: 1024px) {

    #modals .modal[id*="asgn"]:not(#asgnEditModal),
    #modals .modal[id*="assignment"]:not(#asgnEditModal),
    #modals .modal[id*="slot"]:not(#asgnEditModal) {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Assicura che i modali siano visibili e funzionanti su tablet */
    .modal-dialog {
        margin: 30px auto;
        max-width: 90%;
    }

    .modal-content {
        border-radius: 8px;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    }

    .modal-header {
        padding: 15px 20px;
        border-bottom: 1px solid #e5e5e5;
    }

    .modal-body {
        padding: 20px;
        max-height: 70vh;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 15px 20px;
        border-top: 1px solid #e5e5e5;
    }

    /* Ottimizza le select per tablet */
    .modal select.form-control {
        font-size: 16px;
        padding: 10px 12px;
        border-radius: 6px;
        border: 1px solid #ccc;
        background-color: #fff;
        width: 100%;
        margin-bottom: 15px;
    }

    .modal select.form-control:focus {
        border-color: #66afe9;
        outline: 0;
        box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6);
    }

    /* Ottimizza le select multiple per tablet */
    .modal select[multiple].form-control {
        min-height: 120px;
        max-height: 200px;
    }

    .modal select[multiple].form-control option {
        padding: 8px 12px;
        font-size: 14px;
        border-bottom: 1px solid #f0f0f0;
    }

    .modal select[multiple].form-control option:checked {
        background-color: #337ab7;
        color: white;
    }
}


/* Regole aggiuntive per tablet in orizzontale */

@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {

    /* Sidebar ottimizzata per landscape */
    #sidebarCantieri {
        z-index: 1000;
        /* Aumentato per evitare sovrapposizioni */
        background: #f8f9fa;
        /* Background solido per evitare trasparenza */
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        margin-bottom: 20px;
    }

    #modals .modal[id*="asgn"],
    #modals .modal[id*="assignment"],
    #modals .modal[id*="slot"] {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .modal-dialog {
        margin: 20px auto;
        max-width: 80%;
        z-index: 1050 !important;
    }

    .modal-body {
        max-height: 60vh;
    }

    /* Forza la visibilità del backdrop */
    .modal-backdrop {
        display: block !important;
        z-index: 1040 !important;
        opacity: 0.5 !important;
    }

    /* Assicura che il contenuto principale non interferisca */
    .col-md-10 {
        z-index: 1;
        /* Z-index inferiore alla sidebar */
        position: relative;
    }
}


/* Regole specifiche per iPad in landscape */

@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) and (-webkit-min-device-pixel-ratio: 2) {

    #modals .modal[id*="asgn"]:not(#asgnEditModal),
    #modals .modal[id*="assignment"]:not(#asgnEditModal),
    #modals .modal[id*="slot"]:not(#asgnEditModal) {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 1050 !important;
    }

    .modal-dialog {
        margin: 15px auto;
        max-width: 75%;
        z-index: 1050 !important;
    }

    .modal-content {
        border-radius: 8px;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    }

    .modal-body {
        max-height: 55vh;
        overflow-y: auto;
    }

    /* Forza la visibilità del backdrop */
    .modal-backdrop {
        display: block !important;
        z-index: 1040 !important;
        opacity: 0.5 !important;
    }

    /* Assicura che il contenuto principale non interferisca */
    .col-md-10 {
        z-index: 1;
        /* Z-index inferiore alla sidebar */
        position: relative;
    }

    /* Miglioramenti per i pulsanti di chiusura su iPad landscape */
    .modal .close {
        position: relative !important;
        z-index: 1060 !important;
        font-size: 24px !important;
        line-height: 1 !important;
        padding: 8px 12px !important;
        margin: -8px -12px -8px auto !important;
        background: transparent !important;
        border: none !important;
        opacity: 1 !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0, 123, 255, 0.3) !important;
        pointer-events: auto !important;
        user-select: none !important;
        -webkit-user-select: none !important;
    }

    .modal .close:hover,
    .modal .close:focus {
        opacity: 0.7 !important;
        outline: none !important;
    }

    .modal .close:active {
        opacity: 0.5 !important;
    }

    .modal-footer .btn-default {
        position: relative !important;
        z-index: 1060 !important;
        min-height: 44px !important;
        min-width: 80px !important;
        font-size: 16px !important;
        padding: 10px 16px !important;
        margin: 5px !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0, 123, 255, 0.3) !important;
        cursor: pointer !important;
        pointer-events: auto !important;
        user-select: none !important;
        -webkit-user-select: none !important;
    }

    .modal-footer .btn-default:hover,
    .modal-footer .btn-default:focus {
        outline: none !important;
        box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3) !important;
    }

    .modal-footer .btn-default:active {
        transform: scale(0.98) !important;
    }

    /* Assicura che l'header del modale sia cliccabile */
    .modal-header {
        position: relative !important;
        z-index: 1060 !important;
        padding: 15px 20px !important;
        pointer-events: auto !important;
    }

    .modal-footer {
        position: relative !important;
        z-index: 1060 !important;
        padding: 15px 20px !important;
        pointer-events: auto !important;
    }

    /* Miglioramenti per il backdrop su iPad landscape */
    .modal-backdrop {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background-color: rgba(0, 0, 0, 0.5) !important;
        z-index: 1040 !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        pointer-events: auto !important;
    }

    .modal-backdrop:hover {
        background-color: rgba(0, 0, 0, 0.6) !important;
    }

    /* Assicura che il modale sia sempre sopra il backdrop */
    .modal {
        z-index: 1050 !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        outline: 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        pointer-events: auto !important;
    }

    /* Miglioramenti per il contenuto del modale */
    .modal-content {
        position: relative !important;
        z-index: 1060 !important;
        background-color: #fff !important;
        border: 1px solid rgba(0, 0, 0, 0.2) !important;
        border-radius: 8px !important;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5) !important;
        outline: 0 !important;
        pointer-events: auto !important;
    }

    /* Stili specifici per il pulsante di emergenza */
    #emergency-close {
        position: fixed !important;
        top: 10px !important;
        right: 10px !important;
        z-index: 9999 !important;
        background: red !important;
        color: white !important;
        padding: 10px !important;
        border-radius: 5px !important;
        cursor: pointer !important;
        font-size: 14px !important;
        font-weight: bold !important;
        border: none !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(255, 0, 0, 0.3) !important;
        pointer-events: auto !important;
        user-select: none !important;
        -webkit-user-select: none !important;
    }

    #emergency-close:hover {
        background: darkred !important;
        transform: scale(1.05) !important;
    }

    #emergency-close:active {
        transform: scale(0.95) !important;
    }
}


/* Regole aggiuntive per tablet in verticale */

@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {

    #modals .modal[id*="asgn"]:not(#asgnEditModal),
    #modals .modal[id*="assignment"]:not(#asgnEditModal),
    #modals .modal[id*="slot"]:not(#asgnEditModal) {
        display: block !important;
    }

    .modal-dialog {
        margin: 40px auto;
        max-width: 95%;
    }

    .modal-body {
        max-height: 80vh;
    }
}


/* Regole per dispositivi touch con schermo tablet-size */

@media (min-width: 768px) and (max-width: 1024px) and (hover: none) and (pointer: coarse) {

    #modals .modal[id*="asgn"],
    #modals .modal[id*="assignment"],
    #modals .modal[id*="slot"] {
        display: block !important;
    }

    .modal-dialog {
        margin: 25px auto;
        max-width: 85%;
    }

    .modal select.form-control {
        font-size: 18px;
        /* Più grande per touch */
        padding: 12px 15px;
    }

    .modal select[multiple].form-control {
        min-height: 150px;
        max-height: 250px;
    }
}

/* Il sidebar resta visibile mentre scorri la colonna destra */
#sidebarCantieri {
    position: sticky;
    top: 10px;
    /* regola se hai header fissati */
    align-self: flex-start;
}

/* La UL dei cantieri scorre internamente */
#draggableSites {
    max-height: calc(100vh - 140px);
    /* adatta 140px a titolo/margini della tua UI */
    overflow: auto;
    overscroll-behavior: contain;
    /* evita lo “scroll a cascata” sul body/calendario */
    -webkit-overflow-scrolling: touch;
}

/* Evita che container genitori uccidano lo sticky */
.row,
.col-md-2 {
    overflow: visible;
}

/* (opzionale) scrollbar webkit */
#draggableSites::-webkit-scrollbar {
    width: 8px;
}

#draggableSites::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .25);
    border-radius: 8px;
}

/* Sidebar cantieri schedulabili */

#sidebarCantieri {
    position: sticky;
    top: 20px;
    height: fit-content;
    z-index: 100;
}

#sidebarCantieri ul.list-group {
    margin-top: 10px;
}

.draggable-site {
    cursor: grab;
    transition: background 0.2s;
    font-size: 15px;
    border-radius: 6px;
    margin-bottom: 6px;
    border: 1px solid #e0e0e0;
    /* Ottimizzazioni per touch devices */
    touch-action: pan-x pan-y;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}


/* Ottimizzazioni specifiche per drag and drop su tablet */

@media (min-width: 768px) and (max-width: 1024px) {
    .draggable-site {
        cursor: grab;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 123, 255, 0.1);
    }

    .draggable-site:active {
        cursor: grabbing;
    }

    .draggable-site.ui-draggable-dragging {
        cursor: grabbing !important;
        z-index: 10000;
        opacity: 0.8;
        transform: rotate(5deg);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }

    .draggable-site.touch-active {
        background-color: #e3f2fd !important;
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2);
    }

    .ui-draggable-helper {
        background: #fff !important;
        border: 2px solid #2196f3 !important;
        border-radius: 8px !important;
        box-shadow: 0 8px 25px rgba(33, 150, 243, 0.3) !important;
        transform: rotate(3deg) !important;
        opacity: 0.9 !important;
        z-index: 10001 !important;
        pointer-events: none !important;
    }

    /* Styling per placeholder durante il drag and drop negli slot */
    .slot-placeholder {
        background: linear-gradient(90deg, transparent 0%, #2196f3 50%, transparent 100%) !important;
        height: 3px !important;
        margin: 2px 0 !important;
        border-radius: 2px !important;
        opacity: 0.8 !important;
        animation: pulse 1s infinite !important;
    }

    @keyframes pulse {
        0% { opacity: 0.8; }
        50% { opacity: 1; }
        100% { opacity: 0.8; }
    }

    /* Miglioramento feedback visivo per slot durante il drag */
    .slot-list.ui-sortable-helper {
        background-color: rgba(33, 150, 243, 0.1) !important;
        border: 2px dashed #2196f3 !important;
        border-radius: 8px !important;
    }

    /* Indicatore di inserimento più visibile */
    .slot-list .insertion-indicator {
        background: #2196f3 !important;
        height: 2px !important;
        margin: 1px 0 !important;
        border-radius: 1px !important;
        opacity: 0.9 !important;
        box-shadow: 0 0 4px rgba(33, 150, 243, 0.5) !important;
        transition: all 0.2s ease !important;
    }

    /* Feedback visivo per elementi durante il drag */
    .slot-list .list-group-item.drag-hover-top {
        border-top: 2px solid #2196f3 !important;
        background-color: rgba(33, 150, 243, 0.1) !important;
    }

    .slot-list .list-group-item.drag-hover-bottom {
        border-bottom: 2px solid #2196f3 !important;
        background-color: rgba(33, 150, 243, 0.1) !important;
    }

    /* Feedback visivo per pannelli durante il drag */
    .droppable-cell .panel.drag-hover-top {
        border-top: 2px solid #2196f3 !important;
        background-color: rgba(33, 150, 243, 0.1) !important;
    }

    .droppable-cell .panel.drag-hover-bottom {
        border-bottom: 2px solid #2196f3 !important;
        background-color: rgba(33, 150, 243, 0.1) !important;
    }

    /* Styling per placeholder nei pannelli */
    .droppable-cell .slot-placeholder {
        background: linear-gradient(90deg, transparent 0%, #2196f3 50%, transparent 100%) !important;
        height: 3px !important;
        margin: 2px 0 !important;
        border-radius: 2px !important;
        opacity: 0.8 !important;
        animation: pulse 1s infinite !important;
    }

    /* Indicatori di inserimento per pannelli */
    .droppable-cell .insertion-indicator {
        background: #2196f3 !important;
        height: 2px !important;
        margin: 1px 0 !important;
        border-radius: 1px !important;
        opacity: 0.9 !important;
        box-shadow: 0 0 4px rgba(33, 150, 243, 0.5) !important;
        transition: all 0.2s ease !important;
    }

    .droppable-cell,
    .droppable-cell-unassigned {
        touch-action: pan-x pan-y;
        position: relative;
        min-height: 60px;
    }

    .droppable-cell.cell-hover,
    .droppable-cell-unassigned.cell-hover {
        background-color: #e3f2fd !important;
        border: 2px solid #2196f3 !important;
        box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2) inset;
    }

    .draggable-assignment {
        z-index: 100;
        position: relative;
    }

    .draggable-assignment.ui-draggable-dragging {
        cursor: grabbing !important;
        z-index: 10000;
        opacity: 0.8;
        transform: rotate(5deg);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }

    .draggable-assignment.touch-active {
        background-color: #e3f2fd !important;
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2);
    }
}


/* Regole globali per dispositivi touch */

@media (hover: none) and (pointer: coarse) {

    .draggable-site,
    .draggable-assignment {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 123, 255, 0.1);
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        position: relative;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .droppable-cell,
    .droppable-cell-unassigned {
        touch-action: pan-x pan-y;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    /* Feedback visivo per touch */
    .draggable-site.touch-active,
    .draggable-assignment.touch-active {
        background-color: #e3f2fd !important;
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2);
        transition: all 0.2s ease;
        border: 2px solid #2196f3 !important;
        border-radius: 8px;
    }

    /* Migliora l'aspetto cliccabile per tablet */
    .draggable-site:hover,
    .draggable-assignment:hover {
        background-color: #f0f8ff !important;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(33, 150, 243, 0.15);
        border: 2px solid #2196f3;
        border-radius: 8px;
    }

    /* Feedback per celle slot cliccabili */
    .droppable-cell:hover,
    .droppable-cell-unassigned:hover {
        background-color: #e8f5e8 !important;
        border: 2px solid #4caf50 !important;
        box-shadow: 0 4px 12px rgba(76, 175, 80, 0.15);
        transform: scale(1.02);
    }

    /* Helper element per drag nativo */
    .ui-draggable-helper {
        background: #fff !important;
        border: 2px solid #2196f3 !important;
        border-radius: 8px !important;
        box-shadow: 0 8px 25px rgba(33, 150, 243, 0.3) !important;
        transform: rotate(3deg) !important;
        opacity: 0.9 !important;
        z-index: 10001 !important;
        pointer-events: none !important;
        position: fixed !important;
    }

    /* Feedback per drop zones */
    .droppable-cell.cell-hover,
    .droppable-cell-unassigned.cell-hover {
        background-color: #e3f2fd !important;
        border: 2px solid #2196f3 !important;
        box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2) inset;
        transform: scale(1.02);
        transition: all 0.2s ease;
    }

    /* Miglioramenti per modali su tablet */
    .modal-dialog {
        margin: 20px auto;
        max-width: 95%;
    }

    .modal-content {
        border-radius: 12px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    }

    .modal-header {
        border-bottom: 2px solid #e9ecef;
        padding: 20px;
    }

    .modal-body {
        padding: 25px;
    }

    .modal-footer {
        border-top: 2px solid #e9ecef;
        padding: 20px;
    }

    .form-control {
        font-size: 16px;
        /* Previene zoom su iOS */
        padding: 12px;
        border-radius: 8px;
        border: 2px solid #e9ecef;
    }

    .form-control:focus {
        border-color: #2196f3;
        box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    }

    .btn {
        padding: 12px 24px;
        font-size: 16px;
        border-radius: 8px;
        border: none;
        min-height: 44px;
        /* Area touch minima */
    }

    /* Rimuovi tooltip per tablet - comportamento click diretto */
    .draggable-site::after,
    .draggable-assignment::after,
    .droppable-cell::after,
    .droppable-cell-unassigned::after {
        display: none;
    }
}

.draggable-site-confirmato {
    background: #e8f5e9;
    border-left: 5px solid #f2cc11;
}

.draggable-site-nonconfermato {
    background: #fff8e1;
    border-left: 5px solid #ff9800;
}

.draggable-site-completato {
    background: #e8f5e9;
    border-left: 5px solid #5cb85c;
}

.draggable-site:hover {
    background: #f1f1f1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    cursor: grabbing;
}

.draggable-site .label {
    font-size: 12px;
    margin-left: 6px;
}


/* Tabella pianificazione */

.van-day-table,
.dashboard-table {
    background: #fff;
    border-radius: 8px;
    /* overflow hidden breaks position: sticky in Chrome; keep visible */
    overflow: visible;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border-collapse: separate; /* improve sticky behavior */
    border-spacing: 0;
}

.van-day-table th,
.dashboard-table th {
    background: #f5f5f5;
    font-weight: 600;
    text-align: center;
    font-size: 15px;
    border-bottom: 2px solid #e0e0e0;
}

/* Make headers sticky for both tables (works in Chrome) */
.van-day-table thead th,
.dashboard-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
}

.van-day-table td,
.dashboard-table td {
    min-width: 120px;
    vertical-align: top;
    background: #fafbfc;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: box-shadow 0.2s;
}

.van-day-table tr:nth-child(odd) td,
.dashboard-table tr:nth-child(odd) td {
    background: #f9fbe7;
}

.van-day-table tr:nth-child(even) td,
.dashboard-table tr:nth-child(even) td {
    background: #e3f2fd;
}

.dashboard-cell-unassigned,
.van-day-cell-unassigned,
.droppable-cell-unassigned {
    background: #ececec !important;
    border-left: 4px solid #bdbdbd !important;
    color: #444;
    font-weight: 500;
}

.droppable-cell,
.droppable-cell-unassigned {
    transition: box-shadow 0.2s, border 0.2s;
    /* Ottimizzazioni per touch devices */
    touch-action: pan-x pan-y;
    position: relative;
}

.droppable-cell.cell-hover,
.droppable-cell-unassigned.cell-hover {
    box-shadow: 0 0 0 3px #2196f3 inset, 0 2px 12px rgba(33, 150, 243, 0.08);
    border: 2px solid #2196f3;
}


/* Panel assignment */

.panel-xs {
    margin-bottom: 6px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    font-size: 14px;
    padding: 0 2px;
}

.panel-default.panel-xs {
    border-left: 4px solid #1976d2;
}

.panel-warning.panel-xs {
    border-left: 4px solid #ff9800;
    background: #fffde7;
}

.panel-xs .panel-body {
    padding: 6px 8px;
    line-height: 1.5;
}

/* Allinea i pulsanti in alto a destra nel pannello assignment */
.panel-xs .del-assignment,
.panel-xs .copy-assignment {
    position: relative;
    top: -2px;              /* micro correzione verticale */
}

/* Correzione specifica per il bottone rosso (X) */
.panel-xs .del-assignment {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    line-height: 1;         /* evita sfasamenti verticali */
}
.panel-xs .del-assignment .glyphicon {
    line-height: 1;
}

.panel-xs .fa,
.panel-xs .glyphicon {
    margin-right: 4px;
    /*color: #888;*/
}


/* Data odierna */

#vanDayToday {
    display: block;
    clear: both;
    position: relative;
    z-index: 10;
    background: #e3f2fd;
    padding: 8px 0 8px 0; /* più compatto: più spazio al calendario */
    font-size: 16px;
    text-align: center;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: 0 1px 6px rgba(33, 150, 243, 0.07);
}

#vanDayToday .fa-calendar {
    color: #1976d2;
    margin-right: 8px;
    font-size: 18px;
}

#logoutBtn {
    background: #e53935;
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 3px 12px 3px 10px;
    font-weight: 600;
    font-size: 13px;
    box-shadow: 0 2px 6px rgba(229, 57, 53, 0.08);
    transition: background 0.2s, box-shadow 0.2s;
    position: relative;
}

#logoutBtn:hover,
#logoutBtn:focus {
    background: #b71c1c;
    color: #fff;
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.18);
}

#logoutBtn .glyphicon-log-out {
    margin-right: 5px;
}


/* Responsive migliorato */


/* Tablet (768px - 1024px) */

@media (min-width: 768px) and (max-width: 1024px) {

    /* Layout generale per tablet */
    .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Header e titoli */
    h1 {
        font-size: 24px;
        margin: 15px 0 20px 0;
    }

    /* Sidebar ottimizzata per tablet */
    #sidebarCantieri {
        position: sticky;
        top: 15px;
        max-height: 85vh;
        overflow-y: auto;
        padding-right: 10px;
        z-index: 1000;
        /* Aumentato per evitare sovrapposizioni */
        background: #f8f9fa;
        /* Background solido per evitare trasparenza */
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        margin-bottom: 20px;
    }

    #sidebarCantieri h4 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .draggable-site {
        font-size: 14px;
        padding: 8px 10px;
        margin-bottom: 8px;
    }

    /* Tabelle ottimizzate per tablet */
    .van-day-table,
    .dashboard-table {
        font-size: 13px;
    }

    .van-day-table th,
    .dashboard-table th {
        font-size: 13px;
        padding: 8px 4px;
    }

    .van-day-table td,
    .dashboard-table td {
        min-width: 100px;
        padding: 6px 4px;
        font-size: 12px;
    }

    /* Panel assignments più compatti */
    .panel-xs {
        margin-bottom: 4px;
        font-size: 12px;
    }

    .panel-xs .panel-body {
        padding: 4px 6px;
        line-height: 1.3;
    }

    /* Bottoni più piccoli per tablet */
    .btn-xs {
        padding: 2px 6px;
        font-size: 11px;
    }

    /* Nav tabs ottimizzati */
    .nav-tabs>li>a {
        padding: 8px 12px;
        font-size: 14px;
    }

    /* Modali ottimizzati per tablet */
    .modal-dialog {
        width: 90%;
        max-width: 600px;
    }

    /* Chrome fix: avoid clipped selects inside modal on desktop/tablet */
    .modal select.form-control {
        height: auto !important;
        min-height: 38px;
        line-height: normal;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        padding-right: 32px;
    }

    .modal-body {
        padding: 15px;
    }

    /* Form controls ottimizzati */
    .form-control {
        font-size: 16px;
        /* Previene zoom su iOS */
        padding: 8px 10px;
    }

    /* Logout button ottimizzato */
    #logoutBtn {
        font-size: 12px;
        padding: 4px 10px;
    }
}


/* Tablet in modalità portrait (verticale) */

@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {

    /* Layout ottimizzato per portrait */
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Header più compatto */
    h1 {
        font-size: 20px;
        margin: 10px 0 15px 0;
    }

    /* Sidebar ottimizzata per portrait - arriva fino a fine schermo */
    #sidebarCantieri {
        position: sticky;
        top: 10px;
        max-height: 90vh;
        /* Aumentato per sfruttare più spazio verticale */
        overflow-y: auto;
        padding-right: 8px;
        padding-bottom: 20px;
        /* Spazio extra in fondo */
    }

    #sidebarCantieri h4 {
        font-size: 15px;
        margin-bottom: 10px;
    }

    /* Cantieri più compatti per portrait */
    .draggable-site {
        font-size: 13px;
        padding: 6px 8px;
        margin-bottom: 6px;
    }

    /* Tabelle più compatte per portrait */
    .van-day-table,
    .dashboard-table {
        font-size: 12px;
    }

    .van-day-table th,
    .dashboard-table th {
        font-size: 12px;
        padding: 6px 3px;
    }

    .van-day-table td,
    .dashboard-table td {
        min-width: 90px;
        padding: 4px 3px;
        font-size: 11px;
    }

    /* Panel assignments ancora più compatti */
    .panel-xs {
        margin-bottom: 3px;
        font-size: 11px;
    }

    .panel-xs .panel-body {
        padding: 3px 5px;
        line-height: 1.2;
    }

    /* Nav tabs più compatti */
    .nav-tabs>li>a {
        padding: 6px 10px;
        font-size: 13px;
    }

    /* Logout button più compatto */
    #logoutBtn {
        font-size: 11px;
        padding: 3px 8px;
    }

    /* Assicura che la sidebar arrivi fino a fine schermo */
    #sidebarCantieri ul.list-group {
        margin-bottom: 0;
        padding-bottom: 10px;
    }

    /* Ottimizza lo spazio verticale */
    .row {
        margin-left: -5px;
        margin-right: -5px;
    }

    .col-md-2,
    .col-md-10 {
        padding-left: 5px;
        padding-right: 5px;
    }
}


/* Desktop e tablet grandi (oltre 1024px) */

@media (min-width: 1025px) {

    .van-day-table td,
    .dashboard-table td {
        min-width: 120px;
        font-size: 14px;
    }

    #sidebarCantieri {
        font-size: 15px;
        position: sticky;
        top: 20px;
    }
}


/* Mobile (sotto 768px) */

@media (max-width: 767px) {

    .van-day-table td,
    .dashboard-table td {
        min-width: 80px;
        font-size: 13px;
    }

    #sidebarCantieri {
        font-size: 14px;
        position: sticky;
        top: 10px;
    }

    /* Lascia spazio tappabile a fine slot nella tabella desktop vista su mobile */
    .droppable-cell,
    .droppable-cell-unassigned {
        padding-bottom: 56px; /* più area tappabile in fondo allo slot */
        padding-top: 8px;
    }

    /* ultimo pannello con un po' di respiro */
    .panel-xs:last-child {
        margin-bottom: 12px;
    }
}

@media print {

    body,
    html {
        background: #fff !important;
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .container-fluid {
        height: auto !important;
        overflow: visible !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .row {
        height: auto !important;
        overflow: visible !important;
        max-height: none !important;
        margin: 0 !important;
    }

    .row:first-child {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .col-md-2,
    .col-md-10,
    .col-xs-2,
    .col-xs-10 {
        padding: 0 !important;
    }

    .col-md-2 {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }

    .col-md-10 {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .tab-content {
        height: auto !important;
        overflow: visible !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    .tab-pane {
        height: auto !important;
        overflow: visible !important;
        max-height: none !important;
        display: block !important;
        page-break-inside: avoid !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .tab-pane#dashboard {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    .tab-pane:not(.active) {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .calendar-scroll {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
        position: static !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #calendarScroll {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #dashboardStickyHeader {
        position: static !important;
        margin: 0 !important;
        padding: 0 !important;
        height: 0 !important;
        display: none !important;
    }

    [class*="sticky"],
    [id*="Sticky"],
    [id*="sticky"] {
        position: static !important;
    }

    .container-fluid > .row:first-child {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        visibility: hidden !important;
    }

    br {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #sidebarCantieri,
    .nav,
    .nav-tabs,
    .tab-content>.tab-pane:not(.active),
    .btn,
    #modals,
    #dashboardWeekNav,
    #vanDayWeekNav,
    .pull-right,
    img[alt="Logo STC"],
    h1 {
        display: none !important;
        height: 0 !important;
        width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        visibility: hidden !important;
        font-size: 0 !important;
        line-height: 0 !important;
    }

    #vanDayToday,
    #vanDayTable,
    #calendar {
        display: block !important;
        page-break-inside: avoid !important;
        margin-top: 0 !important;
    }

    #vanDayTable,
    #calendar {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding: 0 !important;
    }

    #calendar {
        page-break-before: auto !important;
    }

    .van-day-table,
    .dashboard-table {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        page-break-inside: auto !important;
    }

    .van-day-table tbody,
    .dashboard-table tbody {
        display: table-row-group !important;
    }

    .van-day-table tr,
    .dashboard-table tr {
        page-break-inside: avoid !important;
        page-break-after: auto !important;
    }

    .table {
        font-size: 12px !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        width: 100% !important;
    }

    .van-day-table th,
    .dashboard-table th {
        font-size: 11px !important;
        font-weight: 700 !important;
        padding: 10px 8px !important;
        background: #f5f5f5 !important;
        color: #000 !important;
        text-align: center !important;
        vertical-align: middle !important;
        border-bottom: 2px solid #333 !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .van-day-table td,
    .dashboard-table td {
        font-size: 10px !important;
        padding: 8px 6px !important;
        vertical-align: top !important;
        line-height: 1.5 !important;
        min-height: 50px !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .panel-xs {
        font-size: 9px !important;
        box-shadow: none !important;
        page-break-inside: avoid !important;
        margin-bottom: 5px !important;
        padding: 5px 7px !important;
        border-radius: 4px !important;
        line-height: 1.4 !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        width: 100% !important;
    }

    .panel-xs .panel-body {
        padding: 5px 7px !important;
        line-height: 1.4 !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .panel-xs * {
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Auto-shrink print content so Chrome scaling >100% still fits A3 */
    #vanDayTable,
    #calendar {
        width: 104% !important;
        transform: scale(0.96);
        transform-origin: top left;
    }

    .van-day-table th,
    .dashboard-table th,
    .van-day-table td,
    .dashboard-table td {
        min-width: 100px !important;
    }

    .panel-xs .fa,
    .panel-xs .glyphicon {
        font-size: 9px !important;
        margin-right: 4px !important;
    }

    .panel-xs strong {
        font-size: 10px !important;
        font-weight: 600 !important;
        display: block !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .panel-xs small {
        font-size: 8px !important;
        display: block !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    table,
    th,
    td {
        border: 1px solid #666 !important;
        border-collapse: collapse !important;
    }

    th,
    td {
        background: #fff !important;
        color: #000 !important;
    }

    .table {
        border: 1px solid #333 !important;
    }

    /* Migliora il contrasto per le celle non assegnate */
    .dashboard-cell-unassigned,
    .van-day-cell-unassigned,
    .droppable-cell-unassigned {
        background: #f5f5f5 !important;
        border-left: 3px solid #999 !important;
        color: #333 !important;
        font-weight: 500 !important;
    }

    /* Mantieni i colori alternati delle righe ma più leggibili */
    .van-day-table tr:nth-child(odd) td,
    .dashboard-table tr:nth-child(odd) td {
        background: #fafafa !important;
    }

    .van-day-table tr:nth-child(even) td,
    .dashboard-table tr:nth-child(even) td {
        background: #f0f0f0 !important;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    @page {
        size: A3 landscape;
        margin: 8mm;
    }

    /* Assicura che il calendario inizi immediatamente senza spazi vuoti */
    .container-fluid > .row:nth-child(2) {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    .container-fluid > .row:nth-child(2) > .col-md-10 {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
}


/* Ottimizzazioni stampa per tablet */

@media print and (min-width: 768px) and (max-width: 1024px) {
    body,
    html {
        height: auto !important;
        overflow: visible !important;
    }

    .container-fluid {
        height: auto !important;
        overflow: visible !important;
        max-height: none !important;
    }

    .calendar-scroll {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
    }

    #calendarScroll {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
    }

    #calendar,
    #vanDayTable {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .table {
        font-size: 16px !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .panel-xs {
        font-size: 14px !important;
    }

    @page {
        size: A4 landscape;
        margin: 5mm;
    }

    .table {
        font-size: 10px !important;
    }

    .van-day-table th,
    .dashboard-table th {
        font-size: 9px !important;
        padding: 6px 4px !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .van-day-table td,
    .dashboard-table td {
        font-size: 8px !important;
        padding: 5px 3px !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .panel-xs {
        font-size: 7px !important;
        padding: 3px 5px !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .panel-xs .panel-body {
        padding: 3px 5px !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .panel-xs * {
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
}

.mobile-content {
    padding-bottom: 20px;
}

.mobile-header {
    margin: 10px 0 20px 0;
}


/* --- MOBILE MODERNO --- */

.mobile-content {
    max-width: 420px;
    margin: 24px auto;
    padding: 18px 12px 70px 12px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

.mobile-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin: 10px 0 24px 0;
    font-size: 20px;
}

.mobile-header div {
    line-height: 1.3;
}

.logout-btn,
#logoutBtn {
    margin-left: 12px;
    font-size: 16px;
    padding: 7px 20px;
    border-radius: 22px;
    background: #e74c3c;
    color: #fff;
    border: none;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.08);
    transition: background 0.2s;
}

.logout-btn:hover,
#logoutBtn:hover {
    background: #c0392b;
}

.form-group label {
    font-size: 16px;
    margin-bottom: 4px;
    font-weight: 500;
}

.form-group label .glyphicon {
    margin-right: 4px;
    color: #666;
}

.form-control {
    font-size: 16px;
    padding: 10px 12px;
    margin-bottom: 14px;
    border-radius: 7px;
    border: 1px solid #dbe2ef;
    box-shadow: none;
}

#mobileLoadBtn {
    font-size: 17px;
    padding: 12px 0;
    border-radius: 7px;
    margin-bottom: 20px;
    background: #3578c6;
    color: #fff;
    border: none;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(53, 120, 198, 0.08);
    transition: background 0.2s;
}

#mobileLoadBtn:hover {
    background: #285a99;
}


/* Stili specifici per la tabella mobile */

.mobile-table {
    font-size: 14px;
    margin-bottom: 0;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.mobile-table th {
    background: #f5f5f5;
    font-weight: 600;
    text-align: center;
    font-size: 13px;
    padding: 8px 4px;
    border-bottom: 2px solid #e0e0e0;
    vertical-align: middle;
}

.mobile-table td {
    padding: 8px 4px;
    vertical-align: middle;
    font-size: 12px;
    line-height: 1.3;
    border: 1px solid #e0e0e0;
}

.mobile-table td small {
    font-size: 11px;
    color: #666;
    display: block;
    margin-top: 2px;
}

.mobile-table .btn-xs {
    padding: 2px 6px;
    font-size: 10px;
    margin: 1px;
}


/* Responsive per la tabella mobile */

@media (max-width: 400px) {
    .mobile-table {
        font-size: 12px;
    }

    .mobile-table th {
        font-size: 11px;
        padding: 6px 2px;
    }

    .mobile-table td {
        font-size: 10px;
        padding: 6px 2px;
    }

    .mobile-table .btn-xs {
        padding: 1px 4px;
        font-size: 9px;
    }

    .mobile-table td small {
        font-size: 9px;
    }
}


/* Ottimizzazioni per la tabella mobile su schermi molto piccoli */

@media (max-width: 350px) {
    .mobile-table {
        font-size: 11px;
    }

    .mobile-table th {
        font-size: 10px;
        padding: 4px 1px;
    }

    .mobile-table td {
        font-size: 9px;
        padding: 4px 1px;
    }

    .mobile-table .btn-xs {
        padding: 1px 3px;
        font-size: 8px;
    }

    .mobile-table td small {
        font-size: 8px;
    }
}

#mobileAssignments .panel {
    margin-bottom: 13px;
    border-radius: 7px;
    box-shadow: 0 2px 8px rgba(53, 120, 198, 0.06);
}

#mobileAssignments .panel .glyphicon {
    margin-right: 4px;
    color: #888;
}

.alert-info {
    font-size: 16px;
    padding: 13px 12px;
    border-radius: 7px;
    background: #e3f1fa;
    color: #3578c6;
    border: none;
}

@media (max-width: 400px) {
    .mobile-content {
        padding: 4px 2px 70px 2px;
    }

    .mobile-header {
        font-size: 15px;
    }

    .logout-btn,
    #logoutBtn {
        font-size: 14px;
        padding: 5px 12px;
    }

    .form-group label,
    .alert-info {
        font-size: 14px;
    }

    #mobileLoadBtn {
        font-size: 15px;
    }

    .mobile-content select.form-control {
        font-size: 15px;
        padding: 8px 8px;
    }

    .mobile-content select.form-control {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        /* Rimuovo le proprietà che causano il taglio del testo */
        /* text-overflow: ellipsis; */
        /* white-space: nowrap; */
        /* overflow: hidden; */
    }

    /* Assicura che la sidebar rimanga visibile anche su schermi molto piccoli */
    #sidebarCantieri {
        position: sticky;
        top: 5px;
        max-height: 80vh;
        overflow-y: auto;
    }
}

.mobile-content select.form-control {
    padding-right: 28px;
    /* lascia spazio per la freccia, ma non troppo */
}


/* Stili specifici per i modali mobile */

@media (max-width: 768px) {

    /* Modali ottimizzate per mobile */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
        width: auto;
    }

    .modal-content {
        border-radius: 8px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    .modal-header {
        padding: 15px;
        border-bottom: 1px solid #e5e5e5;
    }

    .modal-header h4 {
        font-size: 18px;
        margin: 0;
    }

    .modal-body {
        padding: 15px;
        max-height: 70vh;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 15px;
        border-top: 1px solid #e5e5e5;
    }

    /* Form controls ottimizzati per mobile */
    .modal .form-control {
        font-size: 16px;
        /* Previene zoom su iOS */
        padding: 12px;
        border-radius: 6px;
        border: 1px solid #ddd;
        margin-bottom: 15px;
    }

    .modal .form-control:focus {
        border-color: #007bff;
        box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    }

    /* Select ottimizzate per mobile */
    .modal select.form-control {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 16px;
        padding-right: 40px;
    }

    /* Bottoni ottimizzati per mobile */
    .modal .btn {
        padding: 12px 20px;
        font-size: 16px;
        border-radius: 6px;
        min-height: 44px;
        /* Area touch minima */
    }

    .modal .btn-xs {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 36px;
    }

    /* Assicura che i modali siano sempre visibili su mobile */
    .modal {
        z-index: 1050 !important;
    }

    .modal-backdrop {
        z-index: 1040 !important;
    }

    /* Migliora la leggibilità delle label */
    .modal label {
        font-size: 14px;
        font-weight: 500;
        margin-bottom: 5px;
        display: block;
    }

    /* Ottimizza le option nelle select */
    .modal select.form-control option {
        padding: 8px 12px;
        font-size: 16px;
    }
}


/* Stili specifici per schermi molto piccoli */

@media (max-width: 400px) {
    .modal-dialog {
        margin: 5px;
        max-width: calc(100% - 10px);
    }

    .modal-header {
        padding: 12px;
    }

    .modal-header h4 {
        font-size: 16px;
    }

    .modal-body {
        padding: 12px;
    }

    .modal-footer {
        padding: 12px;
    }

    .modal .form-control {
        font-size: 16px;
        padding: 10px;
    }

    .modal .btn {
        padding: 10px 16px;
        font-size: 15px;
    }
}


/* Stili specifici per la tabella settimanale mobile */

.mobile-weekly-table {
    font-size: 16px;
    margin-bottom: 0;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    min-width: 100vw;
    /* Ogni colonna occupa tutta la larghezza dello schermo */
}

.mobile-weekly-table th {
    background: #f5f5f5;
    font-weight: 600;
    text-align: center;
    font-size: 15px;
    padding: 10px 6px;
    border-bottom: 2px solid #e0e0e0;
    vertical-align: middle;
    white-space: nowrap;
    min-width: 100vw;
    /* Ogni colonna occupa tutta la larghezza dello schermo */
    width: 100vw;
}

.mobile-weekly-table td {
    padding: 8px 4px;
    vertical-align: top;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid #e0e0e0;
    min-width: 100vw;
    /* Ogni colonna occupa tutta la larghezza dello schermo */
    width: 100vw;
}

.mobile-weekly-table th:first-child {
    min-width: 120px;
    /* Colonna giorno/slot più stretta */
    width: 120px;
    text-align: left;
    padding-left: 8px;
}

.mobile-cell {
    background: #fafbfc;
    position: relative;
    min-height: 40px;
    width: 100vw;
}

.mobile-cell-unassigned {
    background: #ececec;
    border-left: 4px solid #bdbdbd;
    color: #444;
    font-weight: 500;
    position: relative;
    min-height: 40px;
    width: 100vw;
}

/* Spazio di manovra nei riquadri mobile: lascia sempre margine in fondo
   così è più semplice toccare per aggiungere un nuovo assegnamento */
@media (max-width: 768px) {
    .mobile-cell,
    .mobile-cell-unassigned {
        padding-bottom: 56px; /* più area libera in fondo allo slot */
        padding-top: 8px;
    }

    /* assicura un piccolo respiro anche dopo l'ultimo elemento */
    .mobile-assignment:last-child,
    .mobile-assignment-unassigned:last-child {
        margin-bottom: 10px;
    }

    /* spacer non interattivo in fondo alla cella per avere sempre area tappabile */
    .mobile-cell::after,
    .mobile-cell-unassigned::after {
        content: "";
        display: block;
        height: 36px;
        pointer-events: none;
    }
}

.mobile-assignment {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 4px;
    padding: 6px;
    margin: 3px 0;
    font-size: 12px;
    line-height: 1.3;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-assignment:hover {
    background: #bbdefb;
    border-color: #1976d2;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.2);
}

.mobile-assignment-unassigned {
    background: #fffde7;
    border: 1px solid #ff9800;
    border-radius: 4px;
    padding: 6px;
    margin: 3px 0;
    font-size: 12px;
    line-height: 1.3;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-assignment-unassigned:hover {
    background: #fff8e1;
    border-color: #f57c00;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(255, 152, 0, 0.2);
}

.mobile-assignment strong,
.mobile-assignment-unassigned strong {
    font-size: 14px;
    color: #333;
    display: block;
    margin-bottom: 3px;
}

.mobile-assignment small,
.mobile-assignment-unassigned small {
    font-size: 11px;
    color: #666;
    display: block;
    line-height: 1.2;
}

.mobile-del-asg {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 16px;
    height: 16px;
    padding: 0;
    font-size: 10px;
    line-height: 1;
    border-radius: 50%;
    background: #d9534f;
    border: 1px solid #d43f3a;
    color: white;
    z-index: 10;
}

.mobile-del-asg:hover {
    background: #c9302c;
    transform: scale(1.1);
}


/* Navigazione settimanale mobile */

.week-nav-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
    background: #f5f5f5;
    padding: 8px;
    border-radius: 6px;
}

.week-nav-mobile button {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
}

.week-nav-mobile span {
    font-size: 14px;
    font-weight: bold;
    margin: 0 10px;
}


/* Responsive per la tabella settimanale mobile */

@media (max-width: 600px) {
    .mobile-weekly-table {
        font-size: 10px;
        min-width: 100vw;
    }

    .mobile-weekly-table th {
        font-size: 9px;
        padding: 4px 2px;
        min-width: 100vw;
        width: 100vw;
    }

    .mobile-weekly-table td {
        font-size: 8px;
        padding: 3px 1px;
        min-width: 100vw;
        width: 100vw;
    }

    .mobile-weekly-table th:first-child {
        min-width: 100px;
        width: 100px;
    }

    .mobile-assignment,
    .mobile-assignment-unassigned {
        font-size: 8px;
        padding: 3px;
    }

    .mobile-assignment strong,
    .mobile-assignment-unassigned strong {
        font-size: 9px;
    }

    .mobile-assignment small,
    .mobile-assignment-unassigned small {
        font-size: 7px;
    }

    .mobile-del-asg {
        width: 14px;
        height: 14px;
        font-size: 8px;
    }
}

@media (max-width: 400px) {
    .mobile-weekly-table {
        font-size: 9px;
        min-width: 100vw;
    }

    .mobile-weekly-table th {
        font-size: 8px;
        padding: 3px 1px;
        min-width: 100vw;
        width: 100vw;
    }

    .mobile-weekly-table td {
        font-size: 7px;
        padding: 2px 1px;
        min-width: 100vw;
        width: 100vw;
    }

    .mobile-weekly-table th:first-child {
        min-width: 80px;
        width: 80px;
    }

    .mobile-assignment,
    .mobile-assignment-unassigned {
        font-size: 7px;
        padding: 2px;
    }

    .mobile-assignment strong,
    .mobile-assignment-unassigned strong {
        font-size: 8px;
    }

    .mobile-assignment small,
    .mobile-assignment-unassigned small {
        font-size: 6px;
    }

    .mobile-del-asg {
        width: 12px;
        height: 12px;
        font-size: 7px;
    }
}


/* Scroll orizzontale per la tabella */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    width: 100%;
}


/* Stili per celle cliccabili mobile */

.clickable-cell {
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
}

.clickable-cell:hover {
    background-color: #e8f5e9 !important;
    border-color: #4caf50 !important;
    box-shadow: inset 0 0 0 2px rgba(76, 175, 80, 0.2) !important;
}

.clickable-cell:active {
    background-color: #c8e6c9 !important;
    transform: scale(0.98);
}


/* Stili specifici per la tabella settimanale mobile */

.mobile-weekly-table {
    font-size: 12px;
    margin-bottom: 0;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    min-width: 100vw;
    /* Ogni colonna occupa tutta la larghezza dello schermo */
}

.mobile-weekly-table th {
    background: #f5f5f5;
    font-weight: 600;
    text-align: center;
    font-size: 11px;
    padding: 6px 3px;
    border-bottom: 2px solid #e0e0e0;
    vertical-align: middle;
    white-space: nowrap;
    min-width: 100vw;
    /* Ogni colonna occupa tutta la larghezza dello schermo */
    width: 100vw;
}

.mobile-weekly-table td {
    padding: 4px 2px;
    vertical-align: top;
    font-size: 10px;
    line-height: 1.2;
    border: 1px solid #e0e0e0;
    min-width: 100vw;
    /* Ogni colonna occupa tutta la larghezza dello schermo */
    width: 100vw;
}

.mobile-weekly-table th:first-child {
    min-width: 120px;
    /* Colonna giorno/slot più stretta */
    width: 120px;
    text-align: left;
    padding-left: 8px;
}

.mobile-cell {
    background: #fafbfc;
    position: relative;
    min-height: 40px;
    width: 100vw;
}

.mobile-cell-unassigned {
    background: #ececec;
    border-left: 4px solid #bdbdbd;
    color: #444;
    font-weight: 500;
    position: relative;
    min-height: 40px;
    width: 100vw;
}

.mobile-assignment {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 4px;
    padding: 4px;
    margin: 2px 0;
    font-size: 9px;
    line-height: 1.2;
    position: relative;
}

.mobile-assignment-unassigned {
    background: #fffde7;
    border: 1px solid #ff9800;
    border-radius: 4px;
    padding: 4px;
    margin: 2px 0;
    font-size: 9px;
    line-height: 1.2;
    position: relative;
}

.mobile-assignment strong,
.mobile-assignment-unassigned strong {
    font-size: 10px;
    color: #333;
    display: block;
    margin-bottom: 2px;
}

.mobile-assignment small,
.mobile-assignment-unassigned small {
    font-size: 8px;
    color: #666;
    display: block;
    line-height: 1.1;
}

.mobile-del-asg {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 16px;
    height: 16px;
    padding: 0;
    font-size: 10px;
    line-height: 1;
    border-radius: 50%;
    background: #d9534f;
    border: 1px solid #d43f3a;
    color: white;
    z-index: 10;
}

.mobile-del-asg:hover {
    background: #c9302c;
    transform: scale(1.1);
}


/* Navigazione settimanale mobile */

.week-nav-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
    background: #f5f5f5;
    padding: 8px;
    border-radius: 6px;
}

.week-nav-mobile button {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
}

.week-nav-mobile span {
    font-size: 14px;
    font-weight: bold;
    margin: 0 10px;
}


/* Responsive per la tabella settimanale mobile */

@media (max-width: 600px) {
    .mobile-weekly-table {
        font-size: 10px;
        min-width: 100vw;
    }

    .mobile-weekly-table th {
        font-size: 9px;
        padding: 4px 2px;
        min-width: 100vw;
        width: 100vw;
    }

    .mobile-weekly-table td {
        font-size: 8px;
        padding: 3px 1px;
        min-width: 100vw;
        width: 100vw;
    }

    .mobile-weekly-table th:first-child {
        min-width: 100px;
        width: 100px;
    }

    .mobile-assignment,
    .mobile-assignment-unassigned {
        font-size: 8px;
        padding: 3px;
    }

    .mobile-assignment strong,
    .mobile-assignment-unassigned strong {
        font-size: 9px;
    }

    .mobile-assignment small,
    .mobile-assignment-unassigned small {
        font-size: 7px;
    }

    .mobile-del-asg {
        width: 14px;
        height: 14px;
        font-size: 8px;
    }
}

@media (max-width: 400px) {
    .mobile-weekly-table {
        font-size: 9px;
        min-width: 100vw;
    }

    .mobile-weekly-table th {
        font-size: 8px;
        padding: 3px 1px;
        min-width: 100vw;
        width: 100vw;
    }

    .mobile-weekly-table td {
        font-size: 7px;
        padding: 2px 1px;
        min-width: 100vw;
        width: 100vw;
    }

    .mobile-weekly-table th:first-child {
        min-width: 80px;
        width: 80px;
    }

    .mobile-assignment,
    .mobile-assignment-unassigned {
        font-size: 7px;
        padding: 2px;
    }

    .mobile-assignment strong,
    .mobile-assignment-unassigned strong {
        font-size: 8px;
    }

    .mobile-assignment small,
    .mobile-assignment-unassigned small {
        font-size: 6px;
    }

    .mobile-del-asg {
        width: 12px;
        height: 12px;
        font-size: 7px;
    }
}


/* Scroll orizzontale per la tabella */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    width: 100%;
}


/* Stili per il login - centrato su tutti i dispositivi */

body.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f5f6fa;
    padding: 20px;
    margin: 0;
    box-sizing: border-box;
}

.login-header {
    width: 100%;
    text-align: center;
    position: relative;
    background: transparent;
    padding: 0 0 20px 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 20px;
    color: #333;
}

.login-container {
    background: #fff;
    width: 100%;
    max-width: 400px;
    padding: 40px 30px 30px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto;
    box-sizing: border-box;
}

.login-container h2 {
    margin-bottom: 30px;
    color: #333;
    font-weight: 600;
}

.login-container form {
    width: 100%;
}

.login-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.login-container input[type="text"],
.login-container input[type="password"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 20px;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
}

.login-container input[type="text"]:focus,
.login-container input[type="password"]:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.login-container input[type="submit"] {
    width: 100%;
    padding: 12px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.login-container input[type="submit"]:hover {
    background: #0056b3;
}

.login-container input[type="submit"]:active {
    transform: translateY(1px);
}


/* Responsive per schermi piccoli */

@media (max-width: 480px) {
    body.login-page {
        padding: 15px;
    }

    .login-header {
        font-size: 20px;
        padding: 0 0 15px 0;
        margin-bottom: 15px;
    }

    .login-container {
        padding: 30px 20px 25px 20px;
        max-width: 100%;
    }

    .login-container h2 {
        font-size: 20px;
        margin-bottom: 25px;
    }

    .login-container input[type="text"],
    .login-container input[type="password"] {
        font-size: 16px;
        padding: 10px 12px;
        margin-bottom: 15px;
    }

    .login-container input[type="submit"] {
        font-size: 16px;
        padding: 12px;
    }
}


/* Aumento dimensioni font per mobile */

@media (max-width: 768px) {
    .mobile-weekly-table {
        font-size: 16px !important;
    }

    .mobile-weekly-table th {
        font-size: 15px !important;
        padding: 10px 6px !important;
    }

    .mobile-weekly-table td {
        font-size: 14px !important;
        padding: 8px 4px !important;
        line-height: 1.4 !important;
    }

    .mobile-assignment,
    .mobile-assignment-unassigned {
        font-size: 12px !important;
        padding: 6px !important;
        margin: 3px 0 !important;
        line-height: 1.3 !important;
    }

    .mobile-assignment strong,
    .mobile-assignment-unassigned strong {
        font-size: 14px !important;
        margin-bottom: 3px !important;
    }

    .mobile-assignment small,
    .mobile-assignment-unassigned small {
        font-size: 11px !important;
        line-height: 1.2 !important;
    }

    .mobile-header {
        font-size: 20px !important;
    }

    .mobile-header div {
        line-height: 1.3 !important;
    }

    .week-nav-mobile span {
        font-size: 16px !important;
    }

    .mobile-del-asg {
        width: 18px !important;
        height: 18px !important;
        font-size: 12px !important;
    }
}


/* Fix per modali mobile - select tagliate */

@media (max-width: 768px) {
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
        width: auto;
        max-height: 90vh;
    }

    .modal-content {
        border-radius: 8px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        max-height: 90vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .modal-header {
        padding: 15px;
        border-bottom: 1px solid #e5e5e5;
        flex-shrink: 0;
    }

    .modal-header h4 {
        font-size: 18px;
        margin: 0;
    }

    .modal-body {
        padding: 15px;
        overflow-y: auto;
        flex: 1;
        min-height: 0;
    }

    .modal-footer {
        padding: 15px;
        border-top: 1px solid #e5e5e5;
        flex-shrink: 0;
    }

    /* Form controls ottimizzati per mobile */
    .modal .form-control {
        font-size: 16px;
        /* Previene zoom su iOS */
        padding: 12px;
        border-radius: 6px;
        border: 1px solid #ddd;
        margin-bottom: 15px;
        width: 100%;
        box-sizing: border-box;
    }

    .modal .form-control:focus {
        border-color: #007bff;
        box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    }

    /* Select ottimizzate per mobile */
    .modal select.form-control {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 16px;
        padding: 18px 40px 18px 12px;
        min-height: 56px;
        line-height: 1.6;
    }

    /* Assicura che le select multiple siano visibili */
    .modal select[multiple].form-control {
        min-height: 120px;
        max-height: 200px;
        overflow-y: auto;
    }

    /* Bottoni ottimizzati per mobile */
    .modal .btn {
        padding: 12px 20px;
        font-size: 16px;
        border-radius: 6px;
        min-height: 44px;
        /* Area touch minima */
    }

    .modal .btn-xs {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 36px;
    }

    /* Assicura che i modali siano sempre visibili su mobile */
    .modal {
        z-index: 1050 !important;
    }

    .modal-backdrop {
        z-index: 1040 !important;
    }

    /* Migliora la leggibilità delle label */
    .modal label {
        font-size: 14px;
        font-weight: 500;
        margin-bottom: 5px;
        display: block;
    }

    /* Ottimizza le option nelle select */
    .modal select.form-control option {
        padding: 8px 12px;
        font-size: 16px;
    }

    /* Assicura che i form-group abbiano spazio sufficiente */
    .modal .form-group {
        margin-bottom: 20px;
    }

    /* Fix per select che potrebbero essere tagliate */
    .modal .form-group:last-child {
        margin-bottom: 0;
    }
}


/* Fix specifici per Samsung One UI e dispositivi Samsung */

@media (max-width: 768px) {

    /* Fix per Samsung One UI - select tagliate */
    .modal select.form-control {
        /* Rimuovi proprietà che causano taglio su Samsung */
        text-overflow: initial !important;
        white-space: normal !important;
        overflow: visible !important;
        /* Aumenta padding per evitare taglio */
        padding: 20px 50px 20px 15px !important;
        min-height: 60px !important;
        /* Assicura che il testo sia completamente visibile */
        line-height: 1.8 !important;
        /* Fix per Samsung One UI */
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        /* Previene problemi di rendering su Samsung */
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
    }

    /* Fix specifico per Samsung A54 e dispositivi simili */
    @media screen and (-webkit-min-device-pixel-ratio: 2) and (max-width: 768px) {
        .modal select.form-control {
            /* Aumenta ulteriormente il padding per schermi ad alta densità */
            padding: 22px 55px 22px 18px !important;
            min-height: 65px !important;
            font-size: 17px !important;
            /* Assicura che il testo non venga tagliato */
            text-overflow: clip !important;
            white-space: normal !important;
            overflow: visible !important;
            /* Fix per rendering Samsung */
            -webkit-transform: translate3d(0, 0, 0) !important;
            transform: translate3d(0, 0, 0) !important;
        }

        /* Fix per select multiple su Samsung */
        .modal select[multiple].form-control {
            min-height: 140px !important;
            max-height: 220px !important;
            padding: 15px !important;
        }

        /* Fix per option su Samsung */
        .modal select.form-control option {
            padding: 12px 15px !important;
            font-size: 17px !important;
            line-height: 1.6 !important;
            /* Assicura che le option siano completamente visibili */
            white-space: normal !important;
            word-wrap: break-word !important;
        }
    }

    /* Fix per Samsung con One UI 4+ */
    @media screen and (-webkit-min-device-pixel-ratio: 2) and (max-width: 768px) {
        .modal select.form-control {
            /* Rimuovi completamente le proprietà che causano taglio */
            text-overflow: initial !important;
            white-space: normal !important;
            overflow: visible !important;
            /* Aumenta significativamente il padding */
            padding: 25px 60px 25px 20px !important;
            min-height: 70px !important;
            font-size: 18px !important;
            /* Fix per Samsung One UI */
            -webkit-appearance: none !important;
            -moz-appearance: none !important;
            appearance: none !important;
            /* Assicura che il background della freccia sia visibile */
            background-position: right 15px center !important;
            background-size: 20px !important;
        }

        /* Fix per select multiple su Samsung One UI */
        .modal select[multiple].form-control {
            min-height: 160px !important;
            max-height: 240px !important;
            padding: 20px !important;
            /* Assicura che il contenuto sia completamente visibile */
            overflow-y: auto !important;
            overflow-x: hidden !important;
        }

        /* Fix per option su Samsung One UI */
        .modal select.form-control option {
            padding: 15px 20px !important;
            font-size: 18px !important;
            line-height: 1.7 !important;
            /* Rimuovi qualsiasi limitazione di testo */
            white-space: normal !important;
            word-wrap: break-word !important;
            text-overflow: initial !important;
            overflow: visible !important;
        }
    }

    /* Fix per Samsung con schermi molto piccoli */
    @media screen and (max-width: 400px) and (-webkit-min-device-pixel-ratio: 2) {
        .modal select.form-control {
            /* Riduci leggermente il padding per schermi piccoli ma mantieni visibilità */
            padding: 20px 50px 20px 15px !important;
            min-height: 60px !important;
            font-size: 16px !important;
        }

        .modal select[multiple].form-control {
            min-height: 140px !important;
            max-height: 200px !important;
            padding: 15px !important;
        }

        .modal select.form-control option {
            padding: 12px 15px !important;
            font-size: 16px !important;
        }
    }
}


/* Fix aggiuntivi per Samsung One UI - problemi di rendering */

@media (max-width: 768px) {

    /* Fix per problemi di rendering su Samsung */
    .modal select.form-control {
        /* Forza il rendering corretto su Samsung */
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
        /* Assicura che il contenuto sia sempre visibile */
        text-overflow: initial !important;
        white-space: normal !important;
        overflow: visible !important;
        /* Rimuovi qualsiasi limitazione di altezza che potrebbe causare taglio */
        max-height: none !important;
        height: auto !important;
    }

    /* Fix per container delle select su Samsung */
    .modal .form-group {
        /* Assicura che il container non limiti la visibilità */
        overflow: visible !important;
        max-height: none !important;
        height: auto !important;
    }

    /* Fix per modal body su Samsung */
    .modal-body {
        /* Assicura che il modal body non limiti la visibilità delle select */
        overflow-y: auto !important;
        overflow-x: visible !important;
        /* Aumenta il padding per dare più spazio */
        padding: 20px !important;
    }

    /* Fix per modal content su Samsung */
    .modal-content {
        /* Assicura che il modal content non limiti la visibilità */
        overflow: visible !important;
        max-height: none !important;
        height: auto !important;
    }
}


/* Fix specifici per Samsung One UI 5+ e dispositivi Samsung moderni */

@media (max-width: 768px) {

    /* Fix per Samsung One UI 5+ */
    .modal select.form-control {
        /* Rimuovi completamente le proprietà che causano taglio su Samsung */
        text-overflow: initial !important;
        white-space: normal !important;
        overflow: visible !important;
        /* Aumenta significativamente il padding per Samsung */
        padding: 25px 65px 25px 20px !important;
        min-height: 75px !important;
        font-size: 18px !important;
        line-height: 2.0 !important;
        /* Fix per Samsung One UI */
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        /* Assicura che il background della freccia sia visibile */
        background-position: right 20px center !important;
        background-size: 22px !important;
        /* Fix per rendering Samsung */
        -webkit-transform: translate3d(0, 0, 0) !important;
        transform: translate3d(0, 0, 0) !important;
        /* Previene problemi di rendering su Samsung */
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
        /* Assicura che il contenuto sia sempre visibile */
        max-height: none !important;
        height: auto !important;
        /* Rimuovi qualsiasi limitazione di larghezza */
        max-width: none !important;
        width: 100% !important;
    }

    /* Fix per select multiple su Samsung One UI 5+ */
    .modal select[multiple].form-control {
        min-height: 180px !important;
        max-height: 260px !important;
        padding: 25px !important;
        /* Assicura che il contenuto sia completamente visibile */
        overflow-y: auto !important;
        overflow-x: hidden !important;
        /* Fix per Samsung */
        -webkit-transform: translate3d(0, 0, 0) !important;
        transform: translate3d(0, 0, 0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
    }

    /* Fix per option su Samsung One UI 5+ */
    .modal select.form-control option {
        padding: 18px 25px !important;
        font-size: 18px !important;
        line-height: 1.8 !important;
        /* Rimuovi qualsiasi limitazione di testo */
        white-space: normal !important;
        word-wrap: break-word !important;
        text-overflow: initial !important;
        overflow: visible !important;
        /* Fix per Samsung */
        -webkit-transform: translate3d(0, 0, 0) !important;
        transform: translate3d(0, 0, 0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
    }

    /* Fix per container delle select su Samsung One UI 5+ */
    .modal .form-group {
        /* Assicura che il container non limiti la visibilità */
        overflow: visible !important;
        max-height: none !important;
        height: auto !important;
        /* Aumenta il margin per dare più spazio */
        margin-bottom: 25px !important;
    }

    /* Fix per modal body su Samsung One UI 5+ */
    .modal-body {
        /* Assicura che il modal body non limiti la visibilità delle select */
        overflow-y: auto !important;
        overflow-x: visible !important;
        /* Aumenta il padding per dare più spazio */
        padding: 25px !important;
        /* Assicura che il contenuto sia sempre visibile */
        max-height: none !important;
        height: auto !important;
    }

    /* Fix per modal content su Samsung One UI 5+ */
    .modal-content {
        /* Assicura che il modal content non limiti la visibilità */
        overflow: visible !important;
        max-height: none !important;
        height: auto !important;
        /* Aumenta il padding per dare più spazio */
        padding: 0 !important;
    }

    /* Fix per modal dialog su Samsung One UI 5+ */
    .modal-dialog {
        /* Assicura che il modal dialog non limiti la visibilità */
        max-height: none !important;
        height: auto !important;
        /* Aumenta il margin per dare più spazio */
        margin: 15px !important;
        max-width: calc(100% - 30px) !important;
    }
}


/* Fix per Samsung con schermi molto piccoli ma ad alta densità */

@media screen and (max-width: 400px) and (-webkit-min-device-pixel-ratio: 2) {
    .modal select.form-control {
        /* Riduci leggermente il padding per schermi piccoli ma mantieni visibilità */
        padding: 22px 55px 22px 18px !important;
        min-height: 65px !important;
        font-size: 17px !important;
        line-height: 1.8 !important;
        /* Mantieni tutti i fix per Samsung */
        text-overflow: initial !important;
        white-space: normal !important;
        overflow: visible !important;
        -webkit-transform: translate3d(0, 0, 0) !important;
        transform: translate3d(0, 0, 0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
    }

    .modal select[multiple].form-control {
        min-height: 160px !important;
        max-height: 220px !important;
        padding: 20px !important;
    }

    .modal select.form-control option {
        padding: 15px 20px !important;
        font-size: 17px !important;
        line-height: 1.7 !important;
    }
}


/* Fix per Samsung con One UI 6+ (se necessario) */

@media (max-width: 768px) {

    /* Fix per Samsung One UI 6+ */
    .modal select.form-control {
        /* Assicura che le select siano sempre completamente visibili su Samsung */
        text-overflow: initial !important;
        white-space: normal !important;
        overflow: visible !important;
        /* Aumenta ulteriormente il padding per Samsung One UI 6+ */
        padding: 28px 70px 28px 25px !important;
        min-height: 80px !important;
        font-size: 19px !important;
        line-height: 2.2 !important;
        /* Fix per Samsung One UI 6+ */
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        /* Assicura che il background della freccia sia visibile */
        background-position: right 25px center !important;
        background-size: 24px !important;
        /* Fix per rendering Samsung One UI 6+ */
        -webkit-transform: translate3d(0, 0, 0) !important;
        transform: translate3d(0, 0, 0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
        /* Assicura che il contenuto sia sempre visibile */
        max-height: none !important;
        height: auto !important;
        max-width: none !important;
        width: 100% !important;
    }
}

@media screen and (min-width: 768px) and (max-width: 1024px) and (-webkit-min-device-pixel-ratio: 2) {
    .modal select.form-control {
        font-size: 17px !important;
        line-height: 1.8 !important;
        padding: 22px 60px 22px 20px !important;
        min-height: 65px !important;
        /* Evita taglio del testo */
        text-overflow: initial !important;
        white-space: normal !important;
        overflow: visible !important;
        /* Fix per rendering Samsung */
        -webkit-transform: translate3d(0, 0, 0) !important;
        transform: translate3d(0, 0, 0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
        /* Rimuove limitazioni di altezza */
        height: auto !important;
        max-height: none !important;
        width: 100% !important;
        /* Freccia dropdown corretta */
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        background-position: right 20px center !important;
        background-size: 18px !important;
    }

    .modal select.form-control {
        padding: 18px !important;
        min-height: 150px !important;
        max-height: 220px !important;
        overflow-y: auto !important;
    }

    .modal select.form-control option {
        font-size: 16px !important;
        padding: 12px 15px !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        line-height: 1.5 !important;
    }
}

.btn-warning {
    color: #fff;
    background-color: #dd6832 !important;
    border-color: #dd6832 !important;
}

/* Il wrapper deve scrollare in entrambe le direzioni ed essere il contesto sticky */
#mobileWeeklyTable .table-responsive {
  overflow: auto !important;      /* x + y */
  max-height: 72vh;               /* regola a piacere */
  position: relative !important;  /* contesto per sticky */
  isolation: isolate;             /* z-index più affidabile */
  -webkit-overflow-scrolling: touch;
}

/* La tabella NON deve usare 100vw per le celle */
.mobile-weekly-table {
  border-collapse: separate !important;  /* sticky + tabelle */
  border-spacing: 0;
  table-layout: fixed;                    /* larghezze prevedibili */
  width: max-content;                     /* fa crescere la tabella in orizzontale */
  overflow: visible !important;           /* evita clipping di sticky */
}

/* Larghezze “normali” alle colonne (niente 100vw) */
.mobile-weekly-table th,
.mobile-weekly-table td {
  width: auto !important;
  min-width: 220px;            /* quanto vuoi vedere per colonna */
  white-space: normal;         /* lasciamo andare a capo */
}

/* Prima colonna più stretta */
.mobile-weekly-table th:first-child {
  min-width: 140px !important;
}

/* Header bloccato in alto (una sola definizione pulita) */
.mobile-weekly-table thead th {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 5;                  /* sopra le celle normali */
  background: #f5f5f5;
  will-change: top;
  transform: translateZ(0);    /* migliora Safari/iOS */
}

/* Prima colonna bloccata a sinistra */
.mobile-weekly-table th:first-child {
  position: -webkit-sticky;
  position: sticky;
  left: 0;
  z-index: 4;                  /* sotto l’header ma sopra le altre */
  background: #fff;
  will-change: left;
  transform: translateZ(0);
}

/* Cella (0,0) sopra a tutto */
.mobile-weekly-table thead th:first-child {
  z-index: 6;
}

/* Prima colonna SEMPRE sopra ai contenuti delle altre colonne */
.mobile-weekly-table th:first-child {
  z-index: 50 !important;   /* > 10 della X */
}

/* Cella (0,0) ancora sopra all'intera colonna */
.mobile-weekly-table thead th:first-child {
  z-index: 60 !important;
}

/* Header delle altre colonne sopra alle celle normali */
.mobile-weekly-table thead th {
  z-index: 40 !important;
}

/* La X non deve superare la colonna sticky */
.mobile-del-asg {
  z-index: 15 !important;   /* resta sopra al contenuto della propria cella, ma sotto la colonna sticky */
}

/* MOBILE: prima riga + prima colonna sticky, X sotto */
@media (max-width: 768px) {

    /* PRIMA: th:first-child, td:first-child */
    .mobile-weekly-table th:first-child {
        min-width: 140px !important;
    }

    /* PRIMA: th:first-child, td:first-child */
    .mobile-weekly-table th:first-child {
        position: sticky;
        left: 0;
        z-index: 4;
        background: #fff;
    }
    /* Cella d’angolo (0,0) sopra a tutto */
    .mobile-weekly-table thead th:first-child {
        z-index: 60 !important;
    }

    /* La X resta sotto gli elementi sticky */
    .mobile-del-asg {
        z-index: 20 !important;     /* < 40/50/60 */
    }
}