/* ═══════════════════════════════════════════════════════
   sidebar.css — Stats Sidebar untuk halaman Aksara
   punyahanif.id
═══════════════════════════════════════════════════════ */

/* ── SIDEBAR WRAPPER ── */
.stats-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 42px;
  background: #ffffff;
  border-left: 2px solid var(--border);
  box-shadow: -4px 0 16px rgba(18, 32, 92, 0.08);
  z-index: 200;
  overflow: hidden;
  transition: width 0.38s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.stats-sidebar.expanded { width: 210px; }

.ssb-inner {
  width: 210px;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: 60px;
}

/* ── HEADER ── */
.ssb-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  margin-bottom: 14px;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.stats-sidebar.expanded .ssb-header { opacity: 1; transition: opacity 0.2s 0.15s; }

.ssb-header-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
}

.ssb-header-line { flex: 1; height: 1px; background: var(--border); }

/* ── SCROLL AREA ── */
.ssb-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.ssb-scroll::-webkit-scrollbar { display: none; }

.ssb-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 6px;
}

/* ── ITEMS ── */
.ssb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: default;
  transition: background 0.15s;
  white-space: nowrap;
  position: relative;
}

.ssb-item--drill            { cursor: pointer; }
.ssb-item--drill:hover      { background: rgba(18, 32, 92, 0.05); }
.ssb-item.open              { background: rgba(18, 32, 92, 0.06); }

.ssb-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.ssb-text {
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.15s;
  min-width: 0;
  flex: 1;
}

.stats-sidebar.expanded .ssb-text { opacity: 1; transition: opacity 0.15s 0.12s; }

.ssb-label {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
}

.ssb-num {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
  font-family: 'Lora', serif;
}

.ssb-num-collapsed {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  transition: opacity 0.15s;
  pointer-events: none;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Lora', serif;
}

.stats-sidebar.expanded .ssb-num-collapsed { opacity: 0; }

.ssb-arrow {
  color: var(--border);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.15s, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
  font-family: 'DM Sans', sans-serif;
}

.stats-sidebar.expanded .ssb-arrow      { opacity: 1; }
.ssb-item.open .ssb-arrow               { transform: rotate(90deg); color: var(--primary); }

.ssb-divider { height: 1px; background: var(--border); margin: 3px 6px; }

/* ── DRILL PANEL ── */
.ssb-drill {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.36s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s;
}

.ssb-drill.open { max-height: 300px; opacity: 1; }

.ssb-drill-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 6px 6px;
}

.ssb-drill-empty {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 9px;
  font-family: 'DM Sans', sans-serif;
}

.ssb-drill-entry {
  border-radius: 8px;
  border-left: 2px solid transparent;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  padding: 7px 9px;
}

.ssb-drill-entry:hover {
  background: white;
  border-left-color: var(--primary);
  transform: translateX(2px);
}

.ssb-drill-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
  font-family: 'DM Sans', sans-serif;
  white-space: normal;
}

.ssb-drill-meta {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: 'DM Sans', sans-serif;
}

.ssb-drill-quote {
  font-size: 11px;
  font-style: italic;
  color: var(--text-main);
  line-height: 1.45;
  font-family: 'Lora', serif;
  white-space: normal;
}

.ssb-drill-bar {
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 5px;
}

.ssb-drill-fill {
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── FOOTER ── */
.ssb-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 34px;
}

.ssb-foot-collapsed {
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  transition: opacity 0.15s;
  font-family: 'DM Sans', sans-serif;
}

.stats-sidebar.expanded .ssb-foot-collapsed { opacity: 0; }

.ssb-foot-expanded {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s 0.1s;
  position: absolute;
  font-family: 'DM Sans', sans-serif;
}

.stats-sidebar.expanded .ssb-foot-expanded { opacity: 1; }

/* ── AKSARA MAIN — ruang untuk sidebar ── */
.aksara-main,
.page-main {
  padding-right: 50px;
  transition: padding-right 0.38s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

body:has(.stats-sidebar.expanded) .aksara-main,
body:has(.stats-sidebar.expanded) .page-main {
  padding-right: 210px;
}

.global-nav { padding-right: 58px !important; }

/* ── DARK MODE ── */
body.dark .stats-sidebar {
  background: #1e293b;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.3);
}

body.dark .ssb-drill-entry       { background: rgba(255, 255, 255, 0.05); }
body.dark .ssb-drill-entry:hover { background: rgba(255, 255, 255, 0.1); }

/* ── SIDEBAR EXPANDED LEBIH LEBAR ── */
.stats-sidebar.expanded { width: 260px; }

/* Override ssb-inner width */
.ssb-inner { width: 260px; }

/* ── DRILL QUOTE ENTRY ── */
.ssb-drill-entry--quote {
  position: relative;
  padding-right: 28px;
}

.ssb-drill-meta--quote {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 4px;
}

.ssb-drill-book {
  font-size: 9px;
  font-weight: 700;
  color: var(--primary);
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ssb-drill-chapter {
  font-size: 9px;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
}

/* Tombol hapus quote di sidebar */
.ssb-drill-del {
  position: absolute;
  top: 7px;
  right: 6px;
  background: none;
  border: none;
  color: #ccc;
  font-size: 9px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.ssb-drill-del:hover {
  color: #e24a4a;
  background: rgba(226, 74, 74, 0.08);
}

/* Fix: sidebar tidak ikut scroll halaman */
.stats-sidebar {
  position: fixed !important;
  overflow: hidden;
}

/* Scroll hanya di dalam ssb-scroll */
.ssb-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* ── CLEAR QUOTES BUTTON ── */
.ssb-clear-quotes {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  opacity: 0.4;
  margin-left: 6px;
  padding: 2px 4px;
  border-radius: 4px;
  vertical-align: middle;
  transition: opacity 0.15s;
}
.ssb-clear-quotes:hover { opacity: 1; }
