/* Styles personnalisés */
:root {
    --sidebar-width: 260px;
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --primary-color-rgb: 0, 123, 255;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: white;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
}

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

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar.collapsed {
    width: 70px;
}

.main-content {
    margin-left: var(--sidebar-width);
    transition: all 0.3s;
    min-height: 100vh;
}

.main-content.expanded {
    margin-left: 70px;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.sidebar-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.sidebar-header img {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.sidebar-header h5 {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin: 0.25rem 0 0 0;
    color: #ffffff;
}

.sidebar-header .text-muted {
    opacity: 0.9;
    font-size: 0.75rem;
    margin-top: 0.15rem;
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 400;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.sidebar-menu {
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
}

.sidebar-menu li {
    margin: 0.25rem 0.75rem;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.sidebar-menu li:hover {
    transform: translateX(4px);
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.25rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
    position: relative;
    font-weight: 500;
    font-size: 0.95rem;
}

.sidebar-menu a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 0;
    background: var(--primary-color);
    border-radius: 0 4px 4px 0;
    transition: height 0.3s ease;
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    padding-left: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-menu a:hover::before {
    height: 60%;
}

.sidebar-menu a.active {
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.2), rgba(0, 123, 255, 0.1));
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-left: 3px solid var(--primary-color);
}

.sidebar-menu a.active::before {
    height: 100%;
    width: 3px;
}

.sidebar-menu i {
    margin-right: 1rem;
    width: 22px;
    text-align: center;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    opacity: 0.85;
    color: inherit;
}

.sidebar-menu a:hover i,
.sidebar-menu a.active i {
    opacity: 1;
    transform: scale(1.1);
    color: inherit;
}

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

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

.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.15);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 0 10px 10px;
}

.sidebar-menu li:hover .sidebar-submenu {
    max-height: 500px;
}

.sidebar-submenu li {
    margin: 0.15rem 0;
    border-bottom: none;
}

.sidebar-submenu a {
    padding: 0.7rem 1.25rem 0.7rem 3.5rem;
    color: rgba(255, 255, 255, 0.75);
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 400;
    border-radius: 8px;
    margin: 0 0.5rem;
}

.sidebar-submenu a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding-left: 4rem;
    transform: translateX(4px);
}

.sidebar-submenu i {
    font-size: 0.9rem;
    margin-right: 0.75rem;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1050;
        transition: transform 0.3s ease;
        width: 280px !important;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    /* Overlay pour le menu mobile */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
        transition: opacity 0.3s;
    }
    
    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
    
    /* Assurer que les menus sont visibles en mode mobile */
    .sidebar-menu {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .sidebar-menu li {
        display: block !important;
    }
    
    .sidebar-menu a {
        display: flex !important;
        visibility: visible !important;
    }
    
    .sidebar-header {
        display: block !important;
        visibility: visible !important;
    }
}

.min-vh-100 {
    min-height: 100vh;
}

/* Header amélioré */
.navbar {
    padding: 0.75rem 0;
    background: #ffffff;
    border-bottom: 1px solid #e9ecef !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.navbar .border-bottom {
    border-bottom: 1px solid #e9ecef !important;
}

.navbar h4 {
    font-size: 1.35rem;
    font-weight: 600;
    color: #2c3e50;
    letter-spacing: -0.5px;
    margin-bottom: 0.15rem;
}

.navbar small {
    font-size: 0.8rem;
    color: #6c757d;
}

.user-profile-btn {
    border: none;
    padding: 0.5rem 1rem !important;
    color: #333;
    border-radius: 12px;
    transition: all 0.3s ease;
    background: transparent;
}

