/*= Bookmark Menu - Layout ===================================================*/
/* #goPopup(Legacy of historyMenuPopup), #historyMenuPopup, #bookmarksMenuPopup: looks like global menu
   * #BMB_bookmarksPopup: looks like arrow panel
   */

/* Empty Menu */
menupopup menupopup[emptyplacesresult] .menu-text,
#PersonalToolbar menupopup[emptyplacesresult] .menu-text {
  margin-inline-start: 0 !important;
}

/* Bookmark Popup - As Arrow Panel */
#BMB_bookmarksPopup,
#PersonalToolbar {
  --context-menu-background-padding: var(--arrowpanel-menuitem-padding-inline);
}

//-- Mixin ---------------------------------------------------------------------
// Items
$_bookmarkMenuitem: "menuitem:not(.menuitem-iconic, [disabled=\"true\"])";
$_bookmarkMenu: "menu:not(.menu-iconic)";

// Components
$_bookmarkPopup: "menupopup:is(#BMB_bookmarksPopup)[placespopup=\"true\"]";
$_bookmarkToolbar: "#PersonalToolbar menupopup[placespopup=\"true\"]";

$_bookmarkPopupMenus: selector.nest(
  $_bookmarkPopup,
  "#{$_bookmarkMenuitem}, #{$_bookmarkMenu}"
);
$_bookmarkToolbarMenus: selector.nest(
  $_bookmarkToolbar,
  "#{$_bookmarkMenuitem}, #{$_bookmarkMenu}"
);

@mixin _layoutBookmarkMenu() {
  #{$_bookmarkPopupMenus},
  #{$_bookmarkToolbarMenus} {
    @content;
  }
}
@mixin _layoutBookmarkPopup() {
  #{$_bookmarkPopupMenus} {
    @content;
  }
}
@mixin _layoutBookmarkToolbar() {
  #{$_bookmarkToolbarMenus} {
    @content;
  }
}

//------------------------------------------------------------------------------

/* Windows */
@include OS($win) {
  /* Bookmark Popup - None icon menu */
  @include _layoutBookmarkMenu() {
    margin-inline: var(--arrowpanel-menuitem-margin-inline) !important;
    padding-inline-start: var(--bookmark-menu-icon-text-padding) !important;
    background-position: var(--uc-menu-background-position) var(--bookmark-menu-icon-background-padding) center !important;
  }
}

/* Windows 7, 8 */
@include OS($win7, $win8) {
  /* Global Menu */
  menupopup:is(#goPopup, #historyMenuPopup, #bookmarksMenuPopup) .bookmark-item {
    padding-inline-start: 0 !important;
  }
}

/* Linux */
@include OS($linux) {
  /* Global Menu */
  menupopup:is(#goPopup, #historyMenuPopup, #bookmarksMenuPopup) .bookmark-item {
    padding-inline-start: var(--context-menu-background-padding) !important;
  }

  /* Bookmark Popup - Iconic menu */
  #BMB_bookmarksPopup .menu-iconic-text,
  #PersonalToolbar menupopup[placespopup="true"] .bookmark-item .menu-iconic-text {
    margin-inline-start: -1px !important;
  }
  /* Bookmark Popup - None icon menu */
  @include _layoutBookmarkMenu() {
    padding-inline-start: calc(var(--context-menu-background-padding) + 2px) !important;
    @include Option("userChrome.theme.non_native_menu") {
      margin-inline: var(--arrowpanel-menuitem-margin-inline) !important;
    }

    .menu-text {
      margin-inline-start: var(--context-menu-text-padding) !important;
    }
  }
}

@include OS($mac) {
  /* Bookmark Popup - As Arrow Panel */
  #PersonalToolbar menupopup menuitem,
  #PersonalToolbar menupopup menu {
    padding-inline: var(--arrowpanel-menuitem-padding-inline) !important;
  }

  /* Bookmark Popup - None icon menu */
  @include _layoutBookmarkPopup() {
    padding-inline-start: calc(var(--arrowpanel-menuitem-padding-inline) + 3px) !important;
  }
  @include _layoutBookmarkToolbar() {
    padding-inline-start: calc(var(--arrowpanel-menuitem-padding-inline) + 1px) !important;
  }
  @include _layoutBookmarkMenu() {
    > .menu-text {
      padding-inline-start: var(--context-menu-mac-padding) !important;
    }
  }
}
