/* 浮动目录样式 - 参考网站样式 */
:root {
  --ftwp-bg-color: rgba(40, 40, 40, 0.95);
  --ftwp-text-color: rgba(255, 255, 255, 0.9);
  --ftwp-border-color: rgba(255, 255, 255, 0.2);
  --ftwp-hover-bg: rgba(58, 123, 213, 0.2);
  --ftwp-active-bg: rgba(58, 123, 213, 0.4);
  --ftwp-primary-color: #3a7bd5;
}

:root:not(.dark) {
  --ftwp-bg-color: rgba(245, 245, 245, 0.95);
  --ftwp-text-color: rgba(0, 0, 0, 0.8);
  --ftwp-border-color: rgba(0, 0, 0, 0.15);
  --ftwp-hover-bg: rgba(58, 123, 213, 0.1);
  --ftwp-active-bg: rgba(58, 123, 213, 0.2);
}

/* 浮动目录容器 */
.floating-toc-container {
  position: fixed;
  right: -280px;
  top: 50%;
  transform: translateY(-50%);
  width: 280px;
  max-height: 70vh;
  background-color: var(--ftwp-bg-color);
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
  border-radius: 8px 0 0 8px;
  transition: right 0.3s ease, opacity 0.3s ease;
  z-index: 1000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
}

/* 打开时的位置 */
.floating-toc-container.open {
  right: 0;
  opacity: 1;
  pointer-events: auto;
}

/* 目录头部 */
.floating-toc-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ftwp-border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--ftwp-hover-bg);
  flex-shrink: 0;
}

.floating-toc-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ftwp-text-color);
  margin: 0;
}

/* 关闭按钮 */
.floating-toc-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ftwp-text-color);
  opacity: 0.7;
  transition: opacity 0.2s ease, transform 0.2s ease;
  border-radius: 4px;
}

.floating-toc-close:hover {
  opacity: 1;
  background-color: var(--ftwp-hover-bg);
  transform: rotate(90deg);
}

.floating-toc-close svg {
  width: 16px;
  height: 16px;
}

/* 目录内容区域 */
.floating-toc-content {
  padding: 12px 16px;
  overflow-y: auto;
  flex-grow: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) rgba(0, 0, 0, 0.1);
}

/* 自定义滚动条 */
.floating-toc-content::-webkit-scrollbar {
  width: 6px;
}

.floating-toc-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

.floating-toc-content::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

:root:not(.dark) .floating-toc-content::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
}

/* 重置按钮样式 */
.toc-reset-button {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  padding: 6px;
  background-color: var(--ftwp-hover-bg);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--ftwp-border-color);
}

.toc-reset-button:hover {
  background-color: var(--ftwp-active-bg);
}

.toc-reset-button svg {
  color: var(--ftwp-text-color);
  opacity: 0.8;
}

.toc-reset-button:hover svg {
  opacity: 1;
}

.toc-button-active {
  background-color: var(--ftwp-active-bg) !important;
}

/* 目录链接样式 */
.floating-toc-content nav ul {
  list-style-type: none;
  padding-left: 0;
  margin: 0;
}

.floating-toc-content nav > ul {
  margin-left: 0;
}

.floating-toc-content nav ul li {
  padding: 4px 0;
  margin-bottom: 4px;
  position: relative;
}

.floating-toc-content nav ul ul {
  padding-left: 16px;
  margin-top: 4px;
  position: relative;
}

.floating-toc-content nav ul ul::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: var(--ftwp-border-color);
}

.floating-toc-content nav ul li a {
  color: var(--ftwp-text-color);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  display: inline-block;
  width: 100%;
  padding: 4px 8px;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  line-height: 1.5;
}

.floating-toc-content nav ul li a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--ftwp-primary-color);
  transition: width 0.2s ease;
}

.floating-toc-content nav ul li a:hover {
  color: var(--ftwp-text-color);
  background-color: var(--ftwp-hover-bg);
}

.floating-toc-content nav ul li a:hover::after {
  width: 100%;
}

