/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

body {
  display: flex;
  flex-direction: column;
  inset: 0;
  margin: 0;
  position: absolute;
}

browser {
  flex: 1;
}

#browser-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#header {
  align-items: center;
  background-color: var(--sidebar-background-color);
  border-bottom: 1px solid var(--in-content-border-color);
  display: flex;
  flex-direction: row;
  padding-inline: var(--space-large);

  ::part(button),
  select {
    border-radius: var(--border-radius-small);
    margin: 0;
  }

  moz-button:first-of-type {
    margin-inline-end: var(--space-xsmall);
  }

  select {
    --caret-anchor: left;
    --caret-padding: var(--space-xsmall);
    --end-padding: 0px;
    --start-padding: calc(var(--caret-padding) + var(--background-image-width) + var(--space-xsmall));
    background-color: var(--button-background-color-ghost);
    background-position-x: var(--caret-anchor) var(--caret-padding);
    color: var(--button-text-color-ghost);
    flex: 1;
    height: var(--button-size-icon);
    margin-block: var(--space-xsmall);

    &:hover {
      background-color: var(--button-background-color-ghost-hover);
      color: var(--button-text-color-ghost-hover);
    }

    &:dir(rtl) {
      --caret-anchor: right;
    }
  }

  /* Hide some content, e.g., dropdown, when onboarding exists */
  #multi-stage-message-root + & {
    select {
      background-image: none;
    }

    #header-more {
      display: none;
    }
  }
}

#header-close {
  position: relative;
  z-index: 1;

  /* stylelint-disable-next-line media-query-no-invalid */
  @media not -moz-pref("sidebar.revamp") {
    display: none;
  }
}

#multi-stage-message-root {
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  inset: 0;
  overflow: auto;
  position: absolute;

  .onboardingContainer {
    height: unset;
    margin: var(--space-large);
    margin-top: max(36px, 10vh - 31px);
  }

  .screen {
    border-radius: var(--border-radius-medium);
    min-height: unset;
  }

  .main-content {
    height: unset;
  }

  .main-content-inner {
    max-width: initial;
    padding: var(--space-large);
  }

  .welcome-text {
    margin-bottom: var(--space-xlarge);
    padding-inline: 0;
  }

  .tiles-single-select-container {
    margin-top: 0;

    /* stylelint-disable-next-line media-query-no-invalid */
    @media not -moz-pref("browser.ml.chat.onboarding.unresponsive") {
      --fade-height: 20px;
      --fade-padding: 8px;
      margin-block: calc(-1 * var(--fade-padding));
      max-height: max(144px, 100vh - 310px);
      overflow-y: auto;

      &::after,
      &::before {
        content: "\00a0";
        font-size: var(--fade-height);
        margin-top: calc(-1 * var(--fade-height) + var(--fade-padding));
        pointer-events: none;
        position: sticky;
        z-index: 1;
      }
      &::after {
        background: linear-gradient(transparent, var(--in-content-page-background));
        bottom: 0;
      }
      &::before {
        background: linear-gradient(var(--in-content-page-background), transparent);
        top: 0;
      }
    }
  }

  fieldset {
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
  }

  label {
    background-color: var(--background-color-box);
    border: 0.5px solid var(--border-color-deemphasized);
    border-radius: var(--border-radius-medium);
    flex-direction: row;
    margin: 1.5px; /* avoid shifting content when selected */
    outline-offset: var(--focus-outline-offset);
    padding: var(--space-small);

    &:hover {
      background-color: var(--button-background-color-hover);
    }

    &:has(.selected) {
      background-color: var(--background-color-canvas);
      border: var(--focus-outline);
      margin: 0; /* border switches widths */
    }

    &:focus {
      outline: var(--focus-outline);
    }
  }

  .icon {
    --icon-size: 30px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    border-radius: 0;
    height: var(--icon-size);
    margin-inline: var(--space-small);
    max-width: var(--icon-size);
    min-width: var(--icon-size);
    outline: none;

    &.claude {
      background-image: url(assets/brands/claude.svg);
    }
    &.chatgpt {
      background-image: url(assets/brands/chatgpt.svg);
      -moz-context-properties: fill;
      fill: var(--in-content-page-color);
    }
    &.copilot {
      background-image: url(assets/brands/copilot.svg);
    }
    &.gemini {
      background-image: url(assets/brands/gemini.svg);
    }
    &.huggingchat {
      background-image: url(assets/brands/huggingchat.svg);
    }
    &.lechat {
      background-image: url(assets/brands/lechat.svg);
    }
  }

  .text {
    flex-direction: column;
    font-weight: var(--font-weight-bold);
    margin: 5px;
    text-align: start;

    > div {
      color: var(--text-color-deemphasized);
      font-weight: normal;
      margin: -3px;
      overflow-y: hidden;
      padding: 3px; /* extra space to avoid outlines hidden by overflow */

      @media (prefers-reduced-motion: no-preference) {
        transition: max-height 0.6s;
      }
    }

    ul {
      margin: 0;
      padding: 0;
    }

    li {
      background-position: 0 50%;
      background-repeat: no-repeat;
      -moz-context-properties: fill;
      fill: currentColor;
      margin-block: var(--space-small);
      padding-inline-start: 24px;

      &[data-l10n-id*="generate"] {
        background-image: url(chrome://global/skin/icons/edit-outline.svg);
      }
      &[data-l10n-id*="analyze"] {
        background-image: url(chrome://global/skin/icons/eye.svg);
      }
      &[data-l10n-id*="switch"] {
        background-image: url(chrome://global/skin/icons/arrows-updown.svg);
      }
      &[data-l10n-id*="price"] {
        background-image: url(chrome://browser/skin/price.svg);
      }
    }
  }

  .link-paragraph {
    color: var(--text-color-deemphasized);
    font-size: 0.8em;
  }

  .inline-image {
    background-image: url(assets/shortcuts-static.svg);
    background-repeat: no-repeat;
    background-size: contain;

    @media (prefers-reduced-motion: no-preference) {
      background-image: url(assets/shortcuts-animated.svg);
    }

    @media (prefers-color-scheme: dark) {
      background-image: url(assets/shortcuts-static-dark.svg);

      @media (prefers-reduced-motion: no-preference) {
        background-image: url(assets/shortcuts-animated-dark.svg);
      }
    }

    > img {
      visibility: hidden;
    }
  }
}

#summarize-btn-container {
  border-top: 1px solid var(--in-content-border-color);
  padding: var(--space-large);
  position: relative;

  .badge {
    --badge-background-color-new: var(--color-green-40);

    background: var(--badge-background-color-new);
    border-radius: var(--border-radius-small);
    color: var(--button-text-color-primary-hover);
    font-size: var(--font-size-small);
    left: 10px;
    padding: var(--space-xxsmall) var(--space-small);
    position: absolute;
    text-align: center;
    top: 4px;
    z-index: 1;

    /* stylelint-disable-next-line media-query-no-invalid */
    @media not -moz-pref("browser.ml.chat.page.footerBadge") {
      display: none;
    }
  }

  /* stylelint-disable-next-line media-query-no-invalid */
  @media (not -moz-pref("browser.ml.chat.page")) or -moz-pref("browser.ml.chat.provider", "") {
    display: none;
  }

  /* Hide footer when onboarding exists */
  #multi-stage-message-root ~ & {
    display: none;
  }
}
