// Copyright 2015-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

html {
  height: 100%;
  cursor: inherit;
}

body {
  position: relative;
  height: 100%;
  width: 100%;
  margin: 0;

  color: $color-gray-90;

  @include font-body-1;

  // These should match the logic in `ts/types/Settings.ts`'s `getTitleBarVisibility`.
  //
  // It'd be great if we could use the `:fullscreen` selector here, but that does not seem
  //   to work with Electron, at least on macOS.
  --title-bar-drag-area-height: 0px; // Needs to have a unit to work with `calc()`.
  --draggable-app-region: initial;
  &.os-macos:not(.full-screen) {
    --title-bar-drag-area-height: 28px;
    --draggable-app-region: drag;
  }

  &.light-theme {
    background-color: $color-white;
    color: $color-gray-90;
  }
  &.dark-theme {
    background-color: $color-gray-95;
    color: $color-gray-05;
  }

  &.is-resizing-left-pane {
    cursor: col-resize;
  }
}

::-webkit-scrollbar {
  // For vertical scrollbars
  width: 9px;
  // For horizontal scrollbars
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  @include light-theme {
    background: $color-gray-25;
    border: 2px solid $color-white;
  }
  @include dark-theme {
    background: $color-gray-45;
    border: 2px solid $color-gray-90;
  }

  &:hover {
    @include light-theme {
      background: $color-gray-45;
    }
    @include dark-theme {
      background: $color-gray-25;
    }
  }
}

::-webkit-scrollbar-corner {
  @include light-theme {
    background: $color-white;
  }
  @include dark-theme {
    background: $color-black;
  }
}

audio {
  max-width: 100%;
}

.dark-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;

  opacity: 0.25;
  z-index: $z-index-popup-overlay;

  @include light-theme {
    background-color: $color-black;
  }
  @include dark-theme {
    background-color: $color-gray-95;
  }
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: ' ';
}
.clearfix:after {
  clear: both;
}

.hide {
  display: none;
}

button {
  cursor: pointer;
  font-size: inherit;
}
button.grey {
  border-radius: 5px;
  border: solid 1px $color-gray-25;
  cursor: pointer;
  margin: 1em auto;
  padding: 1em;
  font-family: inherit;

  @include light-theme {
    color: $color-gray-60;
    background: $color-gray-02;
    box-shadow: 0 0 10px -5px $color-black-alpha-40;
  }
  @include dark-theme {
    border: solid 1px $color-gray-25;
    color: $color-gray-60;
    background: $color-gray-02;
    box-shadow: 0 0 10px -5px $color-white-alpha-60;
  }

  &:hover {
    @include light-theme {
      box-shadow: 0 0 10px -3px $color-black-alpha-60;
    }
    @include dark-theme {
      box-shadow: 0 0 10px -3px $color-white-alpha-80;
    }
  }

  &[disabled='disabled'] {
    &,
    &:hover {
      opacity: 0.5;
      box-shadow: none;
      cursor: default;
    }
  }
}

a {
  @include light-theme {
    color: $color-ultramarine;
  }

  @include dark-theme {
    color: $color-gray-05;
  }
}

.group-member-list {
  .container {
    outline: none;
  }
}

$loading-height: 16px;

.loading {
  position: relative;
  &::before {
    display: block;
    margin: 0px auto;
    content: ' ';
    height: $loading-height;
    width: $loading-height;
    border-radius: 2 * $loading-height;
    animation: rotate 1s linear infinite;

    border: solid 3px;
    border-color: $color-ios-blue-tint $color-ios-blue-tint $color-gray-02
      $color-gray-02 !important;
  }
}

.x {
  display: inline-block;
  float: right;
  cursor: pointer;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  padding: 3px;
  background: $color-gray-60;

  &:before {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    @include color-svg('../images/icons/v2/x-24.svg', $color-white);
  }
}

