:root {
    /* Tema principale - colori scuri/neutri */
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --dark-color: #2c3e50;
    --darker-color: #1a252f;
    --light-color: #ecf0f1;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --info-color: #3498db;
    
    /* Layout */
    --header-height: 60px;
    --footer-height: 60px;
    --sidebar-width: 280px;
    
    /* Colori di sfondo */
    --body-bg: #f8f9fa;
    --card-bg: #ffffff;
    --sidebar-bg: #2c3e50;
    --sidebar-text: #ecf0f1;
    --sidebar-hover: #34495e;
    --sidebar-active: #3498db;
    
    /* Colori per contenuti */
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-muted: #95a5a6;
    --border-color: #dee2e6;
    --hover-bg: #f8f9fa;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #3498db, #2980b9);
    --gradient-secondary: linear-gradient(135deg, #34495e, #2c3e50);
    --gradient-card: linear-gradient(135deg, #ffffff, #f8f9fa);
}

html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    font-family: 'Montserrat', sans-serif;
    color: var(--text-primary);
    background-color: var(--body-bg);
    min-height: 100vh;
    margin: 0;
    transition: margin-left 0.3s ease;
}

body.sidebar-open {
    overflow: hidden;
}

.feed-theme {
    background: var(--body-bg);
    color: var(--text-primary);
}

/* Brand text globale */
.brand-text {
    font-weight: 700;
    font-size: 1.5rem;
    color: inherit;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Main content area */
main {
    padding-top: 1rem;
    padding-bottom: 1.5rem;
}

/* Card styling */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.card-header {
    background-color: white;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.card-header.bg-primary {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color)) !important;
    color: white;
}

.card-header.bg-info {
    background: linear-gradient(45deg, #17a2b8, #138496) !important;
    color: white;
}

.card-header.bg-light {
    background: #f8f9fa;
    color: #333;
}

/* Button styling */
.btn-primary {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    border: none;
    font-weight: 500;
    color: white !important;
}

.btn-primary:hover {
    background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
    color: white !important;
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Table styling */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table-hover tbody tr:hover {
    background-color: rgba(108, 99, 255, 0.05);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

.table thead th {
    border-top: none;
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

/* Badge styling */
.badge {
    font-weight: 500;
    padding: 0.4em 0.8em;
    border-radius: 30px;
}

/* Footer styling */
.footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: var(--footer-height);
    background: linear-gradient(135deg, var(--orange-medium), var(--orange-light));
    color: #333;
    padding: 2rem 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.footer a {
    color: rgba(51, 51, 51, 0.8);
    transition: color 0.3s ease;
}

.footer a:hover {
    color: #333;
    text-decoration: none;
}

.footer-links {
    margin-top: 1rem;
}

.footer-links a {
    margin-right: 1.5rem;
}

/* Form styling */
.form-control {
    border-radius: 5px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.6rem 1rem;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(108, 99, 255, 0.25);
}

/* Custom container for content */
.content-container {
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    margin-bottom: 2rem;
    color: #333;
}

.content-container h2 {
    color: var(--dark-color);
    font-weight: 600;
}

.content-container label {
    color: var(--dark-color);
}

.content-container .form-check-label {
    color: var(--dark-color);
}

.content-container a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.content-container a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.content-container .input-group-text {
    background-color: #f8f9fa;
    border-color: rgba(0, 0, 0, 0.1);
}

.content-container .btn-primary {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    border: none;
    font-weight: 500;
    transition: all 0.3s ease;
    color: white !important;
}

.content-container .btn-primary:hover {
    background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 99, 255, 0.3);
    color: white !important;
}

/* Document cards */
.document-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.document-card .card-body {
    flex: 1;
}

.document-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

/* Category pills */
.category-pill {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 30px;
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    transition: transform 0.3s ease;
}

.category-pill:hover {
    transform: translateY(-2px);
}

/* Breadcrumb styling */
.breadcrumb {
    background-color: transparent;
    padding: 0;
    margin-bottom: 1.5rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
}

.breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb-item.active {
    color: #6c757d;
}

/* Scroll to top button */
.scroll-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    background: var(--secondary-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* Homepage Styles */
.hero-section {
    background: linear-gradient(135deg, rgba(255, 228, 209, 0.3), rgba(255, 255, 255, 0.8));
    border-radius: 20px;
    margin-top: 2rem;
    margin-bottom: 1rem;
    min-height: 25vh;
    display: flex;
    align-items: center;
}

.hero-content {
    max-width: 800px;
}

.min-vh-75 {
    min-height: 75vh;
}

.min-vh-37 {
    min-height: 37vh;
}

/* Database Visual Animations */
.database-visual {
    transition: transform 0.3s ease;
}

.database-visual:hover {
    transform: translateY(-10px);
}

.ai-brain {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.query-bubbles .bubble {
    animation: fadeInOut 4s ease-in-out infinite;
}

.bubble-1 {
    animation-delay: 0s;
}

.bubble-2 {
    animation-delay: 1.3s;
}

.bubble-3 {
    animation-delay: 2.6s;
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.9);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.connections div {
    animation: pulse 3s ease-in-out infinite;
}

.data-flow .dot {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.feature-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 133, 51, 0.1);
}

.feature-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 35px rgba(255, 133, 51, 0.15);
}

.quick-access-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.quick-access-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(255, 133, 51, 0.1);
}

.step-number {
    box-shadow: 0 4px 15px rgba(255, 133, 51, 0.3);
}

/* AI Icon Animation */
.ai-icon i {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Feature Icons */
.feature-icon i {
    transition: transform 0.3s ease;
}

.feature-card:hover .feature-icon i {
    transform: scale(1.2);
}

/* ===== SIDEBAR STYLES AVANZATA ===== */
:root {
    --sidebar-width: 360px;
    --sidebar-bg: #2c3e50;
    --sidebar-text: #ecf0f1;
    --sidebar-hover: #34495e;
    --sidebar-active: #3498db;
    --header-height: 60px;
    --sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Container - Comportamento Base */
.sidebar {
    position: fixed;
    top: 0;
    left: calc(-1 * var(--sidebar-width));
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1050;
    transition: left var(--sidebar-transition), transform var(--sidebar-transition);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    /* Assicura che sia cliccabile */
    pointer-events: auto;
}

.sidebar.active {
    left: 0;
    transform: translateX(0);
}

/* Scrollbar personalizzata per la sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    transition: background 0.3s ease;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Firefox scrollbar */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(0, 0, 0, 0.1);
}

/* Sidebar Header */
.sidebar-header {
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid rgba(236, 240, 241, 0.1);
    background: linear-gradient(135deg, #34495e, #2c3e50);
}

.sidebar-brand {
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.sidebar-brand:hover {
    color: var(--sidebar-active);
    text-decoration: none;
}

.sidebar-brand .brand-text {
    color: inherit;
}

/* Pulsante chiusura rimosso - sidebar si chiude solo con hamburger */

/* Sidebar Content con scrollbar personalizzata */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    transition: background 0.3s ease;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.sidebar-menu {
    padding: 0;
    margin: 0;
    list-style: none;
}

.sidebar-nav .sidebar-item {
    margin: 0;
}

/* Effetti hover avanzati per i menu items */
.sidebar-nav .sidebar-link {
    color: var(--sidebar-text);
    padding: 0.75rem 1.75rem;
    border: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    transition: all var(--sidebar-transition);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    /* Assicura che i menu siano cliccabili */
    pointer-events: auto;
    cursor: pointer;
    /* Previeni overflow del testo */
    white-space: nowrap;
}

.sidebar-nav .sidebar-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--sidebar-active);
    transform: scaleY(0);
    transition: transform var(--sidebar-transition);
    transform-origin: bottom;
}

.sidebar-nav .sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
    text-decoration: none;
    transform: translateX(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sidebar-nav .sidebar-link:hover::before {
    transform: scaleY(1);
}

.sidebar-nav .sidebar-link.active {
    background: var(--sidebar-active);
    color: white;
    transform: translateX(8px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.sidebar-nav .sidebar-link.active::before {
    transform: scaleY(1);
}

.sidebar-nav .sidebar-link i {
    width: 20px;
    margin-right: 0.75rem;
    text-align: center;
    font-size: 1.1rem;
    transition: all var(--sidebar-transition);
}

.sidebar-nav .sidebar-link:hover i {
    transform: scale(1.2);
    color: var(--sidebar-active);
}

.sidebar-nav .sidebar-link.active i {
    transform: scale(1.1);
}

.sidebar-nav .sidebar-link span {
    flex: 1;
    transition: all var(--sidebar-transition);
}

.sidebar-nav .sidebar-link:hover span {
    font-weight: 600;
}

.sidebar-nav .toggle-icon {
    transition: transform 0.3s ease;
    font-size: 0.9rem;
}

.sidebar-nav .toggle-icon.rotated {
    transform: rotate(180deg);
}

/* Submenu con effetti avanzati */
.sidebar-nav .collapse {
    transition: all var(--sidebar-transition);
}

.sidebar-nav .collapse .sidebar-submenu {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 0 0 8px 8px;
    margin: 0 0.5rem;
    overflow: hidden;
    padding: 0;
    list-style: none;
}

.sidebar-nav .collapse .sidebar-link {
    padding: 0.5rem 1.25rem 0.5rem 3.25rem;
    font-size: 0.9rem;
    color: rgba(236, 240, 241, 0.8);
    position: relative;
    transition: all var(--sidebar-transition);
    white-space: nowrap;
}

.sidebar-nav .collapse .sidebar-link::before {
    content: '';
    position: absolute;
    left: 2rem;
    top: 50%;
    width: 6px;
    height: 6px;
    background: var(--sidebar-active);
    border-radius: 50%;
    transform: translateY(-50%) scale(0);
    transition: transform var(--sidebar-transition);
}

.sidebar-nav .collapse .sidebar-link:hover {
    color: var(--sidebar-text);
    background: rgba(52, 73, 94, 0.5);
    transform: translateX(4px);
    padding-left: 3.5rem;
}

.sidebar-nav .collapse .sidebar-link:hover::before {
    transform: translateY(-50%) scale(1);
}

.sidebar-nav .collapse .sidebar-link.active {
    color: var(--sidebar-active);
    background: rgba(52, 152, 219, 0.15);
    font-weight: 600;
}

.sidebar-nav .collapse .sidebar-link.active::before {
    transform: translateY(-50%) scale(1);
}

.sidebar-nav .collapse .sidebar-link i {
    width: 16px;
    margin-right: 0.5rem;
    font-size: 0.9rem;
    transition: all var(--sidebar-transition);
}

.sidebar-nav .collapse .sidebar-link:hover i {
    transform: scale(1.1);
    color: var(--sidebar-active);
}

/* Sidebar Footer Semplificato */
.sidebar-footer {
    padding: 1rem 1.75rem;
    border-top: 1px solid rgba(236, 240, 241, 0.1);
    background: rgba(0, 0, 0, 0.1);
    text-align: center;
}

.sidebar-brand-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.sidebar-brand-footer small {
    color: rgba(236, 240, 241, 0.6);
    font-size: 0.75rem;
    font-weight: 500;
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Top Header Migliorato */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--gradient-secondary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    z-index: 1030;
    display: flex;
    align-items: center;
    transition: margin-left var(--sidebar-transition);
}

.sidebar-toggle-btn {
    border: none;
    background: none;
    color: var(--light-color);
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.3s ease;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--light-color);
    transform: scale(1.05);
}

.sidebar-toggle-btn:focus {
    background: rgba(255, 255, 255, 0.15);
    color: var(--light-color);
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
}

.header-title {
    flex: 1;
    text-align: center;
}

.brand-text-mini {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--light-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Header Actions - Area login */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-actions .dropdown-toggle {
    border: none;
    background: none;
    color: var(--light-color);
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.3s ease;
}

.header-actions .dropdown-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--light-color);
}

.header-actions .dropdown-toggle:focus {
    background: rgba(255, 255, 255, 0.15);
    color: var(--light-color);
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
}

.header-actions .btn-outline-light {
    border-color: rgba(255, 255, 255, 0.5);
    color: var(--light-color);
    transition: all 0.3s ease;
}

.header-actions .btn-outline-light:hover {
    background: var(--light-color);
    color: var(--secondary-color);
    border-color: var(--light-color);
    transform: translateY(-1px);
}

/* Dropdown menu personalizzato */
.header-actions .dropdown-menu {
    border: none;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-radius: 0.5rem;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
}

.header-actions .dropdown-header {
    color: var(--text-primary);
    font-weight: 600;
    padding: 0.5rem 1rem;
}

.header-actions .dropdown-item {
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.header-actions .dropdown-item:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    transform: translateX(4px);
}

.header-actions .dropdown-item.text-danger:hover {
    background: rgba(231, 76, 60, 0.1);
    color: var(--accent-color);
}

/* Main Wrapper */
.main-wrapper {
    padding-top: var(--header-height);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Comportamento Responsive Corretto */

/* Comportamento generale - Sidebar sposta sempre il contenuto */
.main-wrapper {
    transition: margin-left var(--sidebar-transition);
    margin-left: 0;
}

.top-header {
    transition: margin-left var(--sidebar-transition);
    margin-left: 0;
}

/* Quando sidebar è aperta - SPOSTA il contenuto */
body.sidebar-open .main-wrapper {
    margin-left: var(--sidebar-width);
}

body.sidebar-open .top-header {
    margin-left: var(--sidebar-width);
}

/* Mobile (≤768px): Sidebar si sovrappone solo su mobile molto piccoli */
@media (max-width: 576px) {
    .sidebar {
        width: 100%;
        left: -100%;
        z-index: 1060;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    /* Su mobile piccolo, overlay e sovrapposizione */
    body.sidebar-open .main-wrapper {
        margin-left: 0; /* Non spostare su mobile molto piccolo */
    }
    
    body.sidebar-open .top-header {
        margin-left: 0; /* Non spostare su mobile molto piccolo */
    }
    
    /* Overlay scuro per mobile piccolo */
    .sidebar-overlay {
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(2px);
    }
    
    /* Impedisce lo scroll del body quando sidebar è aperta */
    body.sidebar-open {
        overflow: hidden;
    }
}

/* Tablet e Desktop (>576px): Sidebar sposta sempre il contenuto */
@media (min-width: 577px) {
    .sidebar {
        width: var(--sidebar-width);
        left: calc(-1 * var(--sidebar-width));
        z-index: 1040;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    /* Su desktop l'overlay è NASCOSTO per non interferire con i click */
    .sidebar-overlay {
        display: none !important;
    }
    
    /* Su desktop non bloccare lo scroll */
    body.sidebar-open {
        overflow: auto;
    }
    
    .header-title {
        display: block;
    }
}

/* Desktop (>768px): Comportamento ottimizzato */
@media (min-width: 769px) {
    /* Overlay completamente nascosto su desktop */
    .sidebar-overlay {
        display: none !important;
    }
}

/* Desktop Large (≥1200px): Comportamento persistente */
@media (min-width: 1200px) {
    .sidebar-persistent .main-wrapper {
        margin-left: var(--sidebar-width);
        transition: margin-left var(--sidebar-transition);
    }
    
    .sidebar-persistent .sidebar {
        left: 0;
        position: fixed;
    }
    
    .sidebar-persistent .sidebar-overlay {
        display: none;
    }
    
    .sidebar-persistent .top-header {
        left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
        transition: all var(--sidebar-transition);
    }
}

/* ===== ACCESSIBILITÀ E STATI SPECIALI ===== */

/* Focus visibile per accessibilità */
.focus-visible {
    outline: 2px solid var(--sidebar-active) !important;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Stato di transizione - Solo per la sidebar, non per tutto */
.sidebar-transitioning .sidebar {
    pointer-events: none;
}

.sidebar-transitioning .sidebar-overlay {
    pointer-events: none;
}

/* Miglioramenti per la performance */
.sidebar,
.sidebar-overlay,
.main-wrapper {
    will-change: transform, left, margin-left;
}

/* Prevenzione selezione testo durante animazioni - Solo sidebar */
.sidebar-transitioning .sidebar {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Smooth scrolling per la sidebar */
.sidebar-content {
    scroll-behavior: smooth;
}

/* Indicatore di caricamento per stati asincroni */
.sidebar-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--sidebar-active);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Stili per ridurre il motion per utenti con preferenze di accessibilità */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-overlay,
    .main-wrapper,
    .sidebar-nav .sidebar-link,
    .sidebar-nav .sidebar-link::before,
    .sidebar-nav .sidebar-link i,
    .sidebar-nav .sidebar-link span,
    .sidebar-nav .toggle-icon,
    .sidebar-content::-webkit-scrollbar-thumb {
        transition: none !important;
        animation: none !important;
    }
    
    .sidebar-nav .sidebar-link:hover,
    .sidebar-nav .sidebar-link.active {
        transform: none !important;
    }
}

/* ===== TEMA APPLICAZIONE ===== */

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.1);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(44, 62, 80, 0.15);
    transform: translateY(-2px);
}

.card-header {
    background: var(--gradient-card);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
}

.card-title {
    color: var(--text-primary);
    margin-bottom: 0;
}

/* Buttons */
.btn-primary {
    background: var(--gradient-primary);
    border-color: var(--primary-color);
    color: white !important;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
    color: white !important;
}

.btn-secondary {
    background: var(--gradient-secondary);
    border-color: var(--secondary-color);
    color: white !important;
}

.btn-secondary:hover {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    transform: translateY(-1px);
    color: white !important;
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: white !important;
}

.btn-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
    color: #333 !important;
}

.btn-danger {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white !important;
}

.btn-info {
    background-color: var(--info-color);
    border-color: var(--info-color);
    color: white !important;
}

/* Tables */
.table {
    color: var(--text-primary);
}

.table thead th {
    background: var(--gradient-secondary);
    color: var(--light-color);
    border-color: var(--secondary-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background-color: var(--hover-bg);
}

.table-striped > tbody > tr:nth-of-type(odd) > td,
.table-striped > tbody > tr:nth-of-type(odd) > th {
    background-color: rgba(248, 249, 250, 0.5);
}

/* Forms */
.form-control {
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.form-label {
    color: var(--text-primary);
    font-weight: 500;
}

.form-select {
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

/* Badges */
.badge {
    font-weight: 500;
}

.badge.bg-primary {
    background-color: var(--primary-color) !important;
}

.badge.bg-secondary {
    background-color: var(--secondary-color) !important;
}

.badge.bg-success {
    background-color: var(--success-color) !important;
}

.badge.bg-warning {
    background-color: var(--warning-color) !important;
}

.badge.bg-danger {
    background-color: var(--accent-color) !important;
}

.badge.bg-info {
    background-color: var(--info-color) !important;
}

/* Alerts */
.alert-primary {
    background-color: rgba(52, 152, 219, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.alert-secondary {
    background-color: rgba(44, 62, 80, 0.1);
    border-color: var(--secondary-color);
    color: var(--secondary-color);
}

.alert-success {
    background-color: rgba(39, 174, 96, 0.1);
    border-color: var(--success-color);
    color: var(--success-color);
}

.alert-warning {
    background-color: rgba(243, 156, 18, 0.1);
    border-color: var(--warning-color);
    color: var(--warning-color);
}

.alert-danger {
    background-color: rgba(231, 76, 60, 0.1);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Pagination */
.pagination .page-link {
    color: var(--primary-color);
    border-color: var(--border-color);
}

.pagination .page-link:hover {
    color: white;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Breadcrumb */
.breadcrumb {
    background-color: transparent;
    padding: 0;
}

.breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--secondary-color);
}

.breadcrumb-item.active {
    color: var(--text-secondary);
}

/* Footer */
.footer {
    background: var(--gradient-secondary);
    color: var(--light-color);
    border-top: 1px solid var(--border-color);
}

.footer p {
    color: var(--light-color);
    margin-bottom: 0;
}

/* Text Colors */
.text-primary {
    color: var(--primary-color) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-success {
    color: var(--success-color) !important;
}

.text-warning {
    color: var(--warning-color) !important;
}

.text-danger {
    color: var(--accent-color) !important;
}

.text-info {
    color: var(--info-color) !important;
}

/* Background Colors */
.bg-primary {
    background-color: var(--primary-color) !important;
}

.bg-secondary {
    background-color: var(--secondary-color) !important;
}

.bg-light {
    background-color: var(--light-color) !important;
}

/* Links */
a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* Dropdown */
.dropdown-menu {
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(44, 62, 80, 0.15);
}

.dropdown-item {
    color: var(--text-primary);
}

.dropdown-item:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

/* Modal */
.modal-content {
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(44, 62, 80, 0.2);
}

.modal-header {
    background: var(--gradient-card);
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    color: var(--text-primary);
}

/* Progress */
.progress {
    background-color: rgba(44, 62, 80, 0.1);
}

.progress-bar {
    background-color: var(--primary-color);
}

/* Nav tabs */
.nav-tabs .nav-link {
    color: var(--text-secondary);
    border-color: transparent;
}

.nav-tabs .nav-link:hover {
    color: var(--primary-color);
    border-color: var(--border-color);
}

.nav-tabs .nav-link.active {
    color: var(--primary-color);
    background-color: var(--card-bg);
    border-color: var(--border-color) var(--border-color) var(--card-bg);
}

/* ===== MIGLIORAMENTI SPECIFICI ===== */

/* Scroll to top button */
.scroll-to-top {
    background: var(--gradient-primary);
    color: white;
    border: none;
    box-shadow: 0 4px 16px rgba(52, 152, 219, 0.3);
}

.scroll-to-top:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

/* Feature cards */
.feature-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(44, 62, 80, 0.15);
}

.feature-icon {
    color: var(--primary-color);
}

/* Statistics cards */
.stat-card {
    background: var(--gradient-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(44, 62, 80, 0.15);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

/* Dashboard widgets */
.dashboard-widget {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.08);
}

.dashboard-widget h5 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 600;
}

/* Search and filter forms */
.search-form {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.search-form .form-control,
.search-form .form-select {
    border-color: var(--border-color);
}

.search-form .btn-primary {
    background: var(--gradient-primary);
    border: none;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
}

/* Status badges personalizzati */
.status-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background-color: rgba(39, 174, 96, 0.15);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.status-inactive {
    background-color: rgba(149, 165, 166, 0.15);
    color: var(--text-muted);
    border: 1px solid var(--text-muted);
}

.status-pending {
    background-color: rgba(243, 156, 18, 0.15);
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
}

.status-error {
    background-color: rgba(231, 76, 60, 0.15);
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.action-buttons .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-action {
    border: none;
    border-radius: 0.375rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.btn-action:hover {
    transform: translateY(-1px);
}

.btn-view {
    background-color: var(--info-color);
    color: white;
}

.btn-edit {
    background-color: var(--warning-color);
    color: white;
}

.btn-delete {
    background-color: var(--accent-color);
    color: white;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive improvements */
@media (max-width: 768px) {
    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    
    .table-responsive {
        border: 1px solid var(--border-color);
        border-radius: 0.375rem;
    }
}
}