.user-profile-btn:hover {
    background-color: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-profile-btn:focus,
.user-profile-btn:active {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    background-color: #f8f9fa;
}

.user-profile-btn.show {
    background-color: #f8f9fa;
}

.user-avatar {
    width: 45px;
    height: 45px;
    object-fit: cover;
    border: 2px solid #e9ecef;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-profile-btn:hover .user-avatar {
    border-color: var(--primary-color, #007bff);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.user-avatar-default {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-profile-btn:hover .user-avatar-default {
    border-color: var(--primary-color, #007bff);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 123, 123, 0.3);
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
}

.navbar .dropdown-menu {
    border: none;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15);
    border-radius: 0.75rem;
    padding: 0.75rem 0;
    margin-top: 0.75rem !important;
    min-width: 250px;
}

.navbar .dropdown-item {
    padding: 0.75rem 1.5rem;
    transition: all 0.2s ease;
    border-radius: 0;
    margin: 0;
    font-size: 0.9rem;
}

.navbar .dropdown-item:first-child {
    border-radius: 0.75rem 0.75rem 0 0;
}

.navbar .dropdown-item:last-child {
    border-radius: 0 0 0.75rem 0.75rem;
}

.navbar .dropdown-item:hover {
    background-color: #f8f9fa;
    transform: translateX(5px);
    padding-left: 1.75rem;
}

.navbar .dropdown-item.text-danger:hover {
    background-color: #f8d7da;
    color: #721c24 !important;
}

.navbar .dropdown-item i {
    width: 20px;
    text-align: center;
    margin-right: 0.5rem;
}

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

/* Badge dans le header */
.navbar .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    font-weight: 500;
}

/* Bouton menu mobile */
#mobileMenuToggle {
    color: #495057;
    border: none;
    background: transparent;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

#mobileMenuToggle:hover {
    background-color: #f8f9fa;
    color: var(--primary-color, #007bff);
}

#mobileMenuToggle:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Responsive header */
@media (max-width: 991px) {
    .navbar {
        padding: 0.6rem 0;
    }
    
    .navbar .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .navbar h4 {
        font-size: 1.1rem;
        margin-bottom: 0.1rem;
        line-height: 1.3;
    }
    
    .navbar small {
        font-size: 0.75rem;
        display: block;
        margin-top: 0.1rem;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0.5rem 0 !important;
    }
    
    .navbar .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .navbar .d-flex.justify-content-between {
        flex-wrap: nowrap;
        gap: 0.5rem;
    }
    
    .navbar h4 {
        font-size: 0.95rem !important;
        margin-bottom: 0.05rem;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .navbar small {
        font-size: 0.65rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .navbar .flex-grow-1 {
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }
    
    .user-profile-btn {
        padding: 0.25rem 0.4rem !important;
        min-width: auto;
        margin: 0 !important;
    }
    
    .user-avatar,
    .user-avatar-default {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.85rem !important;
        margin: 0 !important;
    }
    
    .user-profile-btn .d-none.d-lg-block {
        display: none !important;
    }
    
    .user-profile-btn i.fa-chevron-down {
        display: none !important;
    }
    
    #mobileMenuToggle {
        padding: 0.25rem 0.4rem !important;
        margin-right: 0.25rem !important;
        font-size: 1rem !important;
        min-width: 36px;
    }
    
    .navbar .dropdown-menu {
        min-width: 250px !important;
        max-width: calc(100vw - 1rem);
        right: 0.5rem !important;
        left: auto !important;
        margin-top: 0.5rem !important;
    }
}

/* Styles pour les groupes de permissions */
.permission-group {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.permission-group:hover {
    background: #f1f3f5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.permission-group h6 {
    color: #495057;
    font-weight: 600;
}

.permission-group .form-check {
    padding-left: 1.75rem;
}

.permission-group .form-check-label {
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1.4;
}

.permission-group .form-check-label > span {
    display: block;
    font-weight: 500;
    color: #212529;
    margin-bottom: 2px;
}

.permission-group .form-check-label code {
    font-size: 0.75rem;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    color: #6c757d;
    font-weight: normal;
}

.permission-group .toggle-group {
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.permission-group .toggle-group:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.permission-group .toggle-group.active {
    font-weight: 600;
}

/* Responsive pour les groupes de permissions */
@media (max-width: 768px) {
    .permission-group .d-flex.justify-content-between {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .permission-group .d-flex.justify-content-between > div:last-child {
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .permission-group .toggle-group {
        flex: 1;
        min-width: 120px;
    }
}

/* Styles pour les toasts */
.toast-container {
    z-index: 9999;
}

.toast {
    min-width: 300px;
    max-width: 400px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    margin-bottom: 10px;
}

.toast-header {
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.toast-body {
    padding: 12px 16px;
}

/* Animation pour l'apparition des toasts */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.show {
    animation: slideInRight 0.3s ease-out;
}

/* Styles pour la pagination */
.pagination-wrapper {
    padding-top: 1rem;
}

.pagination-info {
    font-size: 0.9rem;
    white-space: nowrap;
}

.pagination-info strong {
    color: #495057;
    font-weight: 600;
}

.pagination {
    margin-bottom: 0;
    gap: 0.5rem;
    display: flex;
    align-items: center;
}

.pagination .page-link {
    color: #495057;
    background-color: #fff;
    border: 1px solid #dee2e6;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-weight: 500;
    min-width: 44px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 0.9rem;
    text-decoration: none;
}

.pagination .page-link:hover:not(.disabled) {
    color: var(--primary-color, #007bff);
    background-color: #f8f9fa;
    border-color: var(--primary-color, #007bff);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.15);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color, #007bff);
    border-color: var(--primary-color, #007bff);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.25);
}

.pagination .page-item.disabled .page-link {
    color: #adb5bd;
    background-color: #f8f9fa;
    border-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

.pagination .page-item.disabled .page-link:hover {
    transform: none;
    box-shadow: none;
    color: #adb5bd;
    background-color: #f8f9fa;
    border-color: #e9ecef;
}

/* Responsive pagination */
@media (max-width: 768px) {
    .pagination-wrapper {
        padding-top: 0.75rem;
    }
    
    .pagination-info {
        font-size: 0.85rem;
        text-align: center;
        white-space: normal;
        width: 100%;
    }
    
    .pagination-controls {
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem;
    }
    
    .pagination .page-link {
        padding: 0.5rem 0.8rem;
        font-size: 0.875rem;
        min-width: 40px;
    }
}
