body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #ffffff !important; /* Sfondo bianco */
    color: black;
}

header, .navbar, .offcanvas, .content {
    background-color: #ffffff !important; /* Sfondo bianco */
}

.header {
    color: #b21917;
    background-color: #ffffff;
    padding: 10px;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header b {
    font-size: 22px;
    font-weight: bold;
    margin: 0;
    line-height: 1;
}

.header img {
    width: 30px;
    margin-right: 10px;
}

.nav {
    background-color: #b21917;
    color: #ffffff;
    padding: 10px 0;
    text-align: left;
}

.nav a {
    color: #ffffff;
    padding: 0 15px;
    text-decoration: none;
}

.nav a:hover {
    text-decoration: underline;
}

.content {
    padding: 20px;
}

.footer {
    background-color: #333;
    color: #ffffff;
    text-align: center;
    padding: 10px 0;
    margin-top: 4rem;
}

/* Stile per il link di accesso a Django Admin */
.admin-link {
    color: #555555; /* Grigio scuro */
    font-weight: bold;
    text-decoration: none;
}

.admin-link:hover {
    text-decoration: underline;
}

.navbar-light.bg-light {
    background-color: #ffffff !important; /* Rimuove il grigio di Bootstrap */
    border-bottom: 1px solid #ddd; /* Opzionale, linea divisoria sottile */
}

/* Evita che il colore cambi per i link visitati */
.admin-link:visited {
    color: #555555; /* Grigio scuro, identico al colore del link non visitato */
}

.submenu {
    background-color: #f5f5f5; /* Sotto-menu chiaro */
    border-bottom: 2px solid #b22222; /* Linea divisoria */
    padding: 10px;
    display: flex;
    gap: 15px;
}
.submenu a {
    color: #333;
    text-decoration: none;
    font-size: 0.9rem;
}
.submenu a:hover {
    color: #b22222;
    text-decoration: underline;
}

/* Stili per sotto-menu dropdown multi-livello */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu .dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -1px;
    margin-left: -1px;
    z-index: 10000 !important; /* Submenu ancora più in alto */
}

/* Freccia per indicare sotto-menu */
.dropdown-submenu > .dropdown-toggle:after {
    display: block;
    content: "";
    float: right;
    width: 0;
    height: 0;
    border-color: transparent;
    border-style: solid;
    border-width: 5px 0 5px 5px;
    border-left-color: #666;
    margin-top: 5px;
    margin-right: -10px;
}

.dropdown-submenu:hover .dropdown-menu {
    display: block;
}

/* Miglioramenti per il menu PM Control */
.dropdown-menu .dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
}

.dropdown-menu .dropdown-item:hover {
    background-color: #f8f9fa;
    color: #b21917;
}

.dropdown-divider {
    margin: 0.5rem 0;
}

.toast-container .toast {
    margin-bottom: 0.2rem;
}
.toast-container {
    max-height: 50vh;
    max-width: 30vw;
}
.offcanvas-body, .offcanvas-header {
    background-color: #ffffff !important; /* Sfondo bianco */
}


/* Stile base del pulsante */
.btn-custom {
    background-color: #b21917 !important; /* Rosso */
    border: none;
    transition: background-color 0.3s, color 0.3s; /* Transizione fluida */
}

/* Stile dell'icona */
.btn-custom .navbar-toggler-icon {
    background-image: none; /* Rimuove l'icona di Bootstrap */
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    background-color: white; /* Colore delle linee */
    mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><path stroke="currentColor" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"/></svg>') no-repeat center;
    -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><path stroke="currentColor" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"/></svg>') no-repeat center;
}

/* Effetto hover: inversione dei colori */
.btn-custom:hover {
    background-color: white !important; /* Sfondo bianco */
}

.btn-custom:hover .navbar-toggler-icon {
    background-color: #b21917 !important; /* Linee rosse */
    transition: background-color 0.3s; /* Transizione fluida */
}


/* Stile Offcanvas (menu a scomparsa) */
.offcanvas-header, .offcanvas-body {
    background-color: #ffffff; /* Sfondo bianco */
    color: #b21917; /* Rosso per i testi principali */
    font-family: 'Arial', sans-serif; /* Font coerente */
}

