// Variables
$button-hover-background: rgba(255, 255, 255, 0.2);
$primary-text-color: rgba(255, 255, 255, 0.9);
$secondary-text-color: rgba(255, 255, 255, 0.6);

// Mixins
@mixin flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@mixin flex-gap($gap) {
  display: flex;
  gap: $gap;
}

@mixin button {
  background: none;
  border: none;
  cursor: pointer;
}

@mixin icon-button {
  @include button;

  display: flex;
  color: white;
  font-size: 20px;

  & > svg {
    margin: auto;
  }
}

@mixin pill($bg, $fg, $border, $hover-bg, $hover-border) {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 6px;
  background: $bg;
  color: $fg;
  border: 1px solid $border;
  font-weight: 600;
  font-size: 12px;
  user-select: none;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  gap: 4px;

  &:hover {
    background: $hover-bg;
    border-color: $hover-border;
  }

  &.disabled {
    opacity: 0.6;
    cursor: default;
    pointer-events: none;
  }

  svg {
    width: 12px;
  }
}

.extensions-bar-container {
  margin-left: auto;
  margin-right: 0.5rem;
  -webkit-app-region: no-drag;

  * {
    -webkit-app-region: no-drag;
  }

  .ModalDialogBody & {
    margin-right: 1rem;
  }

  .extensions-bar {
    @include flex-gap(2px);
    border-radius: 1rem;
    border: 1px solid transparent;
    transition: border 0.2s ease;

    &:hover {
      border: 1px solid gray;
    }
  }

  .extension-button {
    @include button;

    width: 31px;
    min-width: unset !important;
    height: 31px;
    min-height: unset !important;
    padding: 7px;
    border-radius: 50%;
    position: relative;
    transition: background 0.2s ease;

    &:hover {
      background: $button-hover-background;
    }

    img {
      width: 100%;
      height: 100%;
    }

    svg {
      display: block !important;
    }

    .update-dot {
      position: absolute;
      top: 3px;
      right: 3px;
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #53e582;
      border: 1px solid rgba(83, 229, 130, 0.7);
      box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
      pointer-events: none;
    }
  }
}


//#region extension-manager
$text-color: white;
$secondary-text-color: rgb(196, 199, 197);

$card-width: 400px;
$max-columns: 3;
$grid-gutter: 12px;

.extension-manager-popup {
  margin-top: 3rem;
  user-select: text;
}

.span-icon {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  justify-content: center !important;
}

.root-buttons {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, 400px);

  * {
    box-sizing: border-box !important;
  }
}

.card-container {
  display: grid;
  gap: $grid-gutter;
  grid-template-columns: repeat(auto-fill, $card-width);
  max-width: calc($card-width * $max-columns + $grid-gutter * $max-columns);
  margin: 2rem auto;
  font-size: 13px;
}

.extension-card {
  border-radius: 8px;
  background-color: #292a2d;
  background-color: hsla(0, 0%, 100%, 0.05);
  display: flex;
  flex-direction: column;
  height: 180px;
}

.extension-main {
  display: flex;
  padding: 16px 20px;
  flex: 1 1 0%;
  min-height: 0px;

  .icon {
    align-self: flex-start;
    display: flex;
    padding: 6px;
    position: relative;
    flex-direction: column;
    gap: 8px;

    img {
      height: 36px;
      width: 36px;
    }

    svg {
      margin: auto;
    }

    .update-badge {
      position: absolute;
      top: -6px;
      right: -6px;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: rgba(83, 229, 130, 0.15);
      border: 1px solid rgba(83, 229, 130, 0.4);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;

      svg {
        color: #53e582;
        width: 14px;
        height: 14px;
      }

      &:hover {
        background: rgba(83, 229, 130, 0.25);
        border-color: rgba(83, 229, 130, 0.6);
        transform: translateY(-1px);
      }

      &.disabled {
        opacity: 0.6;
        cursor: default;
        pointer-events: none;
      }
    }
  }

  .content {
    display: flex;
    flex-direction: column;
    margin-left: 24px;
    overflow: hidden;

    .name-and-version {
      color: $text-color;
      margin-bottom: 4px;
      display: flex;
      align-items: center;
      gap: 6px;

      .name {
        margin-right: 8px;
      }

      .version {
        margin-right: 4px;
      }

      .update-pill {
        @include pill(
          rgba(83, 229, 130, 0.12),
          #c7f5dd,
          rgba(83, 229, 130, 0.3),
          rgba(83, 229, 130, 0.2),
          rgba(83, 229, 130, 0.5)
        );
      }

      .warn-pill {
        @include pill(
          rgba(255, 188, 66, 0.12),
          #ffe3b0,
          rgba(255, 188, 66, 0.3),
          rgba(255, 188, 66, 0.2),
          rgba(255, 188, 66, 0.5)
        );
      }
    }

    .description {
      overflow: hidden;
      text-overflow: ellipsis;
      height: 100%;
    }
  }
}

