/**
 * The following styles get applied both on the front of your site
 * and in the editor.
 */

.wp-block-documentation {
  width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  position: relative;

  .documentation-layout {
    display: flex;
    max-width: 1700px;
    width: 100%;
    margin: 0 auto;
    background: var(--orphic-wp-block-plugin-color-background);
    position: relative;
    
    .documentation-nav {
      position: sticky;
      top: var(--wp-admin--admin-bar--height, 0px);
      align-self: flex-start;
      height: 100vh;
      max-height: 100vh;
      display: flex;
      flex-direction: column;
      overflow-y: auto;
      background: var(--orphic-wp-block-plugin-color-background);
      width: 250px;
      flex-shrink: 0;
      gap: var(--orphic-wp-block-spacing-md);

      .documentation-search-bar {
        margin-top: 20px;
        display: flex;
        align-items: center;
        justify-content: start;
        gap: var(--orphic-wp-block-spacing-sm);
        border-radius: var(--orphic-wp-block-border-radius-md);
        padding: var(--orphic-wp-block-spacing-sm);
        background: var(--orphic-wp-block-plugin-color-section-background);
        border: var(--orphic-wp-block-border-width-thin) solid var(--orphic-wp-block-plugin-color-background);
        
        & svg {
          width: 12px;
          height: 12px;
          color: var(--orphic-wp-block-plugin-color-text);
          opacity: 0.72;
        }

        & span {
          font-size: var(--orphic-wp-block-font-size-xs);
          font-weight: var(--orphic-wp-block-font-weight-medium);
          color: var(--orphic-wp-block-plugin-color-text);
          opacity: 0.72;
        }
      }

      .documentation-sections {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: var(--orphic-wp-block-spacing-sm);
        margin-bottom: 20px;
        background: var(--orphic-wp-block-plugin-color-section-background);
        padding: var(--orphic-wp-block-spacing-sm);
        border-radius: var(--orphic-wp-block-border-radius-md);
        border: var(--orphic-wp-block-border-width-thin) solid var(--orphic-wp-block-plugin-color-border);
        overflow-y: auto;
      }
      
      /* Scrollbar styling */
      &::-webkit-scrollbar {
        width: 6px;
      }
      
      &::-webkit-scrollbar-track {
        background: transparent;
      }
      
      &::-webkit-scrollbar-thumb {
        background-color: var(--orphic-wp-block-plugin-color-border);
        border-radius: var(--orphic-wp-block-border-radius-sm);
      }
      
      .nav-section {
        background: var(--orphic-wp-block-plugin-color-section-background-hover);
        border-radius: var(--orphic-wp-block-border-radius-sm);
        border: var(--orphic-wp-block-border-width-thin) solid transparent;
        will-change: transform;
        
        .section-header {
          display: flex;
          align-items: center;
          gap: var(--orphic-wp-block-spacing-sm);
          padding: var(--orphic-wp-block-spacing-lg) var(--orphic-wp-block-spacing-md);
          cursor: pointer;
          user-select: none;
          
          svg {
            width: 18px;
            height: 18px;
            fill: currentColor;
            flex-shrink: 0;
          }
          
          h3 {
            flex: 1;
            margin: 0;
            font-size: var(--orphic-wp-block-font-size-md);
            font-weight: var(--orphic-wp-block-font-weight-semibold);
            color: var(--orphic-wp-block-plugin-color-text);
          }
          
          .chevron-icon {
            width: 20px;
            height: 20px;
            fill: currentColor;
            flex-shrink: 0;
            transform-origin: center;
            transition: transform 300ms cubic-bezier(0.4, 0.0, 0.2, 1);
          }
        }
        
        .section-content {
          overflow: hidden;
          
          nav {
            padding: 0 var(--orphic-wp-block-spacing-md) var(--orphic-wp-block-spacing-md) var(--orphic-wp-block-spacing-md);
            transform: translateY(-10px);
            opacity: 0;
            pointer-events: none;
            transition: transform 300ms cubic-bezier(0.4, 0.0, 0.2, 1),
                        opacity 300ms cubic-bezier(0.4, 0.0, 0.2, 1);
          }
        }
        
        &.open {
          .section-header {
            .chevron-icon {
              transform: rotate(180deg);
            }
          }
          
          .section-content nav {
            transform: translateY(0);
            opacity: 1;
            pointer-events: all;
          }
        }
        
        .nav-item {
          display: flex;
          align-items: center;
          gap: var(--orphic-wp-block-spacing-sm);
          padding: var(--orphic-wp-block-spacing-sm) 0;
          margin-bottom: var(--orphic-wp-block-spacing-sm);
          cursor: pointer;
          border-radius: var(--orphic-wp-block-border-radius-sm);
          color: var(--orphic-wp-block-plugin-color-text);
          font-size: var(--orphic-wp-block-font-size-xs);
          font-weight: var(--orphic-wp-block-font-weight-medium);
          text-decoration: none;
          outline: none;
          
          transition: color 200ms ease-out;
          
          &:hover {
            color: var(--orphic-wp-block-plugin-color-primary);

            svg {
              fill: var(--orphic-wp-block-plugin-color-primary);
            }
          }
          
          &.active {
            background: var(--orphic-wp-block-plugin-color-primary);
            color: var(--orphic-wp-block-plugin-color-background);
          }

          svg {
            width: 6px;
            height: 6px;
            fill: var(--orphic-wp-block-plugin-color-text);
            transition: fill var(--orphic-wp-block-duration-fast) var(--orphic-wp-block-ease-default);
          }
        }
      }
    }
    
    .documentation-content {
      position: relative;
      overflow-y: auto;
      padding: var(--orphic-wp-block-spacing-xl);
      background: var(--orphic-wp-block-plugin-color-background);
      flex: 1;
      height: auto;
      min-height: 300px;
      
      /* Scrollbar styling */
      &::-webkit-scrollbar {
        width: 6px;
      }
      
      &::-webkit-scrollbar-track {
        background: transparent;
      }
      
      &::-webkit-scrollbar-thumb {
        background-color: var(--orphic-wp-block-plugin-color-border);
        border-radius: var(--orphic-wp-block-border-radius-sm);
      }
      
      > * {
        max-width: 100%;
      }
      
      h1, h2, h3, h4, h5, h6 {
        margin-bottom: var(--orphic-wp-block-spacing-md);
        scroll-margin-top: var(--orphic-wp-block-spacing-xl);
        color: var(--orphic-wp-block-plugin-color-text);
        outline: none;
      }
      
      p {
        line-height: 1.6;
        margin-bottom: var(--orphic-wp-block-spacing-md);
        color: var(--orphic-wp-block-plugin-color-text);
      }

      img {
        height: auto;
        border-radius: var(--orphic-wp-block-border-radius-md);
      }

      pre {
        overflow-x: auto;
        background: var(--orphic-wp-block-plugin-color-section-background);
        padding: var(--orphic-wp-block-spacing-md);
        border-radius: var(--orphic-wp-block-border-radius-md);
        border: var(--orphic-wp-block-border-width-thin) solid var(--orphic-wp-block-plugin-color-border);
      }
    }
    
    .documentation-toc {
      position: sticky;
      top: var(--wp-admin--admin-bar--height, 0px);
      align-self: flex-start;
      height: 100vh;
      max-height: 100vh;
      padding: var(--orphic-wp-block-spacing-lg);
      background: var(--orphic-wp-block-plugin-color-background);
      width: 250px;
      flex-shrink: 0;
      overflow-y: auto;
      
      h3 {
        font-size: var(--orphic-wp-block-font-size-lg);
        margin-bottom: var(--orphic-wp-block-spacing-md);
        color: var(--orphic-wp-block-plugin-color-text);
        position: sticky;
        top: 0;
        background: var(--orphic-wp-block-plugin-color-background);
        padding: var(--orphic-wp-block-spacing-sm) 0;
        z-index: 1;
        font-weight: var(--orphic-wp-block-font-weight-semibold);
      }
      
      .toc-content {
        font-size: var(--orphic-wp-block-font-size-sm);
        display: flex;
        flex-direction: column;
        gap: var(--orphic-wp-block-spacing-sm);
        /* Scrollbar styling */
        &::-webkit-scrollbar {
          width: 6px;
        }
        
        &::-webkit-scrollbar-track {
          background: transparent;
        }
        
        &::-webkit-scrollbar-thumb {
          background-color: var(--orphic-wp-block-plugin-color-border);
          border-radius: var(--orphic-wp-block-border-radius-sm);
        }
        
        a {
          display: block;
          padding: var(--orphic-wp-block-spacing-sm) var(--orphic-wp-block-spacing-md);
          color: var(--orphic-wp-block-plugin-color-text);
          text-decoration: none;
          transition: all var(--orphic-wp-block-duration-fast) var(--orphic-wp-block-ease-default);
          border-radius: var(--orphic-wp-block-border-radius-sm);
          border: var(--orphic-wp-block-border-width-thin) solid transparent;
          font-weight: var(--orphic-wp-block-font-weight-medium);
          outline: none;
          
          &:hover {
            background: var(--orphic-wp-block-plugin-color-section-background);
            color: var(--orphic-wp-block-plugin-color-primary);
          }

          &.active {
            background: var(--orphic-wp-block-plugin-color-primary);
            color: var(--orphic-wp-block-plugin-color-background);
            border-color: var(--orphic-wp-block-plugin-color-primary);
          }
        }
      }
    }
  }
}

