html, body {
  /* iOS viewport bug fix (bottom of screen covered by control bar) */
  /* CSS var `--vh` set in JS; see `src/utils/vh_fix.js` */
  min-height: 100vh;
  min-height: fill-available;
  min-height: calc(var(--vh, 1vh) * 100);
  height: 100vh;
  height: fill-available;
  height: calc(var(--vh, 1vh) * 100);
}

html, body, ul {
  padding: 0;
  margin: 0; }

body {
  color: #222;
  font-size: 16px;
  font-family: 'Lato', sans-serif;
}

// Desktop - Max height & width
@media (min-width: 768px) {
  #page {
    display: flex;
    flex-direction: row;
    max-width: 100vw;
    max-height: calc(var(--vh, 1vh) * 100);
  }
}

// Mobile - Max & min height
@media (max-width: 767px) {
  #page {
    display: flex;
    flex-direction: column;
    max-height: calc(var(--vh, 1vh) * 100);
    min-height: calc(var(--vh, 1vh) * 100);
  }
}

$funky-purple: #663399;


.encloser {
  display: flex;
  flex-direction: row;
}

@media (max-width: 768px) {
  .encloser {
    flex-direction: column;
  }
}

// HEADER - mobile settings
header {
  display: flex;
  background-color: $base-color;
  color: #fff;
  padding: 10px 10px 5px;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: wrap;
  min-height: fit-content;

  .users-icon {
    order: -1;
    flex-grow: 1;
    svg {
      cursor: pointer;
    }
  }

  .users-list {
    flex: 0 1 100%;

    ul {
      
      list-style-type: none;
      li {
        svg {
          float: left;
        }
      }
    }

    .invite-users {
      margin-top: 15px;

      button {
        color: white;
        border: solid 1px white;
        border-radius: 5px;
      }
    }
  }

  .logo-container {
    display: flex;
    justify-content: space-between;
    flex-grow: 1;
  }

  .logo {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
  }

  .settings {}
}

// HEADER - desktop settings
@media (min-width: 768px) {
  header {
    flex: 1;
    display: inline-flex;
    max-width: 306px;
    flex-direction: column;
    justify-content: start;
    height: calc(var(--vh, 1vh) * 100);

    .logo-container {
      margin-bottom: 15px;
      order: -1;
      flex-grow: 0;
    }

    .settings {
      float: right;
      margin-top: 3px;
      margin-left: auto;
      cursor: pointer;
    }

    .info {
      float: left;
    }

    .users-icon {
      display: none;
    }

    .users-list {
      flex-grow: 0;
      flex: none;
      display: block !important;

      ul {
        
        li {
          margin-bottom: 1px;
          word-wrap: break-word;
        }
      }
    }
  }
  .modal-header {
    border-bottom: none;
  }
  .message {
    display: flex;
    flex-direction: row;
  }
  .form-control {
    flex-grow: 2;
  }
  .emoji-picker-icon {
    cursor: pointer;
  }

  .form-label {
    font-weight: bold;
  }
}

.modal-content a {
  color: $funky-purple;
}

// Sharing overlay - desktop settings
@media (min-width: 768px) {
  .share-copy-link {
    .current-href {
      width: 60%;
    }
  }
}

// Sharing overlay - mobile settings
@media (max-width: 999px) {
  .share-copy-link {
    .current-href {
      width: 100%;
      border-radius: 7px !important;
      margin-bottom: 5px;
    }
    .icon-button {
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: center;
      border-radius: 7px !important;
      width: 100%;
    }
  }
}

// MAIN - mobile settings
main {

  display: flex;
  flex-grow: 1;
  max-width: 100vw;

  .content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    position: relative;

    .message-list {
      padding: 0 15px;
    }

    .message-form {
      padding: 5px;
      background-color: white;
      border-top: solid 1px #ccc;
      margin-top: auto;

      .message {
        display: flex;

        textarea {
          /* this font-size disables zooming
          on mobile safari, which breaks layout */
          font-size: 16px;
        }
      }

      button {
        border: none;
        padding: 5px;
        float: right;
        height: 54px;
        vertical-align: bottom;
        margin-left: 5px;

        i {
          color: #1e202f;
        }
      }
    }
  } // end .content
} // end main

