// ****** Variables *****
$color-primary: #0c1c25;
$color-primary-inv: #ffffff;
$color-primary-light: #0b2d40;
$color-primary-disabled: #394a53;
$color-text: #0c1c25;
$color-text-inv: #ffffff;
$color-info: #aebef5;
$color-info-dark: #7381ad;
$color-warning: #f08046;
$color-warning-dark: #5f321b;
$color-warning-light: #eebca3;
$color-danger: #b8480e;
$color-danger-dark: #501f06;
$color-danger-light: #bb6b42;
$color-success: #2aa854;
$color-success-dark: #1c5e32;
$color-success-light: #46f07f;
$background-color: #ffffff;

$radius-default: 0.3em;
$button-radius: $radius-default;

$font-family: 'Prompt', Arial, Helvetica, sans-serif;
$font-size: 12pt;

$responsive-break-sm: 40em; // Small devices such as large phones (640px and up)
$responsive-break-md: 48em; // Medium devices such as tablets (768px and up)
$responsive-break-lg: 64em; // Large devices such as laptops (1024px and up)
$responsive-break-xl: 80em; // Largest devices such as desktops (1280px and up)

// ****** Font ******
@font-face {
  font-family: 'Prompt';
  src: url('assets/fonts/Prompt-Regular.ttf');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'Prompt';
  src: url('assets/fonts/Prompt-Bold.ttf');
  font-weight: bold;
  font-style: normal;
}

// ****** Styles ******

*,
body {
  font-family: $font-family;
  font-size: $font-size;
  color: $color-text;
}

h2 {
  font-size: 1.5em;
}

h3 {
  font-size: 1.2em;
}

code {
  font-family: 'Courier New', Courier, monospace;
}

/* ---- General styles ---- */
select {
  background-color: $color-primary;
  border: 2px solid $color-primary;
  border-radius: $button-radius;
  color: $color-primary-inv;
  padding: 0.5em 1em;
  display: flex;
  flex-grow: 1;

  &:hover {
    cursor: pointer;
    background-color: $color-primary-light;
  }
}

.alert {
  padding: 0.5em 0.7em;
  border-radius: 0.3em;
  background-color: $color-info;
  border: 2px solid $color-info-dark;
  margin-top: 1em;
  margin-bottom: 1em;

  svg {
    display: inline-block;
    height: 1em;
    margin: 0 0.2em 0 0.2em;
  }

  &.warning {
    background-color: $color-warning;
    border-color: $color-warning-dark;
  }

  &.success {
    color: $color-text-inv;
    background-color: $color-success;
    border-color: $color-success-dark;
  }
}

button,
.button {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  border: 2px solid $color-primary;
  background-color: $color-primary;
  padding: 0.5em 0.7em;
  text-align: center;
  text-decoration: none;
  border-radius: $button-radius;
  font-size: 0.9em;
  font-weight: 500;
  cursor: pointer;

  &,
  * {
    color: $color-primary-inv;
  }

  img,
  svg {
    display: inline-block;
    height: 1em;
    color: $color-primary-inv;
    margin: 0 0.2em 0 0.2em;
  }
  svg {
    path,
    rect {
      stroke: $color-primary-inv;
    }

    &.svg-fill path,
    rect {
      fill: $color-primary-inv;
    }
  }

  &.button-success {
    background-color: $color-success;
    border-color: $color-success;
  }
  &.button-warning {
    background-color: $color-warning;
    border-color: $color-warning;
  }
  &.button-danger {
    background-color: $color-danger;
    border-color: $color-danger;
  }

  &:hover {
    background-color: $color-primary-light;

    &.button-success {
      background-color: $color-success-light;
    }
    &.button-warning {
      background-color: $color-warning-light;
    }
    &.button-danger {
      background-color: $color-danger-light;
    }
  }

  &:disabled {
    background-color: $color-primary-disabled;
    cursor: not-allowed;
  }
}
.button-onlyicon {
  border: 0 none;
  background-color: transparent;
  padding: 0.1em;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  color: $color-primary;
  max-height: 1em;

  * {
    color: $color-primary;
  }

  img,
  svg {
    display: inline-block;
    height: 1em;
    color: $color-primary;
    margin: 0 0.2em 0 0;
  }
  svg {
    path,
    rect {
      stroke: $color-primary;
    }
  }

  &:hover {
    background-color: transparent;
  }

  &:disabled {
    background-color: transparent;
    color: $color-primary-disabled;
    cursor: not-allowed;

    svg {
      color: $color-primary-disabled;
      path,
      rect {
        stroke: $color-primary-disabled;
      }
    }
  }
}

.button-group {
  display: flex;
  flex-direction: row;

  > .button,
  > button {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;

    &:first-child {
      border-top-left-radius: $button-radius;
      border-bottom-left-radius: $button-radius;
    }
    &:last-child {
      border-top-right-radius: $button-radius;
      border-bottom-right-radius: $button-radius;
    }
  }
}

