html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* ============================================
   LAYOUT FIX - Footer sempre in fondo
   ============================================ */

html {
  height: 100%;
}

body.layout-fixed {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.layout-fixed .app-wrapper {
  min-height: 100vh;
}

/* Assicura che app-main riempia lo spazio disponibile */
body.layout-fixed .app-main {
  min-height: calc(100vh - 57px - 50px); /* 100vh - header - footer */
}

/* Login form - responsive styles in mobile.css */
#loginForm {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    position: relative;
}

.background-navbar-white {
    background: white;
}

/* ============================================
   SIDEBAR FIXED - Desktop: sidebar fissa, scroll indipendente
   ============================================ */
@media (min-width: 992px) {
    .app-sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1038;
    }

    .app-sidebar .sidebar-wrapper {
        height: calc(100vh - 60px);
        overflow-y: auto;
    }

    /* Compensa lo spazio della sidebar fixed sul contenuto */
    .app-header {
        margin-left: 250px;
    }

    .app-main {
        margin-left: 250px;
    }

    .app-footer {
        margin-left: 250px;
    }
}

/* ============================================
   NESTED TREEVIEW MENU STYLES
   ============================================ */

/* Base treeview styling */
.nav-treeview {
    display: none;
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Show treeview when parent is open */
.nav-item.menu-open > .nav-treeview {
    display: block;
}

/* Rotate arrow when menu is open */
.nav-item.menu-open > .nav-link .nav-arrow {
    transform: rotate(90deg);
}

.nav-arrow {
    transition: transform 0.3s ease;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
}

/* Allinea verticalmente la freccia con il testo nel parent menu */
.sidebar-menu .nav-link > p {
    display: flex;
    align-items: center;
    margin: 0;
    flex: 1;
}

/* Nested treeview indentation and styling */
.nav-treeview .nav-item {
    position: relative;
}

.nav-treeview .nav-link {
    padding: 0.5rem 1rem;
    padding-left: 1rem;
    font-size: 0.9rem;
}

/* Nested levels - increasing indentation */
.nav-treeview .nav-treeview .nav-link {
    padding-left: 1.5rem;
}

.nav-treeview .nav-treeview .nav-treeview .nav-link {
    padding-left: 2rem;
}

.nav-treeview .nav-treeview .nav-treeview .nav-treeview .nav-link {
    padding-left: 2.5rem;
}

/* Nested treeview visual indicators */
.nav-treeview .nav-item::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-treeview .nav-item:last-child::before {
    bottom: 50%;
}

.nav-treeview .nav-item::after {
    content: '';
    position: absolute;
    left: 1rem;
    top: 50%;
    width: 0.5rem;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.1);
}

/* Hover states */
.nav-treeview .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Active states */
.nav-treeview .nav-link.active {
    background-color: rgba(0, 123, 255, 0.2);
    color: #fff;
}

/* Smaller icons in nested menus */
.nav-treeview .nav-icon {
    font-size: 0.85rem;
    width: 1.5rem;
    text-align: center;
}

/* Has-treeview indicator */
.nav-item.has-treeview > .nav-link {
    cursor: pointer;
}

/* Animation for menu expansion */
.nav-treeview {
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   NOTIFICATIONS STYLES
   ============================================ */

#notificationsDropdown .dropdown-menu {
    padding: 0;
    margin-top: 0 !important;
    top: 100% !important;
    background-color: #ffffff !important;
    color: #212529 !important;
}

#notificationsDropdown .dropdown-header {
    padding: 0.75rem 1rem;
    font-weight: 600;
    background-color: #f8f9fa !important;
    color: #212529 !important;
}

#notificationsDropdown .dropdown-divider {
    border-color: #dee2e6 !important;
}

#notificationsDropdown .notification-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #dee2e6;
    white-space: normal;
    transition: background-color 0.15s ease;
    color: #212529 !important;
}

#notificationsDropdown .notification-item:hover {
    background-color: #f8f9fa !important;
}

#notificationsDropdown .notification-item .text-muted {
    color: #6c757d !important;
}

#notificationsDropdown .notification-item:last-child {
    border-bottom: none;
}

#notificationsDropdown .dropdown-footer {
    padding: 0.75rem 1rem;
    background-color: #f8f9fa !important;
    color: #212529 !important;
    font-weight: 500;
}

#notificationsBadge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.65rem;
    padding: 0.2em 0.4em;
}

/* Icona notifica con pulse per nuove notifiche */
#notificationsBell.has-notifications {
    animation: bellPulse 2s infinite;
}

@keyframes bellPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Navbar dropdown — copertura sia html che body per il data-bs-theme
   (al page load viene settato su html, al toggle viene settato su body) */
.app-header .dropdown-menu {
    background-color: #fff;
}
.app-header .dropdown-menu .dropdown-item {
    color: #212529 !important;
}
html[data-bs-theme="dark"] .app-header .dropdown-menu,
body[data-bs-theme="dark"] .app-header .dropdown-menu,
body.theme-dark .app-header .dropdown-menu {
    background-color: #2b3035;
}
html[data-bs-theme="dark"] .app-header .dropdown-menu .dropdown-item,
body[data-bs-theme="dark"] .app-header .dropdown-menu .dropdown-item,
body.theme-dark .app-header .dropdown-menu .dropdown-item {
    color: rgba(255, 255, 255, 0.85) !important;
}
.app-header .dropdown-menu .dropdown-item:hover,
.app-header .dropdown-menu .dropdown-item:focus {
    background-color: rgba(0, 0, 0, 0.075);
}
html[data-bs-theme="dark"] .app-header .dropdown-menu .dropdown-item:hover,
html[data-bs-theme="dark"] .app-header .dropdown-menu .dropdown-item:focus,
body[data-bs-theme="dark"] .app-header .dropdown-menu .dropdown-item:hover,
body[data-bs-theme="dark"] .app-header .dropdown-menu .dropdown-item:focus,
body.theme-dark .app-header .dropdown-menu .dropdown-item:hover,
body.theme-dark .app-header .dropdown-menu .dropdown-item:focus {
    background-color: rgba(255, 255, 255, 0.1);
}
.app-header .dropdown-menu .dropdown-item.text-danger {
    color: var(--bs-danger) !important;
}

/* Checkbox e radio dark mode — Bootstrap usa --bs-form-check-bg che AdminLTE non imposta */
body.theme-dark .form-check-input,
body[data-bs-theme="dark"] .form-check-input,
html[data-bs-theme="dark"] .form-check-input {
    background-color: #3d4147;
    border-color: #6c757d;
}
body.theme-dark .form-check-input:checked,
body[data-bs-theme="dark"] .form-check-input:checked,
html[data-bs-theme="dark"] .form-check-input:checked {
    background-color: var(--color-primary, #0d6efd);
    border-color: var(--color-primary, #0d6efd);
}
body.theme-dark .form-check-label,
body[data-bs-theme="dark"] .form-check-label,
html[data-bs-theme="dark"] .form-check-label {
    color: #dee2e6;
}