@keyframes loading {
  50% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.app-migration-screen {
  display: flex;
  flex-direction: column;
}

.app-loading-screen {
  z-index: $z-index-on-top-of-everything;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: $color-ultramarine-icon;
  color: $color-white;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  user-select: none;

  .content {
    text-align: center;
  }
  .container {
    margin-left: auto;
    margin-right: auto;
    width: 78px;
    height: 22px;
  }
  .message {
    max-width: 35em;
    margin-left: auto;
    margin-right: auto;
  }

  .dot {
    width: 14px;
    height: 14px;
    border: 3px solid $color-white;
    border-radius: 50%;
    float: left;
    margin: 0 6px;
    transform: scale(0);

    animation: loading 1500ms ease infinite 0ms;
    &:nth-child(2) {
      animation: loading 1500ms ease infinite 333ms;
    }
    &:nth-child(3) {
      animation: loading 1500ms ease infinite 666ms;
    }
  }
}

.full-screen-flow {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;

  &.overlay {
    z-index: $z-index-popup-overlay;
  }

  color: $color-black;
  a {
    color: $color-ultramarine;
  }
  background: linear-gradient(
    to bottom,
    /* (1 - 0.41) * 255 + 0.41 * 213*/ rgb(238, 238, 238) 0%,
    /* (1 - 0.19) * 255 + 0.19 * 191*/ rgb(243, 243, 243) 12%,
    rgb(255, 255, 255) 27%,
    rgb(255, 255, 255) 60%,
    /* (1 - 0.19) * 255 + 0.19 * 222*/ rgb(249, 249, 249) 85%,
    /* (1 - 0.27) * 255 + 0.27 * 98 */ rgb(213, 213, 213) 100%
  );
  display: flex;
  align-items: center;
  text-align: center;

  font-size: 10pt;
  input {
    margin-top: 1em;
    font-size: 12pt;
    border: 2px solid $color-ultramarine;
    padding: 0.5em;
    text-align: center;
    width: 20em;
  }

  @media (min-height: 750px) and (min-width: 700px) {
    font-size: 14pt;

    input {
      font-size: 16pt;
    }
  }

  .header {
    font-weight: normal;
    line-height: 1em;
    margin-bottom: 1.5em;

    font-size: 20pt;

    @media (min-height: 750px) and (min-width: 700px) {
      font-size: 28pt;
    }
  }

  .body-text {
    max-width: 22em;
    text-align: left;
    margin-left: auto;
    margin-right: auto;
  }
  .body-text-wide {
    max-width: 30em;
    text-align: left;
    margin-left: auto;
    margin-right: auto;
  }

  form {
    height: 100%;
    width: 100%;
  }
  .step {
    height: 100%;
    width: 100%;
    padding: 70px 0 50px;
  }
  .step-body {
    margin-left: auto;
    margin-right: auto;
    max-width: 35em;
  }

  .inner {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    height: 100%;
  }

  .banner-image {
    margin: 1em;
    display: none;

    @media (min-height: 550px) {
      display: inline-block;
      height: 10em;
      width: 10em;
    }
  }

  .banner-icon {
    display: none;
    margin: 1em;

    // 640px by 338px is the smallest the window can go
    @media (min-height: 550px) {
      display: inline-block;
      height: 10em;
      width: 10em;
    }

    // generic
    &.check-circle-outline {
      @include color-svg(
        '../images/full-screen-flow/check-circle-outline.svg',
        $color-gray-15
      );
    }
    &.alert-outline {
      @include color-svg(
        '../images/full-screen-flow/alert-outline.svg',
        $color-gray-15
      );
    }

    // import and export
    &.folder-outline {
      @include color-svg(
        '../images/full-screen-flow/folder-outline.svg',
        $color-gray-15
      );
    }
    &.import {
      @include color-svg(
        '../images/full-screen-flow/import.svg',
        $color-gray-15
      );
    }

    // registration process
    &.lead-pencil {
      @include color-svg(
        '../images/full-screen-flow/lead-pencil.svg',
        $color-gray-15
      );
    }
    &.sync {
      @include color-svg('../images/full-screen-flow/sync.svg', $color-gray-15);
    }

    // delete
    &.alert-outline-red {
      @include color-svg(
        '../images/full-screen-flow/alert-outline.svg',
        $color-accent-red
      );
    }
    &.delete {
      @include color-svg(
        '../images/full-screen-flow/delete.svg',
        $color-gray-15
      );
    }
  }

  .button {
    cursor: pointer;
    display: inline-block;
    border: none;
    min-width: 300px;
    padding: 0.75em;
    margin-top: 1em;
    margin-left: 0.5em;
    margin-right: 0.5em;
    color: $color-white;
    background: $color-ultramarine;
    box-shadow: 2px 2px 4px $color-black-alpha-40;

    font-size: 12pt;

    &.neutral {
      color: $color-black;
      background: $color-gray-15;
    }
    &.destructive {
      background: $color-accent-red;
    }

    @media (min-height: 750px) and (min-width: 700px) {
      font-size: 20pt;
    }

    &:disabled {
      background-color: $color-gray-20;
      cursor: auto;
    }
  }

  button.link {
    @include button-reset;

    display: block;
    margin: 0.5em auto;
    text-align: center;
    text-decoration: underline;
    color: $color-ultramarine;

    &:disabled {
      color: $color-gray-20;
      cursor: auto;
    }
  }

  a.link {
    display: block;
    cursor: pointer;
    text-decoration: underline;
    margin: 0.5em;
    color: $color-ultramarine;
  }

  .progress {
    text-align: center;
    padding: 1em;
    width: 80%;
    margin: auto;

    .bar-container {
      height: 1em;
      margin: 1em;
      background-color: $color-gray-02;
    }
    .bar {
      width: 100%;
      height: 100%;
      background-color: $color-ios-blue-tint;
      transition: width 0.25s;
      box-shadow: 2px 2px 4px $color-black-alpha-40;
    }
  }

  .nav {
    width: 100%;
    bottom: 50px;
    margin-top: auto;
    padding-bottom: 2em;
    padding-left: 20px;
    padding-right: 20px;

    .instructions {
      text-align: left;
      margin-left: auto;
      margin-right: auto;
      margin-bottom: 2em;
      margin-top: 2em;
      max-width: 30em;
    }
    .instructions:after {
      clear: both;
    }
    .android {
      float: left;
    }
    .apple {
      float: right;
    }
    .label {
      float: left;
    }
    .body {
      float: left;
    }
  }
}

//yellow border fix
.inbox:focus {
  outline: none;
}

.inbox {
  position: relative;
}

.overflow-hidden {
  overflow: hidden;
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}