// Support pour la barre d'administration WordPress
.admin-bar {
  .wp-block-documentation {
    .documentation-nav,
    .documentation-toc {
      height: calc(100vh - 32px);
      max-height: calc(100vh - 32px);
      top: 32px;
    }
  
    @media screen and (max-width: 782px) {
      .documentation-nav,
      .documentation-toc {
        height: calc(100vh - 46px);
        max-height: calc(100vh - 46px);
        top: 46px;
      }
    }
  }
}

@media (max-width: 1200px) {
  .wp-block-documentation .documentation-layout {
    .documentation-nav,
    .documentation-toc {
      width: 200px;
    }
  }
}

@media (max-width: 1024px) {
  .wp-block-documentation .documentation-layout {
    .documentation-toc {
      display: none;
    }
  }
}

@media (max-width: 768px) {
  .wp-block-documentation .documentation-layout {
    .documentation-nav {
      display: none;
    }

    .documentation-content {
      padding: var(--orphic-wp-block-spacing-md);
    }
  }
}

/* Mobile Navigation Button */
.documentation-nav-toggle {
  display: none;
  position: fixed;
  bottom: var(--orphic-wp-block-spacing-lg);
  right: var(--orphic-wp-block-spacing-lg);
  width: 56px;
  height: 56px;
  border-radius: var(--orphic-wp-block-border-radius-full);
  background: var(--orphic-wp-block-plugin-color-primary);
  color: var(--orphic-wp-block-plugin-color-background);
  border: none;
  cursor: pointer;
  z-index: 1000;
  box-shadow: var(--orphic-wp-block-shadow-md);
  transition: all var(--orphic-wp-block-duration-fast) var(--orphic-wp-block-ease-default);
  align-items: center;
  justify-content: center;

  svg {
    width: 24px;
    height: 24px;
    transition: transform var(--orphic-wp-block-duration-fast) var(--orphic-wp-block-ease-default);
  }

  &.active svg {
    transform: rotate(90deg);
  }
}

