/* ============================================================
   CSS Variables — Light & Dark
   ============================================================ */
:root {
  --bg: #fafaf7;
  --bg-secondary: #f2f2ee;
  --surface: #e8e8e4;
  --border: #d4d4cc;
  --border-strong: #a0a098;
  --text: #1a1a2e;
  --text-secondary: #5a5a72;
  --accent: #1a3a6e;
  --accent-light: #e4ebf5;
  --header-bg: #1a3a6e;
  --header-text: #ffffff;
  --green: #2d8a4e;
  --green-bg: #e8f5ec;
  --green-text: #1a5c32;
  --yellow: #9a6d00;
  --yellow-bg: #fff8df;
  --yellow-text: #6b4900;
  --red: #c0392b;
  --red-bg: #fdecea;
  --red-text: #8b1c14;
  --warning-bg: #fff3cd;
  --warning-border: #ffa500;
  --info-bg: #e8f0fe;
  --info-border: #1a56db;
  --info-text: #1a3a6e;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

html.dark {
  --bg: #121218;
  --bg-secondary: #1a1a22;
  --surface: #26262e;
  --border: #38383e;
  --border-strong: #5a5a68;
  --text: #dcdce8;
  --text-secondary: #8888a0;
  --accent: #5588cc;
  --accent-light: #1a2a42;
  --header-bg: #0d1a30;
  --header-text: #dcdce8;
  --green: #3aad63;
  --green-bg: #0a1e10;
  --green-text: #5ecb84;
  --yellow: #d4a020;
  --yellow-bg: #1e1600;
  --yellow-text: #e8c050;
  --red: #e04535;
  --red-bg: #200800;
  --red-text: #f07060;
  --warning-bg: #201500;
  --warning-border: #a06000;
  --info-bg: #0a1428;
  --info-border: #2a4a8e;
  --info-text: #8ab0e8;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

/* ============================================================
   Custom Scrollbar
   ============================================================ */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) var(--bg-secondary);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg);
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  color: var(--header-text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.5rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--header-text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-print {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
}

.btn-print:hover {
  background: #246b3e;
}

.btn-dark {
  background: rgba(255, 255, 255, 0.12);
  color: var(--header-text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-dark:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* SVG icon visibility for dark/light toggle */
.icon-sun { display: none; }
html.dark .icon-moon { display: none; }
html.dark .icon-sun { display: block; }

.btn-hamburger {
  background: rgba(255, 255, 255, 0.12);
  color: var(--header-text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.3rem;
  min-height: 44px;
  min-width: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-back-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1rem;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
}

.btn-back-top.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   Top Navigation — Mobile dropdown ONLY (hidden on desktop)
   ============================================================ */
.site-nav {
  display: none; /* hidden by default; shows on mobile via .open */
  background: rgba(0, 0, 0, 0.28);
}

.site-nav.open {
  display: flex;
  flex-direction: column;
}

.site-nav a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  font-size: 0.92rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.site-nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* ============================================================
   Page Layout
   ============================================================ */
.page-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
}

/* ============================================================
   Sidebar (Table of Contents)
   ============================================================ */
.sidebar {
  padding: 1.5rem 1rem 1.5rem 1.25rem;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.toc-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.toc ul {
  list-style: none;
}

.toc > ul {
  margin: 0;
}

.toc ul ul {
  margin-left: 0.75rem;
  margin-top: 0.1rem;
}

.toc-link {
  display: block;
  padding: 0.28rem 0.5rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 4px;
  border-left: 2px solid transparent;
}

.toc-link:hover {
  background: var(--surface);
  color: var(--accent);
}

.toc-link.active {
  border-left-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}

.toc-sub {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 0.2rem 0.5rem;
}

.toc li {
  margin-bottom: 0.05rem;
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
  padding: 0 2.5rem 5rem;
  min-width: 0;
  max-width: 900px;
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  padding: 3rem 0 2.5rem;
  border-bottom: 4px solid var(--accent);
  margin-bottom: 0;
}

.hero h1 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 1.75rem;
}

.hero-print {
  font-size: 0.95rem;
  padding: 0.6rem 1.5rem;
}

/* ============================================================
   Sections
   ============================================================ */
section {
  padding: 2.5rem 0 2rem;
  position: relative;
}

/* Decorative gradient separator between sections */
section:not(:last-of-type)::after {
  content: '';
  display: block;
  width: 100%;
  height: 3px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) 20%,
    rgba(26, 58, 110, 0.25) 60%,
    transparent 100%
  );
  border-radius: 2px;
  margin-top: 2rem;
}

html.dark section:not(:last-of-type)::after {
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) 20%,
    rgba(85, 136, 204, 0.2) 60%,
    transparent 100%
  );
}

