/* ===================================================
   VARIABILI CSS GLOBALI
   ===================================================*/
:root {
  --bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --bs-primary: #5235FF;  
  --bs-primary-rgb: 82, 53, 255;
  --bs-body-bg: #f6f6f6;
  --bs-navbar-brand-color: var(--bs-primary);
  --bs-navbar-brand-hover-color: var(--bs-primary-darker);
  --bs-light-rgb: 250, 250, 250;
  --bs-secondary: #D1CAFF;    
  --bs-primary-bg-subtle: #f5f5f5;
  --bs-warning: #e9c46a;
  --bs-warning-bg-subtle: #fff5db;
  --bs-info: #64B5F6;
  --bs-info-rgb: 100, 181, 246;
  --bs-success: #66BB6A;
  --bs-success-rgb: 102, 187, 106;
  --bs-danger: #F55044;
  --bs-danger-rgb: 245, 80, 68;
  --bs-primary-darker: color-mix(in srgb, var(--bs-primary) 85%, black);
}

/* ===================================================
   LAYOUT E TIPOGRAFIA BASE
   ===================================================*/
body {
  background-color: var(--bs-body-bg);
}

.navbar-brand {
  font-family: 'Bree Serif', serif;
  font-weight: 400;
  font-size: 1.75rem;
  letter-spacing: -0.3px;
}

h1, h2, h3, h4, h5, h6, .heading-font {
  font-family: 'Bree Serif', serif;
  letter-spacing: -0.3px;
}

/* ===================================================
   NAVBAR
   ===================================================*/
.navbar-brand, .navbar-nav, .navbar-toggler {
  --bs-navbar-brand-color: var(--bs-primary);
  --bs-navbar-color: var(--bs-primary);
  --bs-nav-link-hover-color: var(--bs-secondary);
}

.navbar {
  background-color: rgba(255, 255, 255, 0.95) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar-brand:hover {
  color: var(--bs-primary-darker);
}

.nav-link {
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem !important;
  transition: all 0.2s ease;
}

/* ===================================================
   CARDS MODERNE
   ===================================================*/
.card {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  background-color: white;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.04),
    0 1px 3px rgba(0, 0, 0, 0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.card-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding: 0.5rem 1rem;
  position: relative;
  min-height: 56px;
  display: flex; /* Aggiungiamo flexbox */
  align-items: center; /* Centraggio verticale */
  justify-content: space-between; /* Per distanziare titolo e azioni */
}

.card-header:first-child {
  border-radius: 16px 16px 0 0;
}

.card-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 16px 16px 0 0;
}

.card-body {
  padding: 1.5rem;
}

.card-header-compact {
  padding: 1rem 1.25rem;
}

.card-body-compact {
  padding: 1.25rem;
}

