% ===========================================================
% LaTeX Template — SIM di Era AI (B5, Times New Roman)
% Sesuai BOOK-SPEC: B5 17.6×25cm, TNR 12pt, 1.5 spacing
% ===========================================================

\documentclass[12pt, b5paper, twoside, openright]{book}

% ── Geometry (margin sesuai BOOK-SPEC) ──
\usepackage[
  paperwidth=17.6cm,
  paperheight=25cm,
  top=3cm,
  bottom=2.5cm,
  inner=3cm,       % binding side
  outer=2.5cm,
  headheight=14pt,
  headsep=0.8cm,
  footskip=1.2cm
]{geometry}

% ── Font: Times New Roman ──
\usepackage{fontspec}
\setmainfont{Times New Roman}
\setsansfont{Arial}
\setmonofont{Courier New}

% ── Bahasa Indonesia ──
\usepackage[indonesian]{babel}

% ── Spacing 1.5 ──
\usepackage{setspace}
\onehalfspacing

% ── Grafik & Warna ──
\usepackage{graphicx}
\usepackage[dvipsnames,svgnames,x11names]{xcolor}
\usepackage{float}

% ── Tabel ──
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage{tabularx}

% ── List ──
\usepackage{enumitem}
\setlist{nosep, leftmargin=1.5em}

% ── Code blocks ──
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{
  fontsize=\small,
  frame=leftline,
  framerule=0.4pt,
  rulecolor=\color{gray!60},
  xleftmargin=1em,
  commandchars=\\\{\}
}

% ── Hyperlinks ──
\usepackage[
  colorlinks=true,
  linkcolor=NavyBlue,
  citecolor=OliveGreen,
  urlcolor=RoyalBlue,
  bookmarks=true,
  bookmarksnumbered=true,
  pdfstartview=FitH
]{hyperref}

% ── Header / Footer ──
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE]{\small\itshape\leftmark}     % judul bab di kiri (halaman genap)
\fancyhead[RO]{\small\itshape\rightmark}     % judul seksi di kanan (halaman ganjil)
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}

% ── Judul Bab styling ──
\usepackage{titlesec}
\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\sffamily}
  {\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{0pt}{-20pt}{30pt}

% ── Callout environments ──
\usepackage{tcolorbox}
\tcbuselibrary{breakable}

\newtcolorbox{callout-definisi}{
  colback=blue!5, colframe=blue!50!black,
  title={\textbf{📌 Definisi}}, breakable, left=4pt, right=4pt
}
\newtcolorbox{callout-insight}{
  colback=yellow!5, colframe=yellow!60!black,
  title={\textbf{💡 Insight}}, breakable, left=4pt, right=4pt
}
\newtcolorbox{callout-warning}{
  colback=red!5, colframe=red!50!black,
  title={\textbf{⚠️ Perhatian}}, breakable, left=4pt, right=4pt
}
\newtcolorbox{callout-casestudy}{
  colback=green!5, colframe=green!50!black,
  title={\textbf{📊 Studi Kasus}}, breakable, left=4pt, right=4pt
}
\newtcolorbox{callout-template}{
  colback=gray!5, colframe=gray!60!black,
  title={\textbf{🔧 Template}}, breakable, left=4pt, right=4pt
}

% ── Pandoc provisions ──
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

% Pandoc will inject additional preamble here via --include-in-header
$if(header-includes)$
$header-includes$
$endif$

% ── Metadata ──
$if(title)$
\title{$title$}
$endif$
$if(author)$
\author{$author$}
$endif$
\date{$if(date)$$date$$else$2025$endif$}

\begin{document}

% ── Front Matter ──
\frontmatter
\pagestyle{plain}

% Halaman judul
\begin{titlepage}
  \centering
  \vspace*{3cm}
  {\Huge\bfseries\sffamily $if(title)$$title$$else$Sistem Informasi Manajemen\\di Era AI$endif$ \par}
  \vspace{0.8cm}
  {\Large\itshape $if(subtitle)$$subtitle$$else$Perspektif Strategis dan Pengambilan Keputusan$endif$ \par}
  \vspace{2cm}
  {\large $if(author)$$author$$else$Helmi Bahar Alim, S.Kom., M.Kom.$endif$ \par}
  \vspace{0.5cm}
  {\normalsize Fakultas Sains dan Teknologi\\Universitas Putra Bangsa, Kebumen \par}
  \vfill
  {\normalsize $if(date)$$date$$else$2025$endif$ \par}
\end{titlepage}

% Halaman hak cipta (placeholder)
\thispagestyle{empty}
\vspace*{\fill}
\noindent\textbf{Sistem Informasi Manajemen di Era AI}\\
\textit{Perspektif Strategis dan Pengambilan Keputusan}\\[6pt]
Penulis: Helmi Bahar Alim, S.Kom., M.Kom.\\
Penerbit: [Nama Penerbit]\\
ISBN: [Nomor ISBN]\\[6pt]
Hak Cipta © 2025 pada penulis.\\
Dilindungi Undang-Undang.\\
Dilarang memperbanyak sebagian atau seluruh isi buku ini\\
tanpa izin tertulis dari penulis dan penerbit.\\[12pt]
Cetakan Pertama, 2025
\vspace{1cm}
\clearpage

% Table of contents
\tableofcontents
\listoffigures
\listoftables

% ── Main Matter ──
\mainmatter
\pagestyle{fancy}

$body$

% ── Back Matter ──
\backmatter

\end{document}
