%%%%%%
% Minitoc
%%%%%%%%%%%%%%
	
\newtcolorbox{minitocbox}{%
	enhanced,
	title = Plan du chapitre,
	colframe = titrecolor,
	colback = titrecolor!10,
	colbacktitle = titrecolor,
	coltitle = titrecolor!5,
	fonttitle = \fontsize{16}{18}\ECFWebster,
	coltitle = titrecolor!5,
	attach boxed title to top center = {
		yshift=-0.25mm-\tcboxedtitleheight/2,
		yshifttext=2mm-\tcboxedtitleheight/2
	},
	boxed title style = {
		boxrule = 0.5mm,
		frame code = {
			\path[tcb fill frame] ([xshift=-4mm]frame.west)
				-- (frame.north west) -- (frame.north east) -- ([xshift=4mm]frame.east)-- (frame.south east) -- (frame.south west) -- cycle; 
		},
		interior code = { 
			\path[tcb fill interior] ([xshift=-2mm]interior.west)
				-- (interior.north west) -- (interior.north east)-- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west)-- cycle;
		}  
	},
	drop fuzzy shadow
}

%%%%%
% TOC
%%%%%%%%%%%%%%

\def\tableofcontents{%
  \if@twocolumn
    \@restonecoltrue\onecolumn
  \else
    \@restonecolfalse
  \fi
  \begin{tikzpicture}
  \node[inner sep=10mm,fill=filltoc,align=center,draw=toc,thick,decorate,decoration={random steps,segment length=0.3cm,amplitude=2mm}] at (0,0) {%
		\begin{minipage}{0.9\linewidth}
			\begin{center}
				\begin{titre}
					\huge\duttfamily
					\contentsname
				\end{titre}
			\end{center}
			\vskip1cm
			\@starttoc{toc}
		\end{minipage}
  };
  \end{tikzpicture}
  \if@restonecol\twocolumn\fi
}


\setcounter{tocdepth}{0}

\fancypagestyle{toc}{%
	\fancyhf{}%
  	\fancyfoot{}
	\pagecolor{toc!5}
  	\fancyfoot[RO,RE]{%
		\vskip0.1pt
		\begin{tikzpicture}
			\node[rounded corners=3pt,fill=toc,inner ysep=5pt, inner xsep=2ex,text=white] (numpage) {\ECFWebster\thepage};
			\drawshadow{numpage}{toc}
		\end{tikzpicture}
  	}
}

\fancypagestyle{maintoc}{% 
	\fancyhf{}%
  	\fancyfoot[RO]{% pages impaires
		\ClearShipoutPicture
		\vskip0.1pt  	
		\begin{tikzpicture}
			\node[rounded corners=3pt,fill=toc,inner ysep=5pt, inner xsep=2ex,text=toc!5] (numpage) {\ECFWebster\thepage};
			\drawshadow{numpage}{toc}
		\end{tikzpicture}
		\pagecolor{toc!5}
  	}
  	\fancyfoot[LE]{% pages paires	
  		\ClearShipoutPicture
  		\vskip0.1pt
  		\begin{tikzpicture}
			\node[rounded corners=3pt,fill=toc,inner ysep=5pt, inner xsep=2ex,text=toc!5] (numpage) {\ECFWebster\thepage};
			\drawshadow{numpage}{toc}
  		\end{tikzpicture}
		\pagecolor{toc!5}
  	}
}

\addto\captionsfrench{\renewcommand{\contentsname}{SOMMAIRE}}

%\newcommand{\chaptertoccolor}{white}
\newcommand{\sectiontoccolor}{sectioncolor}
\newcommand{\subsectiontoccolor}{subsectioncolor}
\newcommand{\subsubsectiontoccolor}{subsubsectioncolor}

\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{2em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries %\large
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      \color{\sectiontoccolor}
	  \def\@linkcolor{\sectiontoccolor}\ECFWebster#1\nobreak\
       \leaders\hbox{$\m@th
        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
        mu$}\hfil\nobreak\hb@xt@\@pnumwidth{\hss
        \def\@linkcolor{\sectiontoccolor}
		\ECFWebster#2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}
 
\renewcommand*\l@section{%
\color{\sectiontoccolor}
\def\@linkcolor{\sectiontoccolor}
\@dottedtocline{1}{0em}{3em}
}

\renewcommand*\l@subsection{%
\color{\subsectiontoccolor}
\def\@linkcolor{\subsectiontoccolor}
\@dottedtocline{1}{2em}{2em}
}

\renewcommand*\l@subsubsection{%
\color{\subsubsectiontoccolor}
\def\@linkcolor{\subsubsectiontoccolor}
\@dottedtocline{1}{4em}{2em}
}