.floating-toc-content nav ul li a.active {
  color: var(--ftwp-text-color);
  background-color: var(--ftwp-active-bg);
  font-weight: 500;
  border-left: 2px solid var(--ftwp-primary-color);
  padding-left: 10px;
}

/* 触发按钮样式 - 参考网站样式 */
.ftwp-trigger {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 50px;
  background-color: var(--ftwp-primary-color);
  border: 2px solid var(--ftwp-border-color);
  border-right: none;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  transition: all 0.3s ease;
  z-index: 1001;
  padding: 0;
  margin: 0;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.2);
}

/* 圆角样式 */
.ftwp-shape-round {
  border-radius: 8px 0 0 8px;
}

/* 边框样式 */
.ftwp-border-medium {
  border-width: 2px;
}

/* 右侧居中定位 */
.ftwp-transform-right-center {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

/* 淡入淡出效果 */
.ftwp-fade-trigger {
  opacity: 0.9;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.ftwp-fade-trigger:hover {
  opacity: 1;
  transform: translateY(-50%) scale(1.05);
}

/* 目录打开时移动按钮 */
.floating-toc-container.open ~ .ftwp-trigger {
  right: 280px;
}

/* 触发图标 */
.ftwp-trigger-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: currentColor;
}

/* 列表图标样式 */
.ftwp-icon-list {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  transition: transform 0.3s ease;
}

/* 目录打开时旋转图标 */
.floating-toc-container.open ~ .ftwp-trigger .ftwp-icon-list {
  transform: rotate(90deg);
}

/* 数字图标样式（已弃用，保留用于兼容） */
.ftwp-icon-number {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
}

/* 箭头图标样式（备用） */
.ftwp-icon-arrow {
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease;
}

.floating-toc-container.open ~ .ftwp-trigger .ftwp-icon-arrow {
  transform: rotate(180deg);
}

/* 响应式调整 */
@media (max-width: 768px) {
  .floating-toc-container {
    width: 240px;
    max-height: 60vh;
    right: -240px;
  }
  
  .floating-toc-container.open ~ .ftwp-trigger {
    right: 240px;
  }
  
  .ftwp-trigger {
    width: 35px;
    height: 45px;
  }
  
  .floating-toc-header {
    padding: 10px 12px;
  }
  
  .floating-toc-title {
    font-size: 0.9rem;
  }
  
  .floating-toc-content {
    padding: 10px 12px;
  }
  
  .floating-toc-content nav ul li a {
    font-size: 0.8rem;
  }
}

@media (max-width: 576px) {
  .floating-toc-container {
    max-height: 50vh;
    width: 200px;
    right: -200px;
  }
  
  .floating-toc-container.open ~ .ftwp-trigger {
    right: 200px;
  }
  
  .ftwp-trigger {
    width: 30px;
    height: 40px;
  }
  
  .ftwp-icon-number {
    font-size: 0.85rem;
  }
}

/* 亮色模式适配 */
:root:not(.dark) .ftwp-trigger {
  background-color: var(--ftwp-primary-color);
  color: #fff;
  border-color: rgba(0, 0, 0, 0.15);
}

:root:not(.dark) .floating-toc-container {
  background-color: var(--ftwp-bg-color);
  color: #333;
}

:root:not(.dark) .floating-toc-header {
  border-bottom-color: var(--ftwp-border-color);
  background-color: var(--ftwp-hover-bg);
}

:root:not(.dark) .floating-toc-title {
  color: var(--ftwp-text-color);
}

:root:not(.dark) .floating-toc-content nav ul li a {
  color: var(--ftwp-text-color);
}

:root:not(.dark) .floating-toc-content nav ul li a:hover,
:root:not(.dark) .floating-toc-content nav ul li a.active {
  color: var(--ftwp-text-color);
}

:root:not(.dark) .floating-toc-content nav ul ul::before {
  background-color: var(--ftwp-border-color);
}

:root:not(.dark) .floating-toc-close {
  color: var(--ftwp-text-color);
}
