% Bokeron Template based on Bayes Business School Beamer theme by Emilio Luis Saenz Guillen

\ProvidesPackage{beamerthemeBokeronTemp}

\RequirePackage{silence}
\WarningsOff[mathdesign/mdbch]
\RequirePackage{etoolbox}
\RequirePackage{fontawesome5}
\RequirePackage{tikz}
\RequirePackage{graphicx}

% Eliminate navigation symbols
\setbeamertemplate{navigation symbols}{}

% Section and subsection numbering in table of contents
\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]
\useoutertheme[subsection=false]{miniframes}
\setbeamercolor{section in head/foot}{bg=BokeronBlue,fg=white}

% Captions numbering
\setbeamertemplate{caption}[numbered]

% Set slide margins
\setbeamersize{text margin left=2.2em, text margin right=2.8em}

% Set Normal Text Color
\setbeamercolor{normal text}{fg=Black}

% Structure colour (bullet points and section headings...)
\setbeamercolor{structure}{fg=BokeronBlue}

% Define colours
\definecolor{BokeronTitleBlue}{RGB}{0,149,197}
\definecolor{LighterBokeronTitleBlue}{RGB}{204,217,236}
\definecolor{BokeronBlue}{RGB}{30,160,186}
\definecolor{BoxLightBlue}{RGB}{173,235,255}
\definecolor{BokeronInk}{RGB}{17,53,71}
\definecolor{BokeronMist}{RGB}{239,249,252}

\newcommand{\BokeronCornerShapes}{%
  \fill[BokeronBlue] ([xshift=-2.1cm]current page.north east) rectangle ([yshift=-1.4cm]current page.north east);
  \fill[BokeronBlue] ([xshift=-1.1cm,yshift=-1.3cm]current page.north east) rectangle ([xshift=0cm,yshift=-2.4cm]current page.north east);
}

\newcommand{\BokeronLogoBadge}{%
  \IfFileExists{images/LogoOpenBokeron.png}{%
    \node[anchor=south east,inner sep=0pt] at ([xshift=-0.6cm,yshift=0.55cm]current page.south east) {\includegraphics[width=2.15cm]{images/LogoOpenBokeron.png}};
  }{}
}

\newcommand{\BokeronStandardBackground}{%
  \begin{tikzpicture}[remember picture,overlay]
    \fill[white] (current page.south west) rectangle (current page.north east);
    \BokeronCornerShapes
    \draw[BokeronMist,line width=1pt] ([xshift=2.2cm,yshift=0.95cm]current page.south west) -- ([xshift=-2.8cm,yshift=0.95cm]current page.south east);
  \end{tikzpicture}%
}

\newcommand{\BokeronSectionBackground}{%
  \begin{tikzpicture}[remember picture,overlay]
    \fill[white] (current page.south west) rectangle (current page.north east);
    \BokeronCornerShapes
    \BokeronLogoBadge
    \draw[BokeronMist,line width=1pt] ([xshift=2.2cm,yshift=0.95cm]current page.south west) -- ([xshift=-3.3cm,yshift=0.95cm]current page.south east);
  \end{tikzpicture}%
}

\newcommand{\BokeronTitleBackground}{%
  \begin{tikzpicture}[remember picture,overlay]
    \fill[black] (current page.south west) rectangle (current page.north east);
    \ifx\inserttitlegraphic\@empty
      \fill[BokeronMist] ([xshift=-7.1cm]current page.north east) rectangle (current page.south east);
    \else
      \node[anchor=north east,inner sep=0pt] at (current page.north east) {\includegraphics[width=0.56\paperwidth,height=\paperheight]{\inserttitlegraphic}};
    \fi
  \end{tikzpicture}%
}

\newcommand{\BokeronClosingBackground}{%
  \begin{tikzpicture}[remember picture,overlay]
    \fill[BokeronBlue] (current page.south west) rectangle (current page.north east);
  \end{tikzpicture}%
}