.card-title {
  font-family: 'Bree Serif', serif;
  font-weight: 600;
  color: #1a202c;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.card-title h1, .card-title h2, .card-title h3, 
.card-title h4, .card-title h5, .card-title h6 {
  margin-bottom: 0;
  color: inherit;
}

.card-subtitle {
  color: #718096;
  font-size: 0.875rem;
  margin-bottom: 0;
  font-weight: 500;
}

/* Varianti colorate per le card */
.card.card-primary {
  border-color: rgba(82, 53, 255, 0.2);
}

.card.card-primary .card-header::before {
  background: linear-gradient(90deg, var(--bs-primary), #6366f1);
}

.card.card-success .card-header::before {
  background: linear-gradient(90deg, var(--bs-success), #48bb78);
}

.card.card-warning .card-header::before {
  background: linear-gradient(90deg, var(--bs-warning), #ed8936);
}

.card.card-info .card-header::before {
  background: linear-gradient(90deg, var(--bs-info), #4299e1);
}

.card-footer {
  background-color: #f8f9fa;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding: 1rem 1.5rem;
  border-radius: 0 0 16px 16px;
}

.card.card-borderless {
  border: none;
  box-shadow: none;
  background: transparent;
}

.card.card-borderless .card-header::before {
  display: none;
}

.card.card-flat {
  box-shadow: none;
  border: 1px solid #e2e8f0;
}

.card.card-flat:hover {
  transform: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ===================================================
   BOTTONI
   ===================================================*/
.btn-primary {
  --bs-btn-bg: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);
  --bs-btn-hover-bg: var(--bs-primary-darker);
  --bs-btn-hover-border-color: var(--bs-primary);
  --bs-btn-active-bg: #000000;
  --bs-btn-active-border-color: #000000;
  --bs-btn-disabled-bg: var(--bs-primary);
  --bs-btn-disabled-border-color: var(--bs-primary);
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-outline-primary {
  --bs-btn-color: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);
  --bs-btn-hover-bg: var(--bs-primary);
  --bs-btn-hover-border-color: var(--bs-primary);
  --bs-btn-hover-color: white;
  --bs-btn-active-bg: color-mix(in srgb, var(--bs-primary) 85%, black);
  --bs-btn-active-border-color: var(--bs-primary);
  --bs-btn-active-color: white;
  --bs-btn-disabled-color: var(--bs-primary);
  --bs-btn-disabled-border-color: var(--bs-primary);
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-outline-secondary {
  --bs-btn-color: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);
  --bs-btn-hover-bg: var(--bs-primary);
  --bs-btn-hover-border-color: var(--bs-primary);
  --bs-btn-hover-color: white;
  --bs-btn-active-bg: color-mix(in srgb, var(--bs-primary) 85%, black);
  --bs-btn-active-border-color: var(--bs-primary);
  --bs-btn-active-color: white;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-outline-success {
  --bs-btn-color: var(--bs-success);
  --bs-btn-border-color: var(--bs-success);
  --bs-btn-hover-bg: var(--bs-success);
  --bs-btn-hover-border-color: var(--bs-success);
  --bs-btn-hover-color: white;
  --bs-btn-active-bg: color-mix(in srgb, var(--bs-success) 85%, black);
  --bs-btn-active-border-color: var(--bs-success);
  --bs-btn-active-color: white;
  --bs-btn-disabled-color: var(--bs-success);
  --bs-btn-disabled-border-color: var(--bs-success);
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-outline-info {
  --bs-btn-color: var(--bs-info);
  --bs-btn-border-color: var(--bs-info);
  --bs-btn-hover-bg: var(--bs-info);
  --bs-btn-hover-border-color: var(--bs-info);
  --bs-btn-hover-color: white;
  --bs-btn-active-bg: color-mix(in srgb, var(--bs-info) 85%, black);
  --bs-btn-active-border-color: var(--bs-info);
  --bs-btn-active-color: white;
  --bs-btn-disabled-color: var(--bs-info);
  --bs-btn-disabled-border-color: var(--bs-info);
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-outline-warning {
  --bs-btn-color: var(--bs-warning);
  --bs-btn-border-color: var(--bs-warning);
  --bs-btn-hover-bg: var(--bs-warning);
  --bs-btn-hover-border-color: var(--bs-warning);
  --bs-btn-hover-color: black;
  --bs-btn-active-bg: color-mix(in srgb, var(--bs-warning) 85%, black);
  --bs-btn-active-border-color: var(--bs-warning);
  --bs-btn-active-color: black;
  --bs-btn-disabled-color: var(--bs-warning);
  --bs-btn-disabled-border-color: var(--bs-warning);
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-outline-danger {
  --bs-btn-color: var(--bs-danger);
  --bs-btn-border-color: var(--bs-danger);
  --bs-btn-hover-bg: var(--bs-danger);
  --bs-btn-hover-border-color: var(--bs-danger);
  --bs-btn-hover-color: white;
  --bs-btn-active-bg: color-mix(in srgb, var(--bs-danger) 85%, black);
  --bs-btn-active-border-color: var(--bs-danger);
  --bs-btn-active-color: white;
  --bs-btn-disabled-color: var(--bs-danger);
  --bs-btn-disabled-border-color: var(--bs-danger);
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

/* ===================================================
   DROPDOWN
   ===================================================*/
.dropdown-menu {
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
  padding: 0.5rem;
  z-index: 1050 !important;
}

.dropdown-item {
  border-radius: 6px;
  padding: 0.5rem 1rem;
}

.dropdown-item.active, .dropdown-item:active {
  background-color: var(--bs-primary);
  color: white;
}

.dropdown-item:hover {
  background-color: #d8d8d8;
  transition: background-color 0.2s ease;
}

/* Stili per i sottomenu dropdown */
.dropdown-submenu {
  position: absolute;
  left: 100%;
  top: 0;
  margin-top: 0;
  visibility: hidden;
  opacity: 0;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
  padding: 0.5rem;
  transition: visibility 0.2s, opacity 0.2s;
}

.dropdown-item.dropdown-toggle {
  position: relative;
}

.dropdown-item.dropdown-toggle::after {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.dropdown-item.dropdown-toggle:hover + .dropdown-submenu,
.dropdown-submenu:hover {
  visibility: visible;
  opacity: 1;
}

/* Stili per dropdown accordion */
.dropdown-accordion {
  position: relative;
}

.accordion-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.accordion-icon {
  margin-left: auto;
  transition: transform 0.3s ease;
}

.accordion-icon.rotate {
  transform: rotate(90deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.accordion-content.show {
  max-height: 200px;
}

.accordion-content .dropdown-item {
  padding-left: 2rem;
}

/* ===================================================
   FORM CONTROLS
   ===================================================*/
.form-control:focus-within, .form-select:focus-within {
  border-color: var(--bs-primary) !important;
  box-shadow: 0 0 0 0.25rem rgba(82, 53, 255, 0.25) !important;
  outline: 0 !important;
}

input[type="color"].form-control {
  height: calc(1.5em + 0.75rem + 2px);
  padding: 0.375rem 0.25rem;
}

.nav-tabs .nav-link {
  color: #6c757d;
}

.nav-tabs .nav-link:hover,
.nav-tabs .nav-link:focus {
  color: var(--bs-primary);
}

.nav-tabs .nav-link.active {
  color: var(--bs-primary);
}

/* Form switches */
.form-switch .form-check-input {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280,0,0,0.25%29'/%3e%3c/svg%3e");
}

.form-switch .form-check-input:checked {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

.form-switch .form-check-input:focus {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.25rem rgba(82, 53, 255, 0.25);
}

.form-switch .form-check-input:checked:focus {
  box-shadow: 0 0 0 0.25rem rgba(82, 53, 255, 0.25);
}

/* Checkbox e radio */
.form-check-input[type="checkbox"],
.form-check-input[type="radio"] {
  border-color: #dee2e6;
  transition: all 0.2s ease;
}

.form-check-input[type="checkbox"]:checked,
.form-check-input[type="radio"]:checked {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.form-check-input[type="checkbox"]:focus,
.form-check-input[type="radio"]:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.25rem rgba(82, 53, 255, 0.25);
}

.form-check-input[type="checkbox"]:checked:focus,
.form-check-input[type="radio"]:checked:focus {
  box-shadow: 0 0 0 0.25rem rgba(82, 53, 255, 0.25);
}

.form-check-input[type="checkbox"]:indeterminate {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
  --bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/%3e%3c/svg%3e");
}

.form-check-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-check-input:disabled:checked {
  background-color: rgba(82, 53, 255, 0.5);
  border-color: rgba(82, 53, 255, 0.5);
}

/* ===================================================
   PAGINAZIONE
   ===================================================*/
.pagination {
  --bs-pagination-color: var(--bs-primary);
  --bs-pagination-bg: #fff;
  --bs-pagination-border-color: var(--bs-primary);
  --bs-pagination-hover-color: #fff;
  --bs-pagination-hover-bg: var(--bs-primary);
  --bs-pagination-hover-border-color: var(--bs-primary);
  --bs-pagination-focus-color: var(--bs-primary);
  --bs-pagination-focus-bg: #fff;
  --bs-pagination-focus-box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
  --bs-pagination-active-color: #fff;
  --bs-pagination-active-bg: var(--bs-primary);
  --bs-pagination-active-border-color: var(--bs-primary);
  --bs-pagination-disabled-color: #6c757d;
  --bs-pagination-disabled-bg: #fff;
  --bs-pagination-disabled-border-color: #dee2e6;
  margin-top: 1rem;
}

.page-link {
  border-radius: 6px;
  margin: 0 2px;
  transition: all 0.2s ease;
}

.page-item.active .page-link {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.page-item:not(.active) .page-link:hover {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
  color: white;
}

/* ===================================================
   SNACKBAR/NOTIFICHE
   ===================================================*/
.snackbar {
  visibility: hidden;
  min-width: 250px;
  margin-left: -125px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 12px;
  padding: 16px;
  position: fixed;
  z-index: 100000;
  left: 50%;
  bottom: 30px;
  font-weight: 500;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.snackbar.show {
  visibility: visible;
  animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

.snackbar.success {
  background-color: #4CAF50;
  color: white;
}

.snackbar.error {
  background-color: #FF4B4B;
  color: white;
}

.snackbar.info {
  background-color: var(--bs-primary);
  color: white;
}

@keyframes fadein {
  from {bottom: 0; opacity: 0;}
  to {bottom: 30px; opacity: 1;}
}

@keyframes fadeout {
  from {bottom: 30px; opacity: 1;}
  to {bottom: 0; opacity: 0;}
}

/* ===================================================
   UTILITY CLASSES
   ===================================================*/
.bg-primary {
  background-color: var(--bs-primary) !important;
}

.text-primary {
  color: var(--bs-primary) !important;
}

.padding-v0 {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.preview-area {
  height: 145px;
  overflow: auto;
}

pre {
  background-color: #f8f9fa !important;
}

/* ===================================================
   SIDEBAR LAYOUT
   ===================================================*/
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 240px;
  background-color: #ffffff;
  border-right: 1px solid #e9ecef;
  z-index: 1000;
  transition: width 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 768px) {
  .sidebar {
      z-index: 2000;
  }
}

.sidebar.collapsed {
  width: 70px;
}

.sidebar-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e9ecef;
  flex-shrink: 0;
  background-color: #ffffff;
  position: relative;
}

.sidebar-brand {
  font-family: 'Bree Serif', serif;
  font-size: 1.3rem;
  color: var(--bs-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  font-weight: 600;
  transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-brand {
  opacity: 0;
  pointer-events: none;
}

.sidebar-brand:hover {
  color: var(--bs-primary-darker);
}

.sidebar-toggle-btn {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  color: #6c757d;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

.sidebar:hover .sidebar-toggle-btn {
  opacity: 1;
  pointer-events: auto;
}

.sidebar.collapsed .sidebar-toggle-btn {
  opacity: 1;
  pointer-events: auto;
  top: 50%;
  right: 50%;
  transform: translateX(50%) translateY(-50%);
}

.sidebar-toggle-btn:hover {
  background-color: #f8f9fa;
  color: var(--bs-primary);
}

.sidebar-menu {
  padding: 1rem 0;
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.collapsed .sidebar-menu {
  padding: 1rem 0;
}

.sidebar-menu::-webkit-scrollbar {
  width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.sidebar-menu-item {
  margin-bottom: 0.25rem;
  position: relative;
}

.sidebar-menu-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: #6c757d;
  text-decoration: none;
  transition: all 0.2s ease;
  border-radius: 0;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-menu-link {
  padding: 0.75rem 0;
  justify-content: center;
}

.sidebar-menu-link:hover {
  background-color: #f8f9fa;
  color: var(--bs-primary);
}

.sidebar-menu-link.active {
  background-color: var(--bs-primary);
  color: white;
}

.sidebar-menu-link i {
  width: 18px;
  margin-right: 0.65rem;
  text-align: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-menu-link i {
  margin-right: 0;
  width: auto;
}

.sidebar-menu-text {
  transition: opacity 0.3s ease;
  flex-grow: 1;
}

.sidebar.collapsed .sidebar-menu-text {
  display: none;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 0.875rem;
}

.sidebar.collapsed .sidebar-footer {
  padding: 0.875rem 0;
  display: flex;
  justify-content: center;
}

.user-info {
  display: flex;
  align-items: center;
  padding: 0.65rem;
  border-radius: 8px;
  background-color: white;
  border: 1px solid #e9ecef;
  transition: all 0.3s ease;
}

.sidebar.collapsed .user-info {
  padding: 0.65rem;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #e9ecef;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: var(--bs-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.8rem;
  margin-right: 0.65rem;
  flex-shrink: 0;
}

.sidebar.collapsed .user-avatar {
  margin-right: 0;
  width: 24px;
  height: 24px;
  font-size: 0.7rem;
}

.user-details {
  flex: 1;
  min-width: 0;
  transition: opacity 0.3s ease;
}

.sidebar.collapsed .user-details {
  opacity: 0;
  pointer-events: none;
  display: none;
}

.user-name {
  font-weight: 600;
  color: #212529;
  font-size: 0.8rem;
  margin-bottom: 0.125rem;
}

.user-company {
  font-size: 0.7rem;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown {
  transition: opacity 0.3s ease;
}

.sidebar.collapsed .user-dropdown {
  opacity: 0;
  pointer-events: none;
  display: none;
}

.main-content {
  margin-left: 240px;
  min-height: 100vh;
  background-color: var(--bs-body-bg);
  transition: margin-left 0.3s ease;
}

.sidebar.collapsed + .main-content {
  margin-left: 70px;
}

/* Submenu Styles */
.sidebar-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background-color: #f8f9fa;
}

.sidebar.collapsed .sidebar-submenu {
  display: none;
}

.sidebar-submenu.show {
  max-height: 300px;
}

.sidebar-submenu .sidebar-menu-link {
  padding-left: 2.5rem;
  font-size: 0.8rem;
  background-color: transparent;
}

.sidebar-submenu .sidebar-menu-link:hover {
  background-color: #e9ecef;
}

.sidebar-submenu .sidebar-menu-link.active {
  background-color: var(--bs-primary);
  color: white;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: #6c757d;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.sidebar-toggle:hover {
  background-color: #f8f9fa;
  color: var(--bs-primary);
}

.chevron {
  transition: transform 0.3s ease, opacity 0.3s ease;
  margin-left: auto;
  font-size: 0.75rem;
}

.sidebar.collapsed .chevron {
  display: none;
}

.chevron.rotate {
  transform: rotate(90deg);
}

/* Tooltip per sidebar collassata */
.sidebar.collapsed .sidebar-menu-item:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background-color: #333;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 1000;
  margin-left: 0.5rem;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

/* ===================================================
   CLASSI GENERICHE PER LAYOUT PAGINE
   ===================================================*/
.page-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: var(--bs-body-bg);
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.page-header {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid #e9ecef;
  background-color: #ffffff;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  z-index: 10;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: #212529;
  margin: 0;
  font-family: 'Bree Serif', serif;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  cursor: pointer;
}

.page-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #fafafa;
  min-width: 0;
  height: 100%;
  position: relative;
  overflow-y: auto;
  padding: 1.5rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.dashboard-main {
  overflow-y: auto;
  padding: 0;
}

.dashboard-main .container-fluid {
  padding: 1.5rem;
}

.page-header .dropdown-menu {
  z-index: 1051 !important;
  max-height: calc(100vh - 50px);
  overflow-y: scroll;
}

/* ===================================================
   MODALI MODERNI
   ===================================================*/
.modal-backdrop {
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-backdrop.show {
  opacity: 1;
}

.modal-dialog {
  box-shadow: none;
  border-radius: 20px;
  border: none;
  overflow: hidden;
  transform: scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.show .modal-dialog {
  transform: scale(1);
}

.modal-content {
  border: none;
  border-radius: 20px;
  background: white;
  overflow: hidden;
  box-shadow: none;
  height: 100%;
}

.modal-header {
  background: linear-gradient(135deg, #fafbfc 0%, #f8f9fa 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding: 1rem 1.5rem 1rem;
  position: relative;
}

.modal-title {
  font-family: 'Bree Serif', serif;
  font-weight: 600;
  color: #1a202c;
  font-size: 1.375rem;
  line-height: 1.3;
  margin: 0;
}

.modal-header .btn-close {
  padding: 0.75rem;
  margin: -0.75rem -1rem -0.75rem auto;
  border: none;
  opacity: 0.6;
  font-size: 1rem;
  transition: all 0.2s ease;
  border-radius: 8px;
}

.modal-header .btn-close:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.05);
  transform: scale(1.1);
}

.modal-header .btn-close:focus {
  box-shadow: 0 0 0 3px rgba(82, 53, 255, 0.2);
  outline: none;
}

.modal-body {
  padding: 1.5rem;
  color: #4a5568;
  line-height: 1.6;
}

.modal-footer {
  background-color: #f8f9fa;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding: 1rem 1.5rem;
  gap: 0.75rem;
}

.modal-footer .btn {
  margin: 0;
  min-width: 100px;
}

.modal-lg .modal-content {
  border-radius: 24px;
}

.modal-xl .modal-content {
  border-radius: 28px;
}

.modal-sm .modal-content {
  border-radius: 16px;
}

.modal-sm .modal-header {
  padding: 1rem 1.25rem 0.875rem;
}

.modal-sm .modal-body {
  padding: 1.25rem;
}

.modal-sm .modal-footer {
  padding: 0.875rem 1.25rem;
}

.modal-fullscreen .modal-content {
  border-radius: 0;
}

.modal.fade .modal-dialog {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translate(0, -50px) scale(0.9);
}

.modal.show .modal-dialog {
  transform: translate(0, 0) scale(1);
}

.modal.modal-headerless .modal-content {
  padding-top: 1rem;
}

.modal.modal-headerless .modal-header {
  display: none;
}

/* ===================================================
   FIX DROPDOWN NELLE CARD
   ===================================================*/
.card .dropdown {
  position: static;
}

.card .dropdown-menu {
  z-index: 1055 !important;
}

.widget-container .card {
  overflow: visible;
  position: relative;
  z-index: 1;
}

.widget-container .card.dropdown-open {
  z-index: 1060 !important;
}

/* ===================================================
   TABELLE MODERNE
   ===================================================*/
.table-container {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid #e9ecef;
  background: white;
}

.table {
  background-color: transparent;
  border-radius: 0;
  border: none;
  margin-bottom: 0;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table thead {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  position: relative;
}

.table thead th {
  background: transparent;
  border: none;
  border-bottom: 2px solid #dee2e6;
  border-right: 1px solid #dee2e6;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: #495057;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.table thead th:first-child {
  border-top-left-radius: 14px;
}

.table thead th:last-child {
  border-top-right-radius: 14px;
  border-right: none;
}

.table tbody td {
  border: none;
  border-bottom: 1px solid #dee2e6;
  border-right: 1px solid #dee2e6;
  color: #6c757d;
  font-size: 0.9rem;
  vertical-align: middle;
  background-color: #fafbfc;
  transition: background-color 0.2s ease;
}

.table tbody td:last-child {
  border-right: none;
}

.table tbody tr:hover td {
  background-color: #f1f3f4;
  border-right-color: #ced4da;
}

.table tbody tr:hover td:last-child {
  border-right: none;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 14px;
}

.table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 14px;
}

.table-responsive {
  border-radius: 16px;
  border: 2px solid #e9ecef;
  background: white;
  overflow: hidden;
}

.table-responsive .table {
  margin-bottom: 0;
}

.table tbody tr.empty-state td {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #6c757d;
  font-style: italic;
}

.table .badge {
  font-size: 0.75rem;
  padding: 0.4em 0.7em;
}

.table a {
  color: var(--bs-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.table a:hover {
  color: #ffffff;
}

/* ===================================================
   RESPONSIVE
   ===================================================*/
@media (max-width: 768px) {
  .card {
    border-radius: 12px;
  }
  
  .card-header {
    padding: 1.25rem 1rem;
  }
  
  .card-body {
    padding: 1.25rem 1rem;
  }
  
  .card-header-compact {
    padding: 0.875rem 1rem;
  }
  
  .card-body-compact {
    padding: 1rem;
  }

  .page-header {
    padding: 0.75rem 1rem;
  }
  
  .page-title {
    font-size: 1.25rem;
  }
  
  .page-main {
    padding: 1rem;
  }
  
  .page-actions {
    gap: 0.5rem;
  }

  .dashboard-main .container-fluid {
    padding: 0rem;
  }

  .modal-dialog {
    margin: 1rem;
    border-radius: 16px;
  }
  
  .modal-content {
    border-radius: 16px;
  }
  
  .modal-header {
    padding: 1rem 1.25rem 0.875rem;
  }
  
  .modal-body {
    padding: 1.25rem;
  }
  
  .modal-footer {
    padding: 1rem 1.25rem;
  }

  .table-container {
    border-radius: 12px;
  }
  
  .table thead th,
  .table tbody td {
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
  }
  
  .table thead th:first-child,
  .table tbody td:first-child {
    padding-left: 0.75rem;
  }
  
  .table thead th:last-child,
  .table tbody td:last-child {
    padding-right: 0.75rem;
  }

  /* Sidebar responsive */
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .sidebar.collapsed {
    width: 240px !important;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .sidebar.collapsed + .main-content {
    margin-left: 0;
  }
  
  .mobile-header {
    display: block;
    padding: 1rem;
    background-color: white;
    border-bottom: 1px solid #e9ecef;
  }
  
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
  }

  @media (max-width: 768px) {
    .sidebar-overlay {
        z-index: 1999;
    }
  }
  
  .sidebar-overlay.show {
    display: block;
  }

  /* Su mobile, annulla tutti gli effetti di collapse */
  .sidebar.collapsed .sidebar-brand {
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  
  .sidebar.collapsed .sidebar-menu-text {
    display: block !important;
  }
  
  .sidebar.collapsed .chevron {
    display: inline !important;
  }
  
  .sidebar.collapsed .sidebar-menu-link {
    padding: 0.75rem 1rem !important;
    justify-content: flex-start !important;
  }
  
  .sidebar.collapsed .sidebar-menu-link i {
    margin-right: 0.65rem !important;
    width: 18px !important;
  }
  
  .sidebar.collapsed .sidebar-menu {
    padding: 1rem 0 !important;
  }
  
  .sidebar.collapsed .sidebar-footer {
    padding: 0.875rem !important;
  }
  
  .sidebar.collapsed .user-info {
    padding: 0.65rem !important;
    justify-content: flex-start !important;
    width: auto !important;
    height: auto !important;
    border-radius: 8px !important;
    border: 1px solid #e9ecef !important;
  }
  
  .sidebar.collapsed .user-avatar {
    margin-right: 0.65rem !important;
    width: 30px !important;
    height: 30px !important;
    font-size: 0.8rem !important;
  }
  
  .sidebar.collapsed .user-details {
    opacity: 1 !important;
    pointer-events: auto !important;
    display: block !important;
  }
  
  .sidebar.collapsed .user-dropdown {
    opacity: 1 !important;
    pointer-events: auto !important;
    display: block !important;
  }
  
  .sidebar.collapsed .sidebar-submenu {
    display: block !important;
  }
  
  .sidebar-toggle-btn {
    display: none !important;
  }
}

@media (min-width: 769px) {
  .mobile-header {
    display: none;
  }
}

@media (max-height: 600px) {
  .modal-dialog {
    margin: 0.5rem;
  }
  
  .modal-body {
    max-height: 60vh;
    overflow-y: auto;
  }
}

/* ===================================================
   COMPATIBILITÀ E LEGACY
   ===================================================*/
table {
  width: 100%;
  margin-bottom: 1rem;
  border-collapse: collapse;
}

.dataTable-wrapper .table-container {
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.04),
    0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Configurazione base */
@view-transition {
  navigation: auto;
}


.btn-square {
  width: 36px;
  height: 36px;
}

.btn-height-std {
  height: 36px;
}