/* ============================================================
   Flexible TOC — CSS
   5 style: modern, minimal, boxed, sidebar, dark
   ============================================================ */

/* ── CSS Variables ── */
:root {
  --ftoc-accent:       #2563eb;
  --ftoc-radius:       10px;
  --ftoc-transition:   0.22s ease;
  --ftoc-font:         inherit;
}

/* ── Base wrapper ── */
.ftoc-wrap {
  font-family: var(--ftoc-font);
  margin: 1.8em 0 2em;
  line-height: 1.5;
}

/* ── Header ── */
.ftoc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ftoc-title {
  font-size: 0.92em;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Toggle button ── */
.ftoc-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.78em;
  color: var(--ftoc-accent);
  padding: 2px 4px;
  border-radius: 4px;
  transition: background var(--ftoc-transition);
  font-family: inherit;
  white-space: nowrap;
}
.ftoc-toggle:hover { background: rgba(37,99,235,.08); }
.ftoc-toggle:focus-visible { outline: 2px solid var(--ftoc-accent); outline-offset: 2px; }

.ftoc-chevron {
  transition: transform var(--ftoc-transition);
  flex-shrink: 0;
}
.ftoc-collapsed .ftoc-chevron { transform: rotate(-90deg); }

/* ── List ── */
.ftoc-body {
  margin-top: 10px;
  overflow: hidden;
}
.ftoc-body[hidden] { display: none; }

.ftoc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ftoc-list-root { padding: 0; }
.ftoc-sublist { padding-left: 1.1em; margin-top: 2px; }

.ftoc-item {
  margin: 0;
  padding: 0;
}
.ftoc-item-empty { list-style: none; }

/* ── Links ── */
.ftoc-link {
  display: block;
  padding: 4px 6px;
  text-decoration: none;
  border-radius: 5px;
  font-size: 0.88em;
  transition: color var(--ftoc-transition), background var(--ftoc-transition), padding-left var(--ftoc-transition);
  color: inherit;
  opacity: 0.82;
}
.ftoc-link:hover {
  opacity: 1;
  color: var(--ftoc-accent);
  background: rgba(37,99,235,.06);
  padding-left: 10px;
}
.ftoc-link.ftoc-active {
  color: var(--ftoc-accent);
  font-weight: 600;
  opacity: 1;
}

/* ── Penomoran custom ── */
.ftoc-numbered .ftoc-list-root { counter-reset: ftoc-counter; }
.ftoc-numbered { counter-increment: ftoc-counter; }
.ftoc-numbered > .ftoc-link::before {
  content: counters(ftoc-counter, ".") ". ";
  font-variant-numeric: tabular-nums;
  color: var(--ftoc-accent);
  opacity: 0.7;
  font-size: 0.9em;
}

/* ================================================
   STYLE: MODERN (default)
   ================================================ */
