html {
  overflow-y: scroll;
  overflow-x: hidden;
}

.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

.tabs > .tab {
  text-transform: none;
  letter-spacing: 0;
  float: left;
  padding: 10px 15px;
  margin: 0 4px 0 0;
  cursor: pointer;
  font-weight: bold;
  font-size: 13px;
  color: var(--body-quiet-color, #666);
  background: var(--darkened-bg, #f8f8f8);
  border: 1px solid var(--hairline-color, #e8e8e8);
  border-bottom: none;
  user-select: none;
}

.tabs > .active {
  background: var(--button-bg, #79aec8);
  color: white;
}

.tabs > .active:hover {
  background: var(--button-hover-bg, #609ab6);
}

.tabs > [data-region="_unknown_"],
.tabs > .has-error {
  border-color: var(--error-fg, #ba2121);
  color: var(--error-fg, #ba2121);
  background: var(--darkened-bg, #f8f8f8);
}

.order-machine-wrapper {
  --control-width: 220px;
  clear: both;
  display: grid;
  grid-template-columns: 1fr var(--control-width);
  transition: grid-template-columns 0.2s;
}

.order-machine-wrapper.collapsed {
  --control-width: 10px;
}

@media (min-width: 1024px) {
  .order-machine-wrapper.collapsed {
    --control-width: 0px;
  }
}

.order-machine {
  padding: 0 10px 10px 10px;
  border: 1px solid var(--hairline-color, #e8e8e8);
  position: relative;

  display: flex;
  flex-flow: column nowrap;
}

.order-machine .inline-related {
  border: 1px solid var(--hairline-color, #e8e8e8);
  border-bottom: 0;
  margin-top: 10px;
}

.order-machine .inline-related > h3 {
  border-top: none;
  font-size: 13px;
  font-weight: normal;
  height: 16px;
  padding: 7px;
  background-color: var(--darkened-bg, #f8f8f8);
  transition: 0.2s background, 0.2s color;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  display: flex;
  flex-flow: row nowrap;
  gap: 2px;
}

h3[draggable] {
  cursor: move;
}

.order-machine .inline-related > h3[draggable]::before {
  content: "drag_indicator";
  font-family: "Material Icons";
  font-size: 24px;
  position: relative;
  top: -6px;
  left: -2px;
}

.order-machine .inline-related > h3 > b,
.order-machine h3 .inline_label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.order-machine .inline-related > h3 > b {
  flex: 0 1 auto;
}

.order-machine h3 .inline_label {
  flex: 1 1 0px;
}

/* Replace the broken content type counter for new contents with a "new" label */
.order-machine .last-related .inline_label {
  content: "new";
}

.order-machine .inline-related fieldset {
  /* Animate out of view REAL FAST */
  transition: max-height 0.2s cubic-bezier(0, 1.05, 0, 1), background 0.2s,
    visibility 0.2s;
  max-height: 2000px;
  overflow: hidden;
  position: relative;
}

.order-machine .inline-related {
  transition: border 0.2s;
}

.order-machine .inline-related.selected > h3 {
  color: white;
  background-color: var(--button-bg, #79aec8);
}

.order-machine .inline-related.for-deletion fieldset,
.order-machine .inline-related.collapsed fieldset {
  max-height: 0;
  visibility: hidden;
}

.order-machine .inline-related.for-deletion > h3::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: var(--error-fg, #ba2121);
  opacity: 0.3;
  pointer-events: none;
}

.machine-message {
  margin: 1.5em 1em 1em;
  text-align: center;
}

.machine-control {
  border: 1px solid var(--hairline-color, #e8e8e8);
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
  background: var(--darkened-bg, #f8f8f8);
  position: sticky;
  top: 0;
  align-self: flex-start;

  width: 220px;
}

.plugin-buttons {
  border-top: 1px solid var(--hairline-color, #e8e8e8);
  margin-top: 8px;
}

.plugin-button {
  margin: 4px 4px;
  padding: 4px 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: 0.1s background;
  user-select: none;
}

.plugin-button.selected {
  background: var(--primary, #79aec8);
}

.plugin-button-icon {
  width: 32px;
}

.plugin-button-icon.missing::before {
  content: "?";
  padding-left: 8px;
}

.toggle-sidebar,
.collapse-items {
  cursor: pointer;
}

.toggle-sidebar .plugin-button-icon {
  transform-origin: 37% 50%;
  display: inline-block;
}

.order-machine-wrapper.collapsed .toggle-sidebar .plugin-button-icon {
  transform: scaleX(-1);
}

.order-machine-wrapper.collapsed .invisible-when-collapsed {
  opacity: 0;
}

.toggle-sidebar input,
.collapse-items input {
  display: none;
}

.collapse-items .uncollapse-all {
  display: none;
}
.collapse-items input:checked ~ .uncollapse-all {
  display: flex;
}
.collapse-items input:checked ~ .collapse-all {
  display: none;
}

.inline_move_to_region {
  border-color: var(--hairline-color, #e8e8e8);
  font-size: 11px;
  height: 22px;
  margin: -2px 8px -2px auto;
  padding: 0px 1px;
}

/* tabbed_fieldsets.js support */
#tabbed .tabs {
  border-bottom: 1px solid var(--hairline-color, #e8e8e8);
}

#tabbed .modules {
  margin-bottom: 30px;
}

#tabbed .module {
  border: 1px solid var(--hairline-color, #e8e8e8);
  border-top: none;
  margin-bottom: 0;
}

#tabbed .form-row:last-child {
  border: none;
}

.content-editor-hidden {
  /* We can't simply use display: none. Some admin widgets need to know
     * their dimensions, so we can't have that -- use an alternative way
     * to hide the modules. */
  visibility: hidden !important;
  height: 0 !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Used when dragging */
.placeholder {
  height: 34px;
  margin: 10px 0 0 0;
  border: none;
  opacity: 0.3;
  background: #79aec8;
}

.order-machine .inline-related {
  position: relative;
}

.order-machine-help {
  font-size: 11px;
  margin-top: -28px;
  margin-bottom: 30px;
}

.fs-dragging {
  opacity: 0.5;
}

.fs-dragover::before {
  content: " ";
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  height: 4px;
  background: #79aec8;
}

.fs-dragover::after {
  /* Cover fieldset with an overlay so that widgets do not swallow events */
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
}

.order-machine-insert-target {
  position: absolute;
  left: 48%;
  top: -0.9em;
  font-size: 1.5rem;
  width: 1.25em;
  height: 1.25em;
  line-height: 1.25em;
  border-radius: 99px;
  background: var(--button-bg, #79aec8);
  color: var(--button-fg, #fff);
  box-shadow: 0 0 3px 1px var(--button-fg);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}
.order-machine-insert-target.last {
  top: auto;
  bottom: -8px;
  left: calc(48% + 10px);
  z-index: 1;
}
.order-machine-insertion .order-machine-insert-target {
  opacity: 0.5;
  pointer-events: all;
  transition: opacity 0.1s;
}
.order-machine-insert-target:hover {
  opacity: 1;
  background: var(--button-hover-bg, #609ab6);
}
.order-machine-insert-target::before {
  content: "→";
  font-weight: bold;
}

@media screen and (max-width: 767px) {
  /* CSS fix for Django's responsive admin interface (shows fields below the
   * 767px breakpoint despite them being .hidden */
  html .aligned .form-row.hidden,
  .toggle-sidebar {
    display: none;
  }

  html .aligned .form-row > div {
    width: calc(100vw - 90px);
  }

  html .order-machine .form-row {
    padding: 10px;
  }

  .order-machine-wrapper {
    grid-template-columns: 1fr;
    grid-template-rows: min-content min-content;
  }

  .machine-control {
    width: auto;
  }
}

@media screen and (min-width: 768px) {
  .submit-row {
    position: sticky;
    bottom: -20px;
  }
}