\newcommand{\insertclosingqrgraphic}{}
\newcommand{\closingqrgraphic}[1]{\renewcommand{\insertclosingqrgraphic}{#1}}
\newcommand{\BokeronContactItem}[3]{%
  {\Large\color{white}#1}\hspace{0.45em}{\large\color{white}\textbf{#2}}\\[0.15em]
  {\normalsize\color{BokeronMist}#3}
}

\newcommand{\BokeronFrameTitleLayout}[2]{%
  \setbeamertemplate{frametitle}{%
    \vspace*{#1}%
    \noindent\begin{beamercolorbox}[wd=0.78\paperwidth,left]{frametitle}%
      \usebeamerfont{frametitle}\insertframetitle
    \end{beamercolorbox}%
    \vspace*{#2}%
  }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% TITLE %%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamerfont{frametitle}{family=\rmfamily,series=\mdseries,size=\Large}
\setbeamercolor{titlelike}{fg=BokeronTitleBlue}
\setbeamertemplate{title page}{%
  \vbox{}
  \vfill
  \begin{minipage}[t]{0.38\paperwidth}
    {\usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle\par}
    \ifx\insertsubtitle\@empty\else
      \vspace{0.45em}
      {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}
    \fi
    \vspace{1.1em}
    {\usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor\par}
    \vspace{0.65em}
    {\usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute\par}
    \vspace{0.35em}
    {\usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate\par}
  \end{minipage}
  \hspace*{0.18\paperwidth}
  \vfill
}
\setbeamerfont{title}{family=\rmfamily,size=\LARGE}
\setbeamerfont{subtitle}{size=\large}
\setbeamerfont{author}{size=\large}
\setbeamerfont{institute}{size=\large}
\setbeamerfont{date}{size=\normalsize}
\setbeamercolor{title}{fg=white}
\setbeamercolor{subtitle}{fg=BokeronMist}
\setbeamercolor{author}{fg=white}
\setbeamercolor{institute}{fg=BokeronMist}
\setbeamercolor{date}{fg=BokeronBlue}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%% BACKGROUND %%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usebackgroundtemplate{\BokeronStandardBackground}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% CLOSING SLIDE %%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{endpage}{%
  \begin{frame}[plain]
    \BokeronClosingBackground
    \vspace*{0.9cm}
    \begin{center}
      {\fontsize{28}{32}\selectfont\color{white}\textbf{Muchas gracias}}\\[0.35em]
      {\Large\color{white}openbokeron.uma.es}\\[0.18em]
      {\large\color{BokeronMist}openbokeron.uma.es/forum}
    \end{center}
    \vfill
    \begin{columns}[T,totalwidth=\textwidth]
      \begin{column}{0.31\textwidth}
        \raggedright
        \BokeronContactItem{\faTelegramPlane}{Telegram}{Comunidad}\\[0.8em]
        \BokeronContactItem{\faTwitter}{Twitter}{@OpenBokeron}
      \end{column}
      \begin{column}{0.28\textwidth}
        \centering
        \ifdefempty{\insertclosingqrgraphic}{%
          \begin{tikzpicture}
            \fill[white] (0,0) rectangle (2.45,2.45);
            \draw[BokeronTitleBlue,line width=1pt] (0.16,0.16) rectangle (2.29,2.29);
            \node[text width=1.7cm,align=center,text=BokeronTitleBlue] at (1.225,1.225) {QR aquí};
          \end{tikzpicture}
        }{%
          \includegraphics[width=0.64\linewidth]{\insertclosingqrgraphic}
        }\\[0.4em]
        {\small\color{BokeronMist}Telegram}
      \end{column}
      \begin{column}{0.31\textwidth}
        \raggedleft
        {\Large\color{white}\faGlobe\hspace{0.45em}\textbf{Web}}\\[0.15em]
        {\normalsize\color{BokeronMist}openbokeron.uma.es}\\[0.8em]
        {\Large\color{white}\faComments\hspace{0.45em}\textbf{Foro}}\\[0.15em]
        {\normalsize\color{BokeronMist}openbokeron.uma.es/forum}
      \end{column}
    \end{columns}
    \vspace*{0.7cm}
  \end{frame}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%% ITEMIZE %%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{itemize item}{\textbullet}
\setbeamertemplate{itemize subitem}{--}
\setbeamertemplate{itemize subsubitem}{\textbullet}
\setlength{\leftmargini}{1.25em}
\setlength{\leftmarginii}{1em}
\setlength{\leftmarginiii}{1em}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% FRAME TITLES %%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\normalframetitle}{%
  \BokeronFrameTitleLayout{1.1em}{0.6em}
  \setbeamerfont{frametitle}{size=\LARGE,series=\mdseries}
}
\newcommand{\smallframetitle}{%
  \BokeronFrameTitleLayout{0.9em}{0.45em}
  \setbeamerfont{frametitle}{size={\fontsize{18}{22}},series=\bfseries}
}
\newcommand{\smallerframetitle}{%
  \BokeronFrameTitleLayout{0.75em}{0.35em}
  \setbeamerfont{frametitle}{size={\fontsize{14}{18}},series=\bfseries}
}
\normalframetitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% TABLES %%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\arraystretch}{1.3}
\newcommand{\tableheadrow}{\rowcolor{BokeronBlue}}
\newcommand{\tableheadcol}[1]{{\bfseries\color{white}#1}}
\AtBeginEnvironment{tabular}{\color{black}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%% BLOCK %%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamerfont{block title}{family=\rmfamily,size=\large}
\setbeamercolor{block title}{fg=white,bg=BokeronTitleBlue}
\setbeamercolor{block body}{bg=LighterBokeronTitleBlue}
\setbeamertemplate{blocks}[rounded][shadow=false]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%% FOOTLINE %%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamercolor{myfootlinecolor}{bg=white,fg=BokeronBlue}
\setbeamertemplate{footline}{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=3.8ex,dp=1.3ex,leftskip=.45cm,rightskip=.45cm plus1fil]{myfootlinecolor}
    \leavevmode{\usebeamerfont{author in head/foot}\insertshortauthor}%
    \hfill
    {\usebeamerfont{institute in head/foot}\insertshortinstitute}%
    \hfill
    {\usebeamerfont{title in head/foot}\insertframenumber/\inserttotalframenumber}
  \end{beamercolorbox}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%% OTHERS %%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pdfstringdefDisableCommands{%
  \def\\{}%
  \def\texttt#1{<#1>}%
}