.message-box,
.search-results {
  // scroll with flexbox needs revisiting
  // for now, message box is viewport height
  // less display height of message form
  // + display height of header
  //
  // 157px is a magic number -- and one that works well on 2 desktop
  // browsers, the Android native app (Capacitor), and the Android
  // emulator.  We need to explicitly set the heights set more heights
  // of things to avoid the magic number, methinks. --@elimisteve
  height: calc(var(--vh, 1vh) * 100 - 157px - var(--androidTopBar, 0));
  overflow-y: scroll;
  padding-top: 5px;

  ul {
    margin-top: 10px;

    li.chat-message {
      display: inline-block;
      border: solid 1px #aaa;
      border-radius: 10px;
      padding: 5px 10px;
      margin-bottom: 6px;
      width: 90%;
      word-wrap: break-word;
      box-shadow: 2px 1px 2px #aaa, -1px 0 1px #aaa;

      .username {
        display: block;
        font-weight: bold;
        font-size: 0.85em;
      }

      p {
        margin: 0 0 3px;
      }

      &.chat-outgoing {
        float: right;
        color: white;
        background-color: $funky-purple;

        p {
          margin: 2px 0;
        }

        .username {
          display: none;
        }

        a {
          text-decoration: underline;
          color: white;
        }

        a:hover {
          color: #ddd;
        }
      }

      &.chat-incoming {
        float: left;
        color: #333;
      }

      ul {
        list-style-type: disc;
        margin-left: 20px;
      }

      img[src^='/static/img/emoji'] {
        width: 24px;
        height: 24px;
        display: inline-block;
        background-size: 100%;
        vertical-align: bottom;
      }
    }
  }
}

.search-results {
  height: auto;
  max-height: calc(var(--vh, 1vh) * 50);
  padding-right: 10px;
}


// MAIN - desktop settings
@media (min-width: 768px) {
  main {
    display: inline-flex;
    flex: 1;
    flex-direction: row;
    justify-content: start;
    height: calc(var(--vh, 1vh) * 100);
    width: 50vw !important;

    .content {
      max-width: 100%;
      .message-box{
        // scroll with flexbox needs revisiting
        // for now, message box is viewport height
        // less display height of message form
        height: calc(var(--vh, 1vh) * 100 - 70px);
        box-shadow: inset 2px 2px 2px #aaa;
      }
    }
  }
}

// Alert styles, overrides default bootstrap
// styles for positioning
.alert-container {
  position: absolute;
  top: 5px;
  left: 10px;
  right: 10px;
  font-size: 14px;
  z-index: 10;

  .alert {


    &.alert-dismissable {
      .close {
        right: auto;
      }
    }
  }
}

// Info Positioning relative to Logo
#logo-info {
  display: inherit;
  .info {
    padding-left: 10px;
    svg {
      vertical-align: top;
      cursor: pointer;
    }
  }
}

.search-results {
  ul {
    li.chat-message {
    }
  }
}

.icon-button {
  display: flex;
  flex-direction: row;
  align-items: center;
  text-decoration: none;

  &:hover {
    text-decoration: none;
  }

  svg {
    margin: 0 6px;
  }
}


// Cursor effect over Settings button
.settings {
  svg {
    cursor: pointer;
  }
}

// Override Bootstrap default
.btn-primary,
.btn-primary:hover,
.btn-primary:active,
.btn-primary:visited {
  background-color: $funky-purple !important;
  border-color: $funky-purple !important;
}

// Allows textarea to be dynamic instead of static
textarea {
  box-sizing: border-box !important;
  max-height: 40vh !important;
  width: 100% !important;
}

// All widths
.chat-icons {
  display: flex;
  flex-direction: row;
  margin-bottom: 5px;
  width: 100%;
  padding-left: 5px;
  gap: 10px;

  .sharing,
  .toggle-audio,
  .open-message-search {
    cursor: pointer;
  }
}
.chat-icons .right-chat-icons {
  display: flex;
  flex-direction: row;
  height: 100%;
  margin-left: auto;
}
.right-chat-icons .delete-all-msgs {
  display: flex;
  flex-direction: row;
  background-color: #c00;
  color: white;
}
.delete-all-msgs:hover {
  background-color: #e00;
}
