:root {
    --app-nav-h: 45px;
    --z-navbar: 1030;
    --z-modal: 2005;
    --z-backdrop: 2000;
}

/* Z-index modali sopra navbar */
.navbar {
    z-index: var(--z-navbar);
}

.modal {
    z-index: var(--z-modal);
}

.modal-backdrop {
    z-index: var(--z-backdrop);
}

/* Struttura base modale */
.modal-content {
    border: 0;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, .18);
}

.modal-header {
    background: linear-gradient(180deg, #eef4ff 0%, #dce9ff 100%);
    border-bottom: 1px solid #d3e2ff;
    padding: 1rem 1rem;
    cursor: move;
    user-select: none;
    position: static !important;
    top: auto !important;
}

.modal-title {
    font-weight: 700;
    color: #1f3b6d;
}

.modal-body .form-label {
    font-size: .85rem;
    font-weight: 600;
    color: #5c667a;
    margin-bottom: .35rem;
}

.modal-body .form-control,
.modal-body .form-select {
    border-radius: 10px;
    border: 1px solid #d8dee9;
    min-height: 42px;
}

.modal-body .form-control:focus,
.modal-body .form-select:focus {
    border-color: #6ea8fe;
    box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .15);
}

.modal-footer {
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
    padding: .9rem 1.2rem;
}

/* Eventuali sezioni interne */
.modal-section {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.modal-section-title {
    font-weight: 700;
    color: #334155;
    margin-bottom: .75rem;
}

/* Animazione modale */
.modal-dialog {
    transition: transform .2s ease-out;
}

.modal.fade .modal-dialog {
    transform: translateY(-20px);
}

.modal.show .modal-dialog {
    transform: translateY(0);
}

/* Scroll interno modali Bootstrap */
.modal-dialog.modal-dialog-scrollable .modal-content {
    max-height: calc(100vh - var(--bs-modal-margin) * 2);
}

/*
.modal-dialog.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
    height: 45dvh;
}
*/

.modal-body[data-enforce-scroll] {
    overflow-y: auto !important;
}





/* Mobile: lascia spazio sotto navbar per le modali normali */
@media (max-width: 576px) {
  #modal .modal-dialog {
        margin: 0;
        max-width: none;
       
    }

.modal-dialog.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
    height: 45dvh;
}

    #modal.modal.show .modal-dialog {
        margin-top: 0;
        }

    #modal .modal-content {
       
        display: flex;
        flex-direction: column;
    }

    #modal .modal-header {
        flex: 0 0 auto;
    }

    #modal .modal-body {
        flex: 1 1 auto;
        overflow-y: auto;
    }

    #modal .modal-footer {
        flex: 0 0 auto;
        position: sticky;
        bottom: 0;
        background: #fff;
        z-index: 10;
    }
}

/* Mobile: ottimizzazione specifica modale Nuovo/Modifica Ginnasta */
@media (max-width: 768px) {
.modal-dialog.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
    height: 45dvh;
}

    #modal .modal-dialog {
        margin: 0;
        max-width: none;
      
    }

    #modal .modal-content {
       
        display: flex;
        flex-direction: column;
    }

    #modal .modal-header {
        flex: 0 0 auto;
    }

    #modal .modal-body {
        flex: 1 1 auto;
        overflow-y: auto;
    }

    #modal .modal-footer {
        flex: 0 0 auto;
        position: sticky;
        bottom: 0;
        background: #fff;
        z-index: 10;
    }

}