#errors {
  li {
    font-size: 75%;
  }
}

.layout-horizontal-center {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.secondary-text {
  font-weight: 400;
  color: $secondary-text-color;
}

.extension-buttons {
  flex-shrink: 0;
  height: 48px;
  padding: 8px 20px;
  display: flex;
  flex-direction: row;
  gap: 8px;

  button {
    flex: 1 1 0%;
    border-radius: 50px;

    &::before {
      box-shadow: none !important;
    }
  }

  & >:last-child {
    margin: auto 0;
    margin-left: 60px;
  }
}

.md-button {
  @include icon-button;

  transition: background 0.2s ease;
  border-radius: 100px;
  width: 32px;
  height: 32px;

  &:hover {
    background: $button-hover-background;
  }
}

.extension-detail-info {
  width: 680px;
  box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
  margin: auto;

  .page-header {
    display: flex;
    align-items: center;
    height: 40px;
    margin-bottom: 12px;
    padding: 8px 12px 0px;
    color: $primary-text-color;

    & > img {
      margin-inline: 16px 12px;
      height: 24px;
      width: 24px;
    }

    & > span {
      flex-grow: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      font-size: 107%;
      font-weight: 500;
    }
  }

  .section {
    padding: 12px 20px;

    .heading {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .content {
      color: $secondary-text-color;
      display: flex;
      flex-direction: column;
    }
  }

  ul {
    margin: 0px;
    padding-inline-start: 20px;
  }

  a {
    color: rgb(168, 199, 250);
  }

  .fs-85 {
    font-size: 85%;
  }

  .clickable-row {
    @include flex-between;
    cursor: pointer;
    transition: background 0.2s ease;

    &:hover {
      background: $button-hover-background;
    }

    & > button {
      @include icon-button;
    }
  }

}

.hr {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

//#endregion

.storage-manager {
  color: $primary-text-color;
  .storage-manager-row {
    @include flex-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);

    button {
      @include icon-button;
      cursor: pointer;
      align-self: flex-start;
      height: 34px;
      width: 34px;
      padding: 5px;
    }
  }

  .storage-manager-item {
    width: 100%;
    padding: 5px 0;

    &:not(:has(> details[open])) {
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
  }

  .header {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: white;

    h1 {
      margin: 0;
    }
  }

}
$externalLinksDefaultBackground: rgba(255, 255, 255, 0.04);

.styled-input {
  width: 100%;
  height: 100%;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: $externalLinksDefaultBackground;
  color: inherit;
  box-sizing: border-box;

  &:focus {
    outline: none;
    border-color: #5aa9ff;
    box-shadow: 0 0 0 2px rgba(90, 169, 255, 0.25);
  }
}

.ext-links-manager {
  display: flex;
  flex-direction: column;
  gap: 8px;

  * {
    box-sizing: border-box;
  }

  .ext-links-title {
    font-weight: 600;
  }

  .ext-links-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .ext-links-row {
    display: grid;
    grid-template-columns: 1fr auto auto; // input, regex toggle, remove button
    gap: 8px;
    align-items: center;
  }

  .ext-links-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: $externalLinksDefaultBackground;
    color: inherit;
    height: 100%;
    cursor: pointer;
    user-select: none;

    input[type='checkbox'] {
      -webkit-appearance: none;
      appearance: none;
      width: 16px;
      height: 16px;
      border: 1px solid rgba(255, 255, 255, 0.25);
      border-radius: 3px;
      background: rgba(255, 255, 255, 0.06);
      display: inline-grid;
      place-content: center;
      cursor: pointer;
    }

    input[type='checkbox']::after {
      content: '';
      width: 10px;
      height: 10px;
      transform: scale(0);
      transition: transform 0.12s ease;
      background: #5aa9ff;
      border-radius: 2px;
    }

    input[type='checkbox']:checked::after {
      transform: scale(1);
    }

    span {
      font-size: 12px;
    }

    &:hover {
      background: rgba(255, 255, 255, 0.08);
    }
  }

  .ext-links-remove,
  .ext-links-add {
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: $externalLinksDefaultBackground;
    color: inherit;
    cursor: pointer;
    height: 100%;

    &:hover {
      background: rgba(255, 255, 255, 0.08);
    }
  }

  .ext-links-empty {
    opacity: 0.7;
    font-style: italic;
  }

  .ext-links-actions {
    margin-top: 4px;
  }
}