/* ==UserStyle==
 * @name            MaterialFox UPDATED Patch
 * @name:zh-CN      MaterialFox UPDATED 补丁
 * @description     修复 MaterialFox UPDATED 在  e3kskoy7wqk/Firefox-for-windows-7 上的一些小问题
 * @author          Ryan
 * @version         0.1.0
 * @compatibility   Firefox 121
 * @homepageURL     https://github.com/benzBrake/FirefoxCustomize
==/UserStyle== */
@-moz-document url-prefix("chrome://"), url-prefix("about:blank"), url-prefix("moz-extension://"), url-prefix("resource://"), url-prefix("data:text/html;charset=utf-8,chrome://"), url-prefix("data:text/html;charset=utf-8,about:blank"), url-prefix("data:text/html;charset=utf-8,moz-extension://"), url-prefix("data:text/html;charset=utf-8,resource://") {
  menuitem[checked=true]:not(:has(> .menu-icon)):not(:has(> .menu-iconic-left)):before {
    content: "" !important;
    display: block !important;
    height: 16px;
    width: 16px;
    margin-inline-end: 8px !important;
    background-image: var(--md-check-icon);
  }

  :is(#urlbar-input-container, .urlbar-input-container)>#location-bar .toolbarbutton-1 {
    --toolbarbutton-inner-padding: 3px 8px;
    width: 32px !important;

    &:has(>.toolbarbutton-icon) {
      --toolbarbutton-border-radius: 0;
      --urlbar-box-hover-bgcolor: var(--md-control-background-color)
    }
  }

  #zoom-controls[cui-areatype="toolbar"]>#zoom-reset-button>.toolbarbutton-text {
    padding-block: var(--toolbarbutton-inner-padding) !important
  }

  /** 扩展管理紧凑样式 */
  :is(#unified-extensions-area, .unified-extensions-list) .subviewbutton {
    margin-inline-start: 0 !important;
    margin-inline-end: 0 !important;
    padding-inline-start: 0 !important;
    padding-inline-end: 0 !important;
  }

  panelview#unified-extensions-view .toolbaritem-combined-buttons {
    height: 32px;
  }

  :is(#unified-extensions-area, .unified-extensions-list) .subviewbutton.unified-extensions-item-action-button {
    height: 32px;
    min-height: unset;
  }

  .unified-extensions-item-row-wrapper {
    align-items: center;
  }

  @media(-moz-platform: windows) {

    /* 修正菜单缩进、二级菜单指示器 */
    .menu-text {
      padding-inline-start: 0 !important;
    }

    .menu-right {
      appearance: none !important;
    }

    #firefoxbeta_tampermonkey_net-menuitem-_root :is(menu, menuitem)>.menu-text {
      transform: translateX(-24px);
    }

    menugroup > menuitem {
      min-height: 24px !important;
      max-height: 24px !important;
    }
  }


  @media (-moz-pref("userChrome.ui-chrome-refresh")) {
    .tab-background {
      padding: 3px 12px 0 !important;
    }

    #tabbrowser-tabs[orient="vertical"] {
      :root[uidensity="compact"] & {
        --tab-min-height: 32px !important;
      }

      :root[uidensity="touch"] & {
        --tab-min-height: 48px !important;
      }

      .tabbrowser-tab {
        padding-block: 0px !important;
      }

      .tabbrowser-tab[fadein]:not([pinned]):not([style*="max-width"]) {
        max-width: 100% !important;
      }

      & .tab-stack,
      & .tab-background {
        --tab-vertical-padding: 0px;
        padding-top: 0px !important;
        min-height: var(--tab-min-height) !important;
        max-height: var(--tab-min-height) !important;

        &:before,
        &:after {
          content: none !important;
        }
      }

      :root:not([expanded]) & .tab-background {
        width: calc(100% - 2 * var(--tab-horizontal-padding)) !important;
      }

      & .tabbrowser-tab:is([visuallyselected], [selected]) {
        &>.tab-stack>.tab-background {
          border-bottom-left-radius: 11px !important;
          border-bottom-right-radius: 11px !important;
        }
      }

      & .tab-content {

        &:before,
        &:after {
          content: none !important;
        }
      }


      #tabs-newtab-button {
        --tab-hover-background-color: transparent;
      }

      #tabbrowser-arrowscrollbox-periphery {
        margin-inline: var(--tab-horizontal-padding) !important;
        padding-inline: 0 !important;

        & #tabs-newtab-button {
          width: 100% !important;
          max-width: unset !important;
          min-width: unset !important;
          padding-inline: 0 !important;
          margin-inline: 0 !important;
          border-radius: 11px !important;
          justify-content: flex-start !important;
          --tab-icon-end-margin: 0;

          &:not([disabled]):hover {
            background-color: var(--md-tab-background-color-hover) !important;
          }

          & .toolbarbutton-icon {
            --md-tab-background-color-hover: transparent;
          }
        }
      }
    }

    #sidebar-main {
      &:not([sidebar-launcher-expanded]) {
        #vertical-tabs .tab-close-button {
          display: none !important;
        }
      }
    }

    #sidebar-box {
      @media -moz-pref("sidebar.revamp") {
        padding-block-end: 0 !important;
      }
    }
  }

  search-textbox {
    height: 29px;

    &+button {
      border-radius: 0 !important;
      height: 29px !important;
    }
  }
}

@-moz-document url-prefix("about:config") {

  :not(dialog, .dialogBox) :not(button-group)>button:is([accesskey], .accessory-button, [dlgtype="cancel"], [autofocus], [default], .primary, .primary-button, .popup-notification-primary-button, .disco-cta-button, [data-l10n-id="translations-manage-language-download-button"]):not(button[type="menu"]),
  :not(dialog, .dialogBox) :not(button-group)>button [type="submit"] {
    min-width: unset !important;
  }
}