.badge {
  border-radius: 1em;
  background-color: $color-primary;
  color: $color-primary-inv;
  padding: 0.5em 1em;
  font-size: 0.7em;

  &.disabled {
    background-color: $color-primary-disabled;
  }
}

/* ---- Modals ---- */
.modal-wrapper {
  display: flex;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  outline: 0;

  .overlay {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
    transition: opacity 0.15s linear;
    background-color: rgba(0, 0, 0, 0.5);
  }

  .modal {
    z-index: 1001;
    background-color: #ffffff;
    align-self: center;
    padding: 1em;
    border-radius: $button-radius;
    margin: 2em;
  }
}

/* ---- Tables ---- */
table {
  border-collapse: collapse;
}

th,
td {
  border: 1px solid;
  padding: 0.2em 0.5em;
}

/* ---- Forms ---- */
label {
  display: block;
  margin-right: 1em;
}

input,
.input,
.pubkey-show {
  border: 2px solid $color-primary;
  border-radius: 0.3em;
  background-color: $background-color;
  padding: 0.5em 1em;
  display: flex;
  flex-grow: 1;

  &:read-only {
    color: grey;
    cursor: not-allowed;
  }
}

.pubkey-show {
  padding: 0.7em 1em;
}

.form-field {
  display: flex;
  flex-direction: column;

  & > * {
    margin-bottom: 0.5em;
  }

  &.validation-error {
    label {
      color: $color-danger;
    }
    input {
      border-color: $color-danger;
    }
  }
}

.input-group {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;

  input {
    flex: 1 1 auto;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 0;
  }
  button {
    margin-left: calc(var(--bs-border-width) * -1);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;

    &:first-child {
      border-top-left-radius: $button-radius;
      border-bottom-left-radius: $button-radius;
    }
    &:last-child {
      border-top-right-radius: $button-radius;
      border-bottom-right-radius: $button-radius;
    }
  }
}

/* ---- Popup ---- */
.popup-main {
  max-width: 640px;

  h1 img {
    max-height: 50px;
  }

  .public-key {
    margin-bottom: 1em;
    background-color: $color-primary;
    border: 0px solid;
    border-radius: 0.3em;
    display: flex;

    code {
      margin-right: 0.5em;
    }

    select {
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
    }

    .profile-switch {
      select {
        max-width: 8em;
        text-overflow: ellipsis;
        option {
          text-overflow: ellipsis;
        }
      }
    }
  }
}

/* ---- Options ---- */
#options-page {
  & {
    width: 100%;
    height: 100%;
  }

  #main {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;

    header {
      text-align: center;
    }

    main {
      flex-grow: 1;

      section {
        h3 {
          display: flex;
          &::after {
            content: '';
            display: flex;
            float: right;
            border-bottom: 1px dotted black;
            flex: 1 auto;
            height: 1px;
            margin-left: 1em;
            align-self: center;
          }
        }
      }

      #selected-profile {
        display: flex;
        flex-direction: row;
        column-gap: 1em;
      }

      .profile-actions {
        display: flex;
        flex-direction: row;
        button {
          margin-right: 1em;
        }
      }

      .relays-list {
        display: flex;
        flex-direction: column;

        .relays-list-item {
          display: flex;
          flex-direction: row;
          margin-bottom: 0.5em;

          svg {
            max-height: 2em;
            align-self: center;
            margin-right: 0.5em;
          }
          input {
            flex-grow: 1;
            margin-right: 0.5em;
          }

          .button-remove {
            max-height: none;
          }
        }
      }

      section.danger {
        display: flex;
        flex-direction: column;
        margin-top: 2em;
      }
    }

    footer {
      text-align: center;
      padding-bottom: 1em;
    }
  }

  .modal {
    max-width: 95%;
  }
  .export-modal {
    code {
      display: block;
      overflow: scroll;
    }
  }
  .import-modal {
    textarea {
      display: block;
      width: 100%;
      overflow: scroll;
      font-family: 'Courier New', Courier, monospace;
    }
  }
}

/* ---- Prompt ---- */
.prompt-main {
  .prompt-navigator {
    position: absolute;
    top: 1em;
    right: 1em;
    display: flex;
    flex-direction: row;
    align-items: center;

    > span {
      white-space: nowrap;
    }
  }

  .prompt-host {
    display: 'block';
    text-align: 'center';
    font-size: 2em;
  }

  .prompt-requests li {
    font-size: 1.2em;
  }

  .prompt-request-raw {
    overflow: auto;
    border: 1px solid #333333;
    display: block;
    padding: 1em;
    margin-bottom: 1em;
  }

  .prompt-action-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
  }

  .prompt-action-buttons > * {
    flex: 1 1 auto;
    margin: 0.5em;
  }

  .close-confirm-dialog-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: end; // bottom of the window
    z-index: 100;

    .close-confirm-dialog {
      width: 100%;
      background-color: white;
      padding: 20px;
      border-top-left-radius: $radius-default;
      border-top-right-radius: $radius-default;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);

      .action-buttons {
        display: flex;
        flex-direction: row;
        justify-content: end;

        > *:not(:first-child) {
          margin-left: 1em;
        }
      }
    }
  }
}
