\documentclass[12pt]{report}
\usepackage{titlesec}
\usepackage[utf8]{inputenc}
\usepackage[latvian]{babel}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{gensymb} % grādu simbols
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{indentfirst}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{ragged2e}
\usepackage{secdot}
\usepackage{tabularx}
\usepackage{tcolorbox}
\usepackage{tikz}
\usepackage{listings}
\usepackage{tocloft}
\usepackage{caption}
\usepackage{fmtcount}
\usepackage{ltablex}
\usepackage{chngcntr}
\usepackage{longtable}
\usepackage{ifthen}
\usepackage{needspace}
\usepackage[framemethod=TikZ]{mdframed}
% uncomment and comment the line above if compile time is too long for preview,
% but it won't compile the continuation overlay in the boxes correctly (should
% be commented for end compilation)
% \usepackage{mdframed}
\usetikzlibrary{positioning}


\hypersetup{
	colorlinks=true,
	linkcolor=black,
	urlcolor=blue
}

\urlstyle{rm}

\renewcommand{\contentsname}{Saturs}

\titlespacing*{\section}{0pt}{2em}{2em}
\titlespacing*{\subsection}{0pt}{2em}{2em}
\titlespacing*{\subsubsection}{0pt}{2em}{2em}
\titlespacing*{\paragraph}{0pt}{2em}{2em}
\titlespacing*{\subparagraph}{0pt}{2em}{2em}



% Configure the chapter / paragraph numbering (it only works this way when I compile)
\renewcommand{\thechapter}{\arabic{chapter}.}
\renewcommand{\thesection}{\arabic{section}.}
\renewcommand{\thesubsection}{\thesection\arabic{subsection}.}
\renewcommand{\thesubsubsection}{\thesubsection\arabic{subsubsection}.}
\renewcommand{\theparagraph}{\thesubsubsection\arabic{paragraph}.}
\renewcommand{\thesubparagraph}{\theparagraph\arabic{subparagraph}.}


\titleformat{\section}{\large\bfseries\centering\vfill\eject\MakeUppercase}{\thesection}{1em}{} % section formatting
\titleformat{\subsection}{\bfseries}{\thesubsection}{1em}{} % subsection formatting
\titleformat{\subsubsection}{\bfseries}{\thesubsubsection}{1em}{} % subsubsection formatting
\titleformat{\paragraph}{\bfseries}{\theparagraph}{1em}{} % paragraph formatting
\titleformat{\subparagraph}{\bfseries}{\thesubparagraph}{0em}{} % subparagraph formatting


% Modify caption style
\DeclareCaptionFormat{format}{\textit{#1} \textbf{#3}}
\captionsetup{format=format}

\DeclareCaptionLabelFormat{image}{#2 att.}
\captionsetup[figure]{labelformat=image, labelsep=period}

\counterwithin{figure}{section} % Reset figure counter within each section
\renewcommand{\thefigure}{\thesection\arabic{figure}.} % Redefine figure numbering
\counterwithin{table}{section} % Reset table counter within each section
\renewcommand{\thetable}{\thesection\arabic{table}.} % Redefine table numbering

\captionsetup[table]{justification=raggedleft,singlelinecheck=off} % Align table caption text to the left
\captionsetup[figure]{justification=raggedright,singlelinecheck=off} % Align figure caption text to the right



\geometry{a4paper, left=30mm, right=20mm, top=20mm, bottom=20mm}

\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\linespread{1.5}
\setlength{\parindent}{1cm}
\setlength{\parskip}{0pt}

\setcounter{secnumdepth}{5} % Numering for subsubsections
\setcounter{tocdepth}{3} % Add subsubsections in ToC


% ToC config
% TODO: section in uppercase
\renewcommand{\cftsecfont}{\MakeUppercase}
\renewcommand{\cfttoctitlefont}{\hfill\large\bfseries\MakeUppercase}
\renewcommand{\cftaftertoctitle}{\hfill}
\cftsetindents{section}{0.5cm}{0.5cm}
\cftsetindents{subsection}{1cm}{1cm}
\cftsetindents{subsubsection}{1.5cm}{1.5cm}
% \addto\captionslatvian{
% 	\renewcommand{\contentsname}{Satura rādītājs}
% }



\newcounter{rownum}
\renewcommand{\therownum}{\padzeroes[2]{\decimal{rownum}}}

\keepXColumns

\input{./src/utils/index.tex}


\begin{document}
\input{./src/title-page.tex}
\input{./src/abstract.tex}
\pagebreak
\tableofcontents
\input{./src/introduction/index.tex}
\input{./src/legends.tex}
\input{./src/description/index.tex}
\input{./src/requirements/index.tex}
\input{./src/design/index.tex}
% \input{./src/test.tex}

\end{document}
