/* Styles pour la page de gestion des utilisateurs */

.users-container {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Header de la page */
.users-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    gap: 24px;
}

.users-title h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.users-title h1 i {
    color: #3b82f6;
    font-size: 1.8rem;
}

.users-title p {
    color: #6b7280;
    font-size: 1rem;
    margin: 0;
    line-height: 1.5;
}

.users-actions {
    flex-shrink: 0;
}

/* Cartes de statistiques */
.users-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 1.2rem;
}

.stat-icon.active {
    background: #dcfce7;
    color: #16a34a;
}

.stat-icon.admin {
    background: #dbeafe;
    color: #2563eb;
}

.stat-content {
    flex: 1;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

/* Conteneur du tableau */
.users-table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

.table-header {
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
}

.table-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}

.table-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.search-box {
    position: relative;
    min-width: 300px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    background: white;
    transition: border-color 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.875rem;
}

/* Tableau */
.table-responsive {
    overflow-x: auto;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.users-table th {
    background: #f9fafb;
    padding: 16px 24px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.users-table td {
    padding: 16px 24px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.users-table tbody tr:hover {
    background: #f9fafb;
}

/* Colonnes spécifiques */
.user-avatar {
    width: 20px;
    text-align: center;
    vertical-align: middle;
}

/* Avatar dans le tableau des utilisateurs */
.users-table .user-avatar {
    width: 100px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* S'assurer que les avatars sont bien visibles */
.users-table .user-avatar .avatar-initial,
.users-table .user-avatar .avatar-img {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.users-table .avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
}

/* Styles pour les avatars avec image dans le tableau */
.users-table .avatar-fallback .avatar-img {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.users-table .avatar-fallback.avatar-fallback-show .avatar-img {
    opacity: 0;
}

.users-table .avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
}

.users-table .avatar-placeholder:hover {
    transform: scale(1.1);
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Styles pour avatar-initial dans le tableau */
.users-table .avatar-initial {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
}

.users-table .avatar-initial:hover {
    transform: scale(1.1);
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Styles pour les avatars avec fallback */
.users-table .avatar-fallback .avatar-initial {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.users-table .avatar-fallback.avatar-fallback-show .avatar-initial {
    opacity: 1;
}

/* Styles pour les avatars avec image dans le tableau */
.users-table .avatar-fallback .avatar-img {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.users-table .avatar-fallback.avatar-fallback-show .avatar-img {
    opacity: 0;
}

/* Styles pour les avatars avec tooltip */
.users-table .avatar-tooltip {
    position: relative;
    cursor: help;
}

.users-table .avatar-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: #1f2937;
    color: white;
    font-size: 12px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    margin-bottom: 8px;
}

.users-table .avatar-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #1f2937;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.users-table .avatar-tooltip:hover::after,
.users-table .avatar-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Avatar dans la modale d'édition */
.user-modal .user-avatar {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
}

.user-modal .avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #e5e7eb;
    transition: all 0.3s ease;
}

.user-modal .avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 24px;
    border: 3px solid #e5e7eb;
}

/* Avatar dans la liste des utilisateurs avec statut */
.user-list-item .user-avatar {
    position: relative;
}

.user-list-item .avatar-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.user-list-item .avatar-status.online {
    background: #10b981;
}

.user-list-item .avatar-status.offline {
    background: #9ca3af;
}

.user-name {
    min-width: 200px;
}

.user-full-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.user-id {
    font-size: 0.75rem;
    color: #9ca3af;
    font-family: 'Courier New', monospace;
}

.user-email {
    min-width: 200px;
}

.email-link {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

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

.user-role {
    min-width: 150px;
}

.role-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-admin {
    background: #dbeafe;
    color: #1e40af;
}

.role-logistics_partner {
    background: #fef3c7;
    color: #92400e;
}

.role-transport_partner {
    background: #d1fae5;
    color: #065f46;
}

.user-status {
    min-width: 120px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.active {
    background: #10b981;
}

.status-dot.inactive {
    background: #ef4444;
}

.status-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.archived-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.user-actions {
    min-width: 120px;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* État vide */
.no-data {
    text-align: center;
    padding: 48px 24px;
}

.no-data-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.no-data-content i {
    font-size: 3rem;
    color: #d1d5db;
}

.no-data-content p {
    color: #6b7280;
    font-size: 1rem;
    margin: 0;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 24px 24px 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #9ca3af;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #6b7280;
}

.modal-body {
    padding: 0 24px 24px 24px;
}

/* Formulaire */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
    font-size: 0.875rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.password-input {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s ease;
}

.password-toggle:hover {
    color: #6b7280;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* Responsive */
@media (max-width: 768px) {
    .users-container {
        padding: 16px;
    }
    
    .users-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .users-stats {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .table-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .search-box {
        min-width: auto;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal {
        margin: 20px;
        max-height: calc(100vh - 40px);
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 4px;
    }
    
    .btn-sm {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .users-table th,
    .users-table td {
        padding: 12px 16px;
    }
    
    .modal-header,
    .modal-body {
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}
