// Import reusable custom scrollbar module
@import '../../../style/module/simplebar-scrollbar';

// Consolidated shortcut styles (moved from source/style/module/_shortcut.scss)
// The widget is in a utility panel (see _utility-panel.scss). The search box stays at the top, and
// the lists below it scroll in the rest of the panel.
.short-cut {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  font-family: inherit;

  // The scroll area of the panel, so the scroll bar is on the edge of the panel. The SimpleBar
  // track is on the edge of this element, so the padding can be on this element. SimpleBar's
  // wrapper fills the rest of the panel, because it only scrolls when its height is limited.
  &__scroll-wrapper {
    @include utility-panel-scroll-area;

    display: flex;
    flex-direction: column;
    padding: 0 var(--sub-nav-padding) var(--sub-nav-padding);
    position: relative;

    .simplebar-wrapper {
      flex: 1 1 auto;
      min-height: 0;
    }

    // Apply custom scrollbar styling
    @extend .custom-scrollbar;
    
    // Disable horizontal scroll for shortcut widget
    .simplebar-track.simplebar-horizontal {
      display: none !important;
    }
    
    // Ensure vertical scroll is always visible when needed. The custom scroll bar puts the track
    // outside the element, in the middle of the padding around it. Here the padding is inside the
    // element, so the track goes in the middle of that padding. The rule must be !important, because
    // the rule in the custom scroll bar is !important.
    .simplebar-track.simplebar-vertical {
      opacity: 1 !important;
      right: calc(var(--sub-nav-padding) / 2 - 1px) !important;
    }
  }

  .short-cut .shortcut-fav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    background: none;
    border: none;
  }
    
  // Drag handle specific properties only (highest specificity to override all button rules)
  .sub-nav__user .drag-handle.icon-grip-dots-vertical.icon.icon--fixed-width {
    cursor: grab !important;
    padding: 0 !important; // Override any inherited padding for precise alignment
    margin-top: 0.25rem !important; // Ensure consistent alignment with thumbtack
    margin: 0.25rem -4px 0 0 !important; // Include right margin to align with search box
    
    &:hover {
      cursor: grab !important; // Keep grab cursor on hover
    }
  }

  .short-cut .shortcut-fav-btn,
    &:hover {
      color: filled('foreground-theme') !important;
    }

  /* Thumbtack active state styling */
.shortcut-fav-btn.icon-thumbtack.icon--active {
  color: color('foreground-theme') !important; // Try foreground-theme for darker appearance
  margin-top: 0.25rem !important; // Ensure consistent alignment
  
  &:hover {
    color: color('foreground-theme-hover') !important;
  }
  
  &::before {
    color: color('foreground-theme') !important;
    background-color: transparent !important;
  }
  
  &:hover::before {
    color: color('foreground-theme-hover') !important;
    background-color: transparent !important;
  }
}

/* Thumbtack inactive state styling (Add to favorites button) */
.shortcut-fav-btn.icon-thumbtack.icon.icon--fixed-width:not(.icon--active) {
  color: color('foreground-secondary') !important;
  margin-top: 0.25rem !important; // Ensure consistent alignment
  
  &:hover {
    color: var(--color-foreground-secondary) !important;
    
    &::before {
      font-weight: 900 !important; // Make it solid/filled on hover
    }
  }
}

  /* Drag handle styling */
  button.drag-handle {
    margin: 0.25rem -4px 0 0 !important;
  }

  .icon-grip-dots-vertical::before {
    content: "\e411";
    font-size: font-size(0);
  }

  /* The item wrapper keeps the outer layout but we align children to the top of the row */
  &__item-wrapper {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 8px;
    width: 100%;
  }


    &__link,
    .shortcut-link {
      color: inherit; 
      text-decoration: none;
      display: flex;
      flex-direction: column; // title above description
      width: 100%;
      flex: 1;

      &:hover,
      &:visited,
      &:active {
        color: inherit;
        text-decoration: none;
      }
    }

    &__description,
    .shortcut-description {
      margin: 0;
      font-size: font-size(-1);
      color: color('foreground-secondary');
    }

    /* Keep outer wrapper centered, but align row content to the title */
    .shortcut-row {
      display: flex;
      align-items: flex-start; /* align title and actions to top */
      gap: 8px;
      width: 100%;
    }
    .shortcut {
      padding: spacing(-1);
      box-shadow: $shadow-style-front color('shadow');
      @include set-colors('interactive');

      &:hover {
        background-color: color('interactive-hover');
        outline: none;
      }

      &:active {
        box-shadow: $shadow-style-back color('shadow');
        outline: none;
      }

      &--highlighted {
        @include set-colors('theme');

        &:hover {
          background-color: color('theme-hover');
        }
      }

      p {
        line-height: line-height('single');
        margin: 0;
      }
    }

/* Project-specific overrides for mitstudie */
.shortcut-link {
  text-size-adjust: 100%;
  width: auto;
  word-wrap: break-word;
  white-space: normal;
  display: block;
  flex: 1;
}

.shortcut-title {
  @include set-font(0, "single");
  color: color('foreground');
  font-weight: 400;
  margin: 0;
  padding: 0;
}

.shortcut-description {
  font-size: font-size(-1);
  font-weight: 400;
  color: color('foreground-secondary');
  margin: 0;
  padding: 0;
}

  // The favourites list shows the Delphinus empty state when there are no favourites. Its bottom
  // border is the rule above the next section, so it gets the space that the <hr> between the
  // sections has when there are favourites.
  &__list--favorites .empty-state {
    margin-bottom: spacing(-2);
  }
}