/* Modern nested CSS for Table of Content */

.mp-toc-container.table-of-content {
  width: 100%;

  & .head-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;

    & > div {
      font-weight: 600;
      font-size: 20px;
      line-height: 28px;
    }

    & .arrow {
      font-size: 18px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.3s ease;
    }
  }

  & .content-section {
    /* Optional thinner scrollbar */
    &::-webkit-scrollbar {
      width: 8px;
    }

    &::-webkit-scrollbar-thumb {
      background-color: rgba(0, 0, 0, 0.2);
      border-radius: 8px;
    }
  }

  & .list {
    display: flex;
    flex-direction: column;
    font-weight: 600;
    font-size: 14px;
    line-height: 20px;
  }

  & a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    gap: 8px;
    text-decoration: none !important;
    color: inherit;
    border-radius: 4px;

    &:hover {
      background-color: #f3f4f6;
    }
  }
}

/* Sticky mode */
.mp-toc-sticky {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9999;
  display: flex;
  gap: 8px;
  transition: all 0.5s ease-in-out;

  &.mp-toc-side-left {
    left: calc(-1 * min(90vw, 360px));
    flex-direction: row-reverse;

    &.is-open {
      left: 16px;
    }
  }

  &.mp-toc-side-right {
    right: calc(-1 * min(90vw, 360px));

    &.is-open {
      right: 16px;
    }
  }

  & .mp-toc-sticky-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 9999px;
    background-color: #ffffff;
    color: var(--accent-color, #1c274c);
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    background-image: url('../img/toc-icon.svg');
    background-size: 18px;
    background-position: center;
    background-repeat: no-repeat;
    transition: all 0.3s ease;
    &:hover {
      background-color: var(--accent-color, #1c274c);
      color: #ffffff;
      border: none;
    }
  }

  & .mp-toc-icon {
    width: 18px;
    height: 18px;
    position: relative;

    /* simple hamburger-like icon */
    &::before,
    &::after {
      content: '';
      position: absolute;
      left: 0;
      right: 0;
      height: 2px;
      background: currentColor;
    }

    &::before {
      top: 4px;
    }

    &::after {
      top: 12px;
    }
  }

  & .mp-toc-sticky-drawer {
    width: min(90vw, 360px);
    max-height: 80vh;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    border: 1px solid #e5e7eb;
  }

  /* Ensure internal TOC scrolls if long */
  & .table-of-content .content-section {
    max-height: 60vh;
    overflow: auto;
  }
}