/* Mobile Navigation Panel */
.documentation-nav-mobile {
  display: none;
  position: fixed;
  box-sizing: border-box;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: var(--orphic-wp-block-plugin-color-background);
  z-index: 999;
  transform: translateX(-100%);
  transition: transform var(--orphic-wp-block-duration-normal) var(--orphic-wp-block-ease-default);
  overflow-y: auto;
  padding: var(--orphic-wp-block-spacing-lg);

  &.active {
    transform: translateX(0);
  }

  .nav-section {
    margin-bottom: var(--orphic-wp-block-spacing-xl);
    background: var(--orphic-wp-block-plugin-color-section-background);
    border-radius: var(--orphic-wp-block-border-radius-md);
    padding: var(--orphic-wp-block-spacing-md);

    h3 {
      display: flex;
      align-items: center;
      font-size: var(--orphic-wp-block-font-size-lg);
      margin-bottom: var(--orphic-wp-block-spacing-md);
      color: var(--orphic-wp-block-plugin-color-text);
      font-weight: var(--orphic-wp-block-font-weight-semibold);
      display: flex;
      align-items: center;
      gap: var(--orphic-wp-block-spacing-sm);

      svg {
        width: 16px;
        height: 16px;
        fill: currentColor;
      }
    }

    .nav-item {
      padding: var(--orphic-wp-block-spacing-sm) var(--orphic-wp-block-spacing-lg);
      margin-bottom: var(--orphic-wp-block-spacing-sm);
      cursor: pointer;
      border-radius: var(--orphic-wp-block-border-radius-sm);
      color: var(--orphic-wp-block-plugin-color-text);
      font-size: var(--orphic-wp-block-font-size-sm);
      font-weight: var(--orphic-wp-block-font-weight-medium);
      text-decoration: none;
      display: block;
      transition: all var(--orphic-wp-block-duration-fast) var(--orphic-wp-block-ease-default);
      outline: none;

      &:hover {
        background: var(--orphic-wp-block-plugin-color-section-background-hover);
        color: var(--orphic-wp-block-plugin-color-primary);
      }

      &.active {
        background: var(--orphic-wp-block-plugin-color-primary);
        color: var(--orphic-wp-block-plugin-color-background);
      }
    }
  }
}

@media (max-width: 768px) {
  .documentation-nav-toggle {
    display: flex;
  }

  .documentation-nav-mobile {
    display: block;
  }

  .wp-block-documentation .documentation-layout {
    .documentation-nav {
      display: none;
    }

    .documentation-content {
      padding: var(--orphic-wp-block-spacing-md);
    }
  }
}