.ftoc-style-modern {
  background: #f8faff;
  border: 1px solid #dde5f7;
  border-left: 4px solid var(--ftoc-accent);
  border-radius: var(--ftoc-radius);
  padding: 16px 20px 14px;
  max-width: 680px;
}
.ftoc-style-modern .ftoc-title { color: var(--ftoc-accent); }
.ftoc-style-modern .ftoc-body { border-top: 1px solid #dde5f7; padding-top: 10px; margin-top: 10px; }
.ftoc-style-modern .ftoc-link { color: #374151; }
.ftoc-style-modern .ftoc-link:hover { color: var(--ftoc-accent); background: rgba(37,99,235,.07); }
.ftoc-style-modern .ftoc-link.ftoc-active { color: var(--ftoc-accent); background: rgba(37,99,235,.10); }

/* ================================================
   STYLE: MINIMAL
   ================================================ */
.ftoc-style-minimal {
  border-left: 3px solid var(--ftoc-accent);
  padding: 0 0 0 16px;
  max-width: 560px;
}
.ftoc-style-minimal .ftoc-title { font-size: 0.78em; color: #9ca3af; margin-bottom: 8px; }
.ftoc-style-minimal .ftoc-header { margin-bottom: 6px; }
.ftoc-style-minimal .ftoc-link {
  padding: 3px 0;
  border-radius: 0;
  color: #6b7280;
  font-size: 0.86em;
}
.ftoc-style-minimal .ftoc-link:hover {
  color: var(--ftoc-accent);
  background: none;
  padding-left: 4px;
}
.ftoc-style-minimal .ftoc-link.ftoc-active { color: var(--ftoc-accent); font-weight: 600; }
.ftoc-style-minimal .ftoc-body { margin-top: 0; }

/* ================================================
   STYLE: BOXED
   ================================================ */
.ftoc-style-boxed {
  border: 2px solid var(--ftoc-accent);
  border-radius: var(--ftoc-radius);
  padding: 0;
  max-width: 660px;
  overflow: hidden;
}
.ftoc-style-boxed .ftoc-header {
  background: var(--ftoc-accent);
  color: #fff;
  padding: 12px 18px;
}
.ftoc-style-boxed .ftoc-title { color: #fff; }
.ftoc-style-boxed .ftoc-toggle { color: rgba(255,255,255,.85); }
.ftoc-style-boxed .ftoc-toggle:hover { background: rgba(0,0,0,.12); }
.ftoc-style-boxed .ftoc-body { padding: 14px 18px 12px; }
.ftoc-style-boxed .ftoc-link { color: #374151; font-size: 0.875em; }
.ftoc-style-boxed .ftoc-link:hover { color: var(--ftoc-accent); background: rgba(37,99,235,.07); }
.ftoc-style-boxed .ftoc-link.ftoc-active {
  color: var(--ftoc-accent);
  background: rgba(37,99,235,.08);
  font-weight: 600;
}

/* ================================================
   STYLE: SIDEBAR STRIP
   ================================================ */
.ftoc-style-sidebar {
  border-right: 3px solid var(--ftoc-accent);
  padding: 14px 20px 14px 0;
  max-width: 320px;
  float: right;
  margin: 0 0 1.5em 2em;
  background: #f8faff;
  border-radius: 8px 0 0 8px;
}
.ftoc-style-sidebar .ftoc-title { color: var(--ftoc-accent); font-size: 0.85em; }
.ftoc-style-sidebar .ftoc-body { margin-top: 8px; }
.ftoc-style-sidebar .ftoc-link { font-size: 0.83em; color: #4b5563; }
.ftoc-style-sidebar .ftoc-link:hover { color: var(--ftoc-accent); }
.ftoc-style-sidebar .ftoc-link.ftoc-active { color: var(--ftoc-accent); font-weight: 600; }

/* ================================================
   STYLE: DARK
   ================================================ */
.ftoc-style-dark {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--ftoc-radius);
  padding: 16px 20px 14px;
  max-width: 680px;
}
.ftoc-style-dark .ftoc-title { color: #93c5fd; }
.ftoc-style-dark .ftoc-header { border-bottom: 1px solid #334155; padding-bottom: 10px; margin-bottom: 0; }
.ftoc-style-dark .ftoc-body { padding-top: 10px; }
.ftoc-style-dark .ftoc-link { color: #cbd5e1; font-size: 0.88em; }
.ftoc-style-dark .ftoc-link:hover { color: #93c5fd; background: rgba(147,197,253,.08); }
.ftoc-style-dark .ftoc-link.ftoc-active { color: #60a5fa; font-weight: 600; background: rgba(96,165,250,.10); }
.ftoc-style-dark .ftoc-toggle { color: #93c5fd; }
.ftoc-style-dark .ftoc-toggle:hover { background: rgba(147,197,253,.10); }
.ftoc-style-dark .ftoc-numbered > .ftoc-link::before { color: #93c5fd; }

/* ── Level indentation ── */
.ftoc-level-2 > .ftoc-link { padding-left: 8px; }
.ftoc-level-3 > .ftoc-link { padding-left: 16px; font-size: 0.84em; }
.ftoc-level-4 > .ftoc-link { padding-left: 24px; font-size: 0.82em; }
.ftoc-level-5 > .ftoc-link { padding-left: 32px; font-size: 0.80em; }
.ftoc-level-6 > .ftoc-link { padding-left: 40px; font-size: 0.78em; }

/* ── Animate body open/close ── */
.ftoc-body-animate {
  animation: ftoc-slide-down 0.22s ease forwards;
}
@keyframes ftoc-slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .ftoc-style-sidebar {
    float: none;
    margin: 0 0 1.5em 0;
    border-radius: var(--ftoc-radius);
    border-right: none;
    border-left: 4px solid var(--ftoc-accent);
    padding: 14px 16px;
    max-width: 100%;
  }
  .ftoc-style-modern,
  .ftoc-style-boxed,
  .ftoc-style-dark { max-width: 100%; }
}

/* ── Print ── */
@media print {
  .ftoc-toggle { display: none; }
  .ftoc-body[hidden] { display: block !important; }
}
