/* Smart Sidebar TOC – by Danial | v1.12.0 (Auto Side + Fade/Slide + Vertical toggle) */

/* ===== Floating Toggle (VERTICAL LABEL) ===== */
.toc-toggle {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(180deg, #0ea5e9, #0284c7);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  cursor: pointer;
  z-index: 99999;
  width: 46px;
  padding: 12px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  transition: background .25s ease, box-shadow .25s ease, transform .25s ease;
}
.toc-toggle .toc-toggle-text{
  writing-mode: vertical-rl;
  text-orientation: mixed;
  white-space: nowrap;
  line-height: 1.1;
  letter-spacing: 1px;
  color: #fff;
}
/* Auto side corners for toggle */
.toc-right { right: 0; border-radius: 8px 0 0 8px; }
.toc-left  { left: 0;  border-radius: 0 8px 8px 0; }

.toc-toggle:hover {
  background: linear-gradient(180deg, #0284c7, #0ea5e9);
  box-shadow: 0 0 18px rgba(14,165,233,0.65);
  transform: translateY(-50%) scale(1.03);
}

/* ===== Overlay ===== */
.toc-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 99990;
}
.toc-overlay.open { opacity: 1; pointer-events: auto; }

/* ===== Sidebar (Glass + Fade/Slide) ===== */
.toc-sidebar {
  position: fixed; top: 0;
  width: 350px; height: 100%;
  backdrop-filter: blur(14px);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 0 25px rgba(0,0,0,0.15);
  border-inline-start: 3px solid #0ea5e9;
  transition: transform 0.45s cubic-bezier(.22,.61,.36,1), opacity 0.3s ease;
  z-index: 100000;
  padding: 20px 16px;
  overflow-y: auto;
  opacity: 0; pointer-events: none;
  /* side + transform are set by JS to avoid RTL conflicts */
}
.toc-sidebar.open { opacity: 1; pointer-events: auto; }

/* ===== Header ===== */
.toc-header {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 2px solid #0ea5e9;
  padding-bottom: 10px; margin-bottom: 15px;
  font-weight: 700; font-size: 17px; color: #0f172a;
}
.toc-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #475569; transition: color .3s; }
.toc-close:hover { color: #0ea5e9; }

/* ===== Search ===== */
.toc-search { margin-bottom: 10px; }
#tocSearch { width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid #cbd5e1; outline: none; font-size: 14px; }
#tocSearch:focus { border-color: #0ea5e9; box-shadow: 0 0 5px rgba(14,165,233,0.3); }

/* ===== TOC List ===== */
.toc-list { list-style: none; padding: 0; margin: 0; }
.toc-list li { margin-bottom: 8px; }
.toc-list a {
  display: flex; align-items: center; gap: 6px;
  text-decoration: none; color: #0369a1; font-weight: 500;
  padding: 6px 8px; border-radius: 6px; transition: all 0.25s ease;
}
.toc-list a::before { content: "▸"; font-size: 12px; color: #0ea5e9; }
.toc-list a:hover { background: rgba(14,165,233,0.1); color: #0284c7; transform: translateX(-4px); }
.toc-list li.level-2 { margin-left: 5px; font-size: 15px; }
.toc-list li.level-3 { margin-left: 20px; font-size: 14px; }

/* ===== Active ===== */
.toc-list a.active {
  background: linear-gradient(90deg, #0ea5e9, #0284c7);
  color: #fff !important;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(14,165,233,0.4);
  transform: scale(1.02);
}

/* ===== Footer + Progress ===== */
.toc-footer { margin-top: 30px; border-top: 1px solid #bae6fd; padding-top: 15px; text-align: center; }
.toc-progress { width: 100%; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.toc-progress-bar { width: 0; height: 100%; background: linear-gradient(90deg,#0ea5e9,#0284c7); transition: width 0.3s ease; }
.toc-top { background: #0ea5e9; color: #fff; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.toc-top:hover { background: #0284c7; }

/* ===== Responsive ===== */
@media (max-width:768px){
  .toc-sidebar{width:85%}
  .toc-toggle{width:44px;font-size:13px;padding:10px 4px}
}

/* ===== Dark Mode ===== */
@media (prefers-color-scheme:dark){
  .toc-sidebar{background:rgba(30,41,59,0.88)}
  .toc-header{color:#e2e8f0;border-bottom-color:#38bdf8}
  #tocSearch{background:rgba(15,23,42,0.35);color:#e2e8f0;border-color:#334155}
  #tocSearch::placeholder{color:#94a3b8}
  .toc-list a{color:#93c5fd}
  .toc-list a::before{color:#38bdf8}
  .toc-footer{border-top-color:#334155}
  .toc-progress{background:#334155}
}