/* Titolo Offcanvas */
.offcanvas-title {
    color: #b21917;
    font-size: 22px;
    font-weight: bold;
}

/* Pulsante di chiusura (X) */
.btn-close {
    color: #b21917 !important; /* Rosso scuro */
    opacity: 1; /* Massima visibilità */
}

/* Link del menu */
.nav-link {
    color: #333; /* Grigio scuro per i link */
    font-weight: 600;
    transition: color 0.3s ease-in-out;
}

.nav-link:hover, .nav-link:focus {
    color: #b21917; /* Rosso all'hover */
    text-decoration: underline;
}

/* Divider nel menu */
hr.divider {
    border: none;
    border-top: 2px solid #b21917; /* Linea rossa */
    margin: 10px 0;
}

/* Dropdown Menu */
.dropdown-menu {
    background-color: #f5f5f5; /* Grigio chiaro */
    border: 1px solid #ddd; /* Bordo sottile */
}

.dropdown-item {
    color: #333;
    transition: color 0.3s ease-in-out;
}

.dropdown-item:hover, .dropdown-item:focus {
    background-color: #b21917; /* Sfondo rosso */
    color: #ffffff; /* Testo bianco */
}

/* Pulsante del menu (Hamburger) */
.btn-custom {
    background-color: #b21917 !important;
    color: #ffffff;
}

.btn-custom:hover {
    background-color: #ffffff !important;
    color: #b21917;
    border: 1px solid #b21917;
}

/* Offcanvas Header */
.offcanvas-header {
    background-color: #ffffff; /* Sfondo bianco */
    border-bottom: 1px solid #ddd; /* Linea grigia */
}

.offcanvas-title {
    color: #b21917; /* Testo rosso */
    font-size: 22px;
    font-weight: bold;
}

/* Offcanvas Body */
.offcanvas-body {
    background-color: #ffffff;
    color: #b21917; /* Testo principale rosso */
}

/* Divider (marcatore di linea) */
hr.divider {
    border: none;
    border-top: 2px solid #aaa; /* Grigio */
    margin: 10px 0;
}

/* Link Principali */
.nav-link {
    color: #b21917; /* Testo rosso */
    font-weight: 600;
    transition: color 0.3s ease-in-out;
}

.nav-link:hover, .nav-link:focus {
    color: #333; /* Grigio scuro all'hover */
    text-decoration: underline;
}

/* Dropdown Menu */
.dropdown-menu {
    background-color: #ffffff; /* Sfondo bianco */
    border: 1px solid #ddd; /* Bordo grigio */
    z-index: 9999 !important; /* Assicura che stia sopra tutto */
}

/* Assicura che tutti i dropdown Bootstrap abbiano z-index alto */
.dropdown-menu.show {
    z-index: 10001 !important;
}

.dropdown-item {
    color: #b21917; /* Testo rosso */
    transition: background-color 0.3s ease-in-out, color 0.3s ease-in-out;
}

.dropdown-item:hover, .dropdown-item:focus {
    background-color: #ddd; /* Sfondo grigio */
    color: #333; /* Testo grigio scuro */
}

/* Pulsante di Chiusura */
.btn-close {
    color: #b21917 !important;
    opacity: 1;
}

/* Sezioni del menu offcanvas */
.menu-section-title {
    letter-spacing: 0.08em;
    color: #6c757d;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.25rem;
}

/* ===========================================
   OFFCANVAS Z-INDEX FIX
   Bootstrap 5 offcanvas z-index override
   Ensures menu stays above page content
   =========================================== */
.offcanvas {
    z-index: 1055 !important; /* Above Bootstrap default 1045 */
}

.offcanvas-backdrop {
    z-index: 1050 !important; /* Above content, below offcanvas */
}

/* Ensure page content doesn't create high z-index stacking contexts */
.container-fluid .card,
.container-fluid .table-container,
.container-fluid .sticky-top:not(.navbar-main) {
    z-index: auto !important;
}

/* Keep sticky table headers low but functional within their container */
.table-responsive .sticky-top,
.table-container .sticky-top,
thead.sticky-top {
    z-index: 1 !important; /* Relative to table container only */
}

.menu-section-title + .nav-item,
.menu-section-title + .dropdown,
.menu-section-title + li {
    margin-top: 0.25rem;
}
