/* just for downloads in the places organizer */

/* downloads panel and places organizer */
@-moz-document url("chrome://browser/content/browser.xhtml"), url-prefix("chrome://browser/content/places/places.xhtml"), url-prefix("about:downloads") {
  #downloadsPanel-mainView,
  #downloadsPanel-blockedSubview {
    min-width: revert !important;
    padding: 0 !important;
  }

  #downloadsListBox {
    border: none !important;
    padding: var(--uc-arrowpanel-menuitem-margin-inline) 0 !important;
  }

  panel #downloadsListBox {
    width: revert !important;
    min-width: 35em !important;
    max-width: 48em !important;
  }

  #emptyDownloads {
    padding-block: 1.25em !important;
    padding-inline: 16px 20px !important;
  }

  #downloadsFooter > stack {
    margin: 0 var(--uc-arrowpanel-menuitem-margin-inline) !important;
    padding-block: 0 var(--uc-arrowpanel-menuitem-margin-inline) !important;
  }

  #downloadsFooterButtons[uc-hbox]:not([hidden]) {
    display: flex !important;
    flex-flow: row nowrap;
    column-gap: var(--uc-arrowpanel-menuitem-margin-inline) !important;
  }

  #downloadsFooter > toolbarseparator,
  #downloadsFooterButtons > toolbarseparator {
    appearance: none !important;
    min-height: 0 !important;
    border-top: 1px solid var(--panel-separator-color) !important;
    border-bottom: none !important;
    margin: var(--panel-separator-margin) !important;
    margin-top: 0 !important;
    padding: 0 !important;
  }

  #downloadsFooterButtons > toolbarseparator {
    margin-inline: 0 !important;
  }

  #downloadsFooter[showingsummary] > toolbarseparator,
  #downloadsFooter:not([showingsummary]) #downloadsFooterButtons[uc-hbox] > toolbarseparator {
    display: none !important;
  }

  #downloadsFooterButtons > button {
    border-radius: var(--context-menuitem-border-radius) !important;
    min-height: var(--subviewbutton-height) !important;
    margin: 0 !important;
    flex-grow: 1;
    padding: 6px 8px !important;
    -moz-context-properties: fill, fill-opacity;
    fill: currentColor;
  }

  #downloadsFooterButtons > button > .button-box {
    display: flex !important;
    flex-flow: row nowrap;
    align-items: center;
  }

  #downloadsFooterButtons > button .button-icon {
    margin-inline: 0 6px;
    width: 16px;
    height: 16px;
  }

  #downloadsHistory {
    list-style-image: url(chrome://userchrome/content/skin/sort.svg);
  }

  #clearDownloadsPanel {
    list-style-image: url(chrome://userchrome/content/skin/close-window.svg);
  }

  #downloadsFooter[showingsummary] #downloadsFooterButtons {
    flex-direction: column !important;
    border-top: 0 !important;
  }

  richlistitem.download-state > toolbarseparator {
    visibility: collapse !important;
  }

  richlistitem.download-state,
  #downloadsSummary {
    position: relative !important;
    border-radius: var(--context-menuitem-border-radius) !important;
    padding: 0 !important;
    margin: 0 var(--uc-arrowpanel-menuitem-margin-inline) !important;
    border: 0 !important;
    outline: 0 !important;
    background: none !important;
  }

  #downloadsSummary {
    height: auto !important;
    min-height: auto !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 8px 4px !important;
    padding-inline-end: calc(4px + 8px + 8px + 32px) !important;
    gap: var(--uc-arrowpanel-menuitem-margin-inline) !important;
  }

  #downloadsPanel-blockedSubview > vbox {
    margin: 0 var(--uc-arrowpanel-menuitem-margin-inline) !important;
  }

  .downloadsPanel-blockedSubview-title-box {
    margin-block: 8px !important;
    min-height: 18px !important;
    align-items: center !important;
  }

  #downloadsPanel-blockedSubview-title {
    margin: 0 !important;
    order: 2 !important;
  }

  #downloadsPanel-blockedSubview[verdict="Insecure"] #downloadsPanel-blockedSubview-title,
  #downloadsPanel-blockedSubview[verdict="Malware"] #downloadsPanel-blockedSubview-title {
    color: var(--warning-text-color) !important;
  }

  #downloadsPanel-blockedSubview-details1,
  #downloadsPanel-blockedSubview-details2 {
    margin-bottom: 6px !important;
  }

  #downloadsPanel-blockedSubview > .panel-footer {
    margin: 12px !important;
  }

  #downloadsPanel-blockedSubview > #downloadsPanel-blockedSubview-buttons {
    margin-top: 8px !important;
  }

  .downloadsPanel-blockedSubview-image {
    width: 18px !important;
    height: 18px !important;
    background-size: contain !important;
    background-repeat: no-repeat;
    margin-inline: 6px 5px !important;
  }

  .downloadMainArea {
    border-radius: var(--context-menuitem-border-radius) !important;
  }

  richlistitem.download-state .downloadMainArea {
    padding: 8px 4px !important;
  }

  .downloadsPanelFooterButton:hover {
    outline: none !important;
  }

  panel richlistitem.download-state[state="1"]:not([exists]) :is(.downloadTarget, .downloadDetails) {
    color: var(--panel-disabled-color);
  }

  richlistitem.download-state[state="1"]:not([exists]) .downloadTypeIcon {
    opacity: 0.6;
  }

  panel richlistitem.download-state .downloadDetails,
  #downloadsSummaryDetails {
    opacity: 1 !important;
    color: var(--panel-description-color);
  }

  richlistitem.download-state > .downloadButton {
    height: auto !important;
    min-height: auto !important;
    width: auto !important;
    min-width: auto !important;
    box-sizing: content-box !important;
    margin: 0 !important;
    background: none !important;
    border: 0 !important;
    outline: none !important;
    border-radius: 0 !important;
    align-items: center !important;
    justify-items: center !important;
  }

  #downloadsListBox richlistitem.download-state > .downloadButton {
    padding: 8px !important;
  }

  richlistitem.download-state[state="1"][exists] .downloadMainArea:hover,
  richlistitem.download-state:not([verdict]) > .downloadButton:hover,
  richlistitem.download-state[verdict]:hover {
    background-color: unset !important;
  }

  richlistitem.download-state[state="1"][exists]:is(:hover, :focus-visible),
  richlistitem.download-state:is([verdict], .openWhenFinished):is(:hover, :focus-visible) {
    background: var(--download-button-hover-bg) !important;
  }

  richlistitem.download-state[state="1"][exists]:hover:active,
  richlistitem.download-state:is([verdict], .openWhenFinished):hover:active {
    background: var(--download-button-active-bg) !important;
  }

  #downloadsListBox > richlistitem.download-state.downloadHoveringButton[state="1"][exists]:hover,
  #downloadsListBox > richlistitem.download-state.downloadHoveringButton:is([verdict], .openWhenFinished):hover,
  richlistitem.download-state[state="1"][exists]:focus-within:not(:focus-visible),
  richlistitem.download-state:is([verdict], .openWhenFinished):focus-within:not(:focus-visible) {
    background: var(--download-button-focus-within-bg) !important;
  }

  richlistitem.download-state > .downloadButton:is(:hover, :focus-visible) .button-box {
    background: var(--uc-content-button-background-hover) !important;
  }

  richlistitem.download-state > .downloadButton:hover:active .button-box {
    background: var(--uc-content-button-background-active) !important;
  }

  #downloadsHistory:focus {
    background-color: revert;
  }

  #downloadsListBox:not([force-focus-visible]) .downloadsPanelFooterButton:focus-visible {
    outline: none;
  }

  #downloadsListBox > richlistitem[state="1"][exists].hoveringMainArea:hover,
  #downloadsListBox > richlistitem:is(.openWhenFinished).hoveringMainArea:hover,
  #downloadsListBox > richlistitem[verdict]:hover,
  #downloadsListBox > richlistitem:hover:is(.openWhenFinished),
  .downloadsPanelFooterButton:not([disabled]):hover,
  #downloadsHistory:not([disabled]):hover,
  #downloadsListBox:focus-visible > richlistitem[selected],
  #downloadsListBox[force-focus-visible]:focus > richlistitem[selected],
  #downloadsListBox[force-focus-visible] .downloadsPanelFooterButton:not([disabled]):focus-visible,
  #downloadsListBox[force-focus-visible] #downloadsListBox:focus-visible > richlistitem[selected],
  #downloadsListBox[force-focus-visible] #downloadsHistory:not([disabled]):focus-visible {
    background-color: var(--download-button-hover-bg) !important;
  }

  #downloadsListBox > richlistitem[state="1"][exists].hoveringMainArea:hover:active,
  #downloadsListBox > richlistitem:is(.openWhenFinished).hoveringMainArea:hover:active,
  #downloadsListBox > richlistitem[verdict]:hover:active,
  .downloadsPanelFooterButton:not([disabled]):is([open="true"], :hover:active),
  #downloadsHistory:not([disabled]):is([open], :hover:active) {
    background-color: var(--download-button-active-bg) !important;
  }

  #downloadsListBox richlistitem {
    color: inherit !important;
  }

  richlistitem.download-state > .downloadButton .button-box {
    width: 32px !important;
    height: 32px !important;
    border-radius: var(--context-menuitem-border-radius) !important;
    padding: 0 !important;
  }

  richlistitem.download-state > .downloadButton .button-box .button-icon {
    width: 18px !important;
    height: auto !important;
  }

  .downloadIconShow .button-box .button-icon {
    list-style-image: url(chrome://userchrome/content/material/places/folder.svg) !important;
  }

  @media (-moz-platform: macos) {
    .downloadIconShow .button-box .button-icon {
      list-style-image: url(chrome://userchrome/content/search-glass.svg) !important;
    }
  }

  .downloadIconCancel .button-box .button-icon {
    list-style-image: url(chrome://userchrome/content/close-big.svg) !important;
  }

  .downloadIconRetry .button-box .button-icon {
    list-style-image: url(chrome://userchrome/content/skin/reload.svg) !important;
  }

  .downloadIconSubviewArrow .button-box .button-icon {
    list-style-image: url(chrome://userchrome/content/arrow-left.svg) !important;
  }

  .downloadIconSubviewArrow > .button-box > .button-icon:-moz-locale-dir(ltr) {
    transform: scaleX(-1);
  }

  richlistitem.download-state > .downloadButton:is(.downloadIconCancel, .downloadIconSubviewArrow) .button-box .button-icon {
    width: 21px !important;
  }

  #downloadsSummaryDescription {
    color: inherit !important;
  }

  .downloadBlockedBadge {
    background-size: contain !important;
    width: 18px !important;
    height: 18px !important;
    margin-inline-end: 0 !important;
  }

  #downloadsPanel-blockedSubview[verdict="Insecure"] .downloadsPanel-blockedSubview-image,
  #downloadsPanel-blockedSubview[verdict="Malware"] .downloadsPanel-blockedSubview-image,
  #downloadsListBox > richlistitem[verdict="Insecure"] .downloadBlockedBadge,
  #downloadsListBox > richlistitem[verdict="Malware"] .downloadBlockedBadge {
    background-image: url(chrome://userchrome/content/error.svg) !important;
    fill: var(--warning-color) !important;
  }

  #downloadsPanel-blockedSubview[verdict="Uncommon"] .downloadsPanel-blockedSubview-image,
  #downloadsListBox > richlistitem[verdict="Uncommon"] .downloadBlockedBadge {
    background-image: url(chrome://userchrome/content/info-filled.svg) !important;
    fill: var(--purple-25) !important;
  }

  #downloadsPanel-blockedSubview[verdict="PotentiallyUnwanted"] .downloadsPanel-blockedSubview-image,
  #downloadsPanel-blockedSubview[verdict="DownloadSpam"] .downloadsPanel-blockedSubview-image,
  #downloadsListBox > richlistitem[verdict="PotentiallyUnwanted"] .downloadBlockedBadge,
  #downloadsListBox > richlistitem[verdict="DownloadSpam"] .downloadBlockedBadge {
    background-image: url(chrome://userchrome/content/warning-big.svg) !important;
    fill: var(--low-warning-icon-background) !important;
  }

  #downloadsListBox > richlistitem[verdict="Insecure"] .downloadDetails,
  #downloadsListBox > richlistitem[verdict="Malware"] .downloadDetails {
    color: var(--warning-text-color) !important;
  }

  .downloadContainer:not([hidden="true"]) {
    display: flex !important;
    flex-flow: column nowrap !important;
    row-gap: 4px !important;
    justify-content: center !important;
  }

  .downloadContainer > * {
    margin: 0 !important;
  }

  .downloadProgress {
    appearance: none !important;
    border: 1px solid transparent !important;
    border-radius: 14px !important;
    height: 7px !important;
    background-color: var(--arrowpanel-dimmed) !important;
    overflow: hidden !important;
  }

  .downloadProgress[paused] {
    background-color: var(--desaturate-dimmed) !important;
  }

  .downloadProgress::-moz-progress-bar {
    --download-progress-fill-color: inherit !important;
    --download-progress-flare-color: inherit !important;

    background-image: none !important;
    background-color: var(--download-progress-fill-color) !important;
  }

  .downloadProgress:not([value="0"])::-moz-progress-bar {
    margin: 0 !important;
    height: 100% !important;
    border-radius: 0 !important;
  }

  .downloadProgress:not(:indeterminate)::-moz-progress-bar {
    mask: linear-gradient(#fff, #fff), url(chrome://userchrome/content/layout/contentaccessible/progress-bar-mask.svg) center right/14px;
    mask-repeat: no-repeat;
    mask-composite: subtract;
    animation: none !important;
  }

  .downloadProgress:indeterminate::-moz-progress-bar {
    border-radius: 0 !important;
    background-image: linear-gradient(90deg, transparent 0%, var(--download-progress-flare-color) 25%, transparent 50%, var(--download-progress-flare-color) 75%, transparent 100%) !important;
  }

  .downloadProgress[paused]:indeterminate::-moz-progress-bar {
    background-color: transparent !important;
    background-image: none !important;
  }
}

/* downloads panel */
@-moz-document url("chrome://browser/content/browser.xhtml") {
  richlistitem.download-state:is([state="-1"], [state="5"], [state="0"], [state="4"], [state="7"]) .downloadMainArea {
    padding-block: 0 !important;

    .downloadContainer {
      row-gap: 3px !important;
    }
  }

  .downloadProgress {
    height: 2px !important;
  }
}

/* places organizer */
@-moz-document url-prefix("chrome://browser/content/places/places.xhtml"), url-prefix("about:downloads") {
  #downloadsListBox {
    border: none !important;
    outline: none !important;
    background: transparent !important;
  }

  #contentAreaDownloadsView {
    background: var(--in-content-bg-dark) !important;
  }

  richlistitem.download-state:is(:hover, :focus-visible),
  richlistitem.download-state[state="1"][exists]:is(:hover, :focus-visible),
  richlistitem.download-state:is([verdict], .openWhenFinished):is(:hover, :focus-visible),
  richlistitem.download-state[state="1"][exists]:hover:active,
  richlistitem.download-state:is([verdict], .openWhenFinished):hover:active {
    background: var(--uc-content-button-background-hover) !important;
  }

  richlistitem.download-state[state="1"][exists]:focus-within:not(:focus-visible),
  richlistitem.download-state:is([verdict], .openWhenFinished):focus-within:not(:focus-visible),
  richlistitem.download-state[selected]:not(:hover, :focus-visible, :focus-within) {
    background: var(--uc-content-button-background) !important;
  }

  richlistitem.download-state[state="1"]:not([exists]) .downloadTarget {
    color: var(--organizer-deemphasized-color);
  }

  richlistitem.download-state .downloadDetails {
    opacity: 1 !important;
    color: var(--organizer-deemphasized-color);
  }
}