section h2 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 1.25rem;
  padding-bottom: 0.55rem;
  border-bottom: 2px solid var(--accent);
  letter-spacing: 0.02em;
}

section h3 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text);
  margin: 1.75rem 0 0.75rem;
}

section h4 {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  margin: 1.25rem 0 0.5rem;
}

section p {
  margin-bottom: 0.9rem;
}

section p:last-child {
  margin-bottom: 0;
}

section ul,
section ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

section li {
  margin-bottom: 0.45rem;
}

/* ============================================================
   Role Cards
   ============================================================ */
.role-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.role-card h4 {
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--accent);
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.role-card p {
  margin-bottom: 0.5rem;
}

.role-card p:last-child {
  margin-bottom: 0;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

th {
  background: var(--accent);
  color: #fff;
  padding: 0.65rem 1rem;
  text-align: left;
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 600;
  white-space: nowrap;
}

td {
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

tr:nth-child(even) td {
  background: var(--bg-secondary);
}

td ul {
  padding-left: 1.25rem;
  margin: 0.25rem 0 0;
}

td li {
  margin-bottom: 0.25rem;
}

/* ============================================================
   Badges (Semafor)
   ============================================================ */
.badge {
  display: inline-block;
  padding: 0.18rem 0.7rem;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

.badge.green { background: var(--green); color: #fff; }
.badge.yellow { background: var(--yellow); color: #fff; }
.badge.red { background: var(--red); color: #fff; }

/* ============================================================
   Color Legend
   ============================================================ */
.color-legend {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

/* ============================================================
   Malverzacija Cards
   ============================================================ */
.malverzacija {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.malverzacija > h3 {
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--accent);
  margin-top: 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.06rem;
}

.situacija {
  border-radius: 6px;
  padding: 0.85rem 1rem;
  margin: 0.75rem 0;
  border-left: 4px solid;
}

.green-situacija {
  background: var(--green-bg);
  border-left-color: var(--green);
  color: var(--green-text);
}

.yellow-situacija {
  background: var(--yellow-bg);
  border-left-color: var(--yellow);
  color: var(--yellow-text);
}

.red-situacija {
  background: var(--red-bg);
  border-left-color: var(--red);
  color: var(--red-text);
}

.situacija .badge { margin-bottom: 0.5rem; }
.situacija p { margin-bottom: 0.5rem; }
.situacija p:last-child { margin-bottom: 0; }

/* ============================================================
   Info / Warning Boxes
   ============================================================ */
.warning-box {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-left: 4px solid var(--warning-border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  font-size: 0.94rem;
}

.warning-box.red {
  background: var(--red-bg);
  border-color: var(--red);
  border-left-color: var(--red);
  color: var(--red-text);
  font-weight: 700;
  font-size: 0.95rem;
}

.warning-box > strong {
  display: block;
  margin-bottom: 0.4rem;
}

.info-box {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-left: 4px solid var(--info-border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  font-size: 0.9rem;
  color: var(--info-text);
}

/* ============================================================
   Rules Lists
   ============================================================ */
.rules-list {
  list-style: none;
  padding-left: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.rules-list li {
  padding: 0.55rem 0.75rem 0.55rem 2.5rem;
  position: relative;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  background: var(--bg-secondary);
}

.rules-list li:last-child {
  border-bottom: none;
}

.rules-list li::before {
  content: '✓';
  position: absolute;
  left: 0.75rem;
  color: var(--green);
  font-weight: 700;
}

.rules-list.forbidden li::before {
  content: '✗';
  color: var(--red);
}

/* ============================================================
   Legal Handbook — specific components
   ============================================================ */

/* Inline law article badge */
.legal-ref {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
  margin-left: 0.4rem;
  white-space: nowrap;
}

/* Example phrase box — what to say */
.quote-example {
  background: var(--bg-secondary);
  border-left: 4px solid var(--border-strong);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.8rem 1rem;
  margin: 0.75rem 0;
  font-style: italic;
  color: var(--text);
}

.quote-example strong {
  display: block;
  font-style: normal;
  color: var(--text-secondary);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

/* Dialogue exchange box */
.dialog-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin: 0.75rem 0;
  font-size: 0.93rem;
}

.dialog-box > strong {
  display: block;
  color: var(--text-secondary);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.dialog-box p {
  margin-bottom: 0.35rem;
}

.dialog-box p:last-child {
  margin-bottom: 0;
}

.dialog-speaker {
  font-weight: 700;
  color: var(--accent);
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  text-align: center;
  padding: 3.5rem 1rem 3rem;
  margin-top: 1rem;
  border-top: 4px solid var(--accent);
  background: var(--bg-secondary);
}

.footer-motto {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.footer-sub {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* ============================================================
   Print
   ============================================================ */
@page {
  margin: 2cm 2.5cm;
}

@media print {
  /* Hide UI elements */
  .site-header,
  .sidebar,
  .btn-back-top,
  .hero-print {
    display: none !important;
  }

  /* Layout */
  .page-layout {
    display: block;
  }

  .main-content {
    padding: 0;
    max-width: 100%;
  }

  /* Each main section starts on its own page */
  section {
    break-before: page;
    break-inside: auto;
    padding: 0;
    border: none;
  }

  /* But the very first section stays after the hero */
  section#uvod {
    break-before: avoid;
    padding-top: 1rem;
  }

  /* Never orphan a heading at bottom of page */
  h2, h3, h4 {
    break-after: avoid;
  }

  /* Keep these blocks together */
  .malverzacija {
    break-inside: avoid;
    border: 1px solid #bbb;
    background: none;
    margin-bottom: 1rem;
  }

  .situacija {
    break-inside: avoid;
    background: none !important;
    color: #000 !important;
    border: 1px solid #ccc;
    border-left: 4px solid #555;
  }

  .green-situacija { border-left-color: #2d8a4e !important; }
  .yellow-situacija { border-left-color: #9a6d00 !important; }
  .red-situacija { border-left-color: #c0392b !important; }

  .role-card {
    break-inside: avoid;
    background: none;
    border: 1px solid #bbb;
    border-left: 4px solid #1a3a6e;
  }

  .table-wrapper {
    overflow: visible;
    box-shadow: none;
    break-inside: avoid;
  }

  table {
    break-inside: avoid;
  }

  tr {
    break-inside: avoid;
  }

  th {
    background: #1a3a6e !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .warning-box,
  .info-box {
    background: none;
    border: 1px solid #aaa;
    break-inside: avoid;
  }

  .rules-list li {
    background: none;
  }

  /* Remove the gradient separator in print */
  section::after {
    display: none;
  }

  body {
    font-size: 10pt;
    color: #000;
    background: #fff;
    line-height: 1.55;
  }

  a { color: #000; text-decoration: none; }

  .hero {
    border-bottom: 3px solid #1a3a6e;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
  }

  .hero h1 {
    color: #1a3a6e;
    font-size: 1.8rem;
  }

  .badge.green {
    background: #2d8a4e !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .badge.yellow {
    background: #9a6d00 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .badge.red {
    background: #c0392b !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .site-footer {
    background: none;
    border-top: 2px solid #1a3a6e;
    break-before: avoid;
  }

  .footer-motto { color: #1a3a6e; }
  .footer-sub { color: #555; }

  .color-legend {
    border: 1px solid #ccc;
    background: none;
  }
}

/* ============================================================
   Responsive — Mobile / Tablet
   ============================================================ */
@media (max-width: 960px) {
  .page-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .btn-hamburger {
    display: inline-flex;
  }

  /* Print button hidden in header on mobile — use footer one */
  .header-inner .btn-print {
    display: none;
  }

  .main-content {
    padding: 0 1.25rem 3rem;
  }

  .hero h1 {
    font-size: 1.7rem;
  }
}

@media (max-width: 600px) {
  .header-title {
    font-size: 0.88rem;
  }

  .hero h1 {
    font-size: 1.4rem;
  }

  .hero-subtitle {
    font-size: 0.95rem;
  }

  section h2 {
    font-size: 1.3rem;
  }

  .color-legend {
    flex-direction: column;
    gap: 0.6rem;
  }

  .malverzacija {
    padding: 1rem;
  }

  .main-content {
    padding: 0 1rem 3rem;
  }
}
