@use 'sass:color';

@use 'globals';

@use 'spectre-css/spectre';
@use 'spectre-css/spectre-icons';
@use 'spectre-css/spectre-exp';
@use 'trix/dist/trix';

@use 'spectre-css/mixins/_shadow';
@use 'partials/index';

@use 'helpers/layouts_helper';

@use 'public';
@use 'account';
@use 'volunteer';
@use 'header';
@use 'spectre-css/variables';

body {
  background-color: variables.$bg-color;
}

.feather-icon {
  line-height: 20px;
  vertical-align: sub;
  stroke: #303742;
  fill: transparent;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn .feather-icon {
  stroke: currentColor;
  margin-right: 0.4em;
}

.btn.btn-sm .feather-icon {
  height: 16px;
  width: 16px;
  margin-right: 0.2em;
}

.feather-icon.error {
  stroke: variables.$error-color;
}

.more-info {
  border-bottom: 0.05rem dotted;
  cursor: help;
  text-decoration: none;
}

ul.error {
  color: red;
}

form details {
  margin-top: 1em;

  summary {
    margin-bottom: 0.3rem;
    color: variables.$link-color;
    outline: none;

    &:focus {
      @include shadow.control-shadow();
    }

    &:focus,
    &:hover,
    &:active,
    &.active {
      color: variables.$link-color-dark;
      text-decoration: underline;
    }
    &:hover {
      cursor: pointer;
    }
  }

  label.form-label {
    display: none;
  }
}

.container {
  padding-bottom: 3rem;
}

header.navbar {
  margin-bottom: 1rem;
}

.toast {
  margin-bottom: 1rem;
  a {
    color: variables.$primary-color;
  }
}

.off-canvas-content {
  .off-canvas-title a {
    color: white;
    font-size: 0.9rem;
    line-height: 1.8rem;
  }
}

.form-buttons {
  margin-top: 2rem;
}

.members-table {
  display: grid;
  grid-row-gap: 0.5rem;
  grid-column-gap: 0.3rem;
  grid-template-columns: 0.5fr 2fr 4fr 2fr 2.5fr 0.5fr 0.5fr;

  .members-table-header {
    font-weight: bold;
  }

  .members-table-number {
    text-align: center;
  }
}

$photo-width: 187px;

.items-list {
  display: flex;
  flex-direction: column;
  margin: 0;

  .item-image {
    display: flex;
    justify-content: center;
  }

  .item-container {
    display: flex;
    border-bottom: 1px solid #dadee4;
  }

  .item-container .item-name {
    font-size: 1rem;
  }
}

// Desktop
@media all and (min-width: 841px) {
  .search-sort-buttons .btn-group {
    margin-inline-start: 4px;
  }

  .items-list {
    .item-container {
      gap: 1rem;
      margin-block-start: 1rem;
      padding-block-end: 1rem;

      &:first-of-type {
        margin-block-start: 0;
      }
    }

    .item-image {
      flex: 1;
      max-width: $photo-width;

      img,
      .image-placeholder {
        max-width: 100%;
      }
    }

    .item-content {
      display: flex;
      flex: 1;
      gap: 1rem;
      justify-content: space-between;
    }

    .item-info {
      flex: 1;
    }

    .item-categories {
      flex: 1;
      font-size: 0.7rem;

      a {
        display: block;
      }
    }
  }
}

// Mobile
@media all and (max-width: 840px) {
  .search-sort-buttons .btn-group {
    display: block;

    .btn.btn {
      border-radius: 5px;
      margin-block-end: 3px;
    }
  }

  .items-list {
    .item-container {
      gap: 0.6rem;
      margin-block-start: 0.6rem;
      padding-block-end: 0.6rem;

      &:first-of-type {
        margin-block-start: 0;
      }
    }

    .item-image {
      width: 100px;

      .item-image-placeholder,
      img {
        width: 100%;
      }
    }

    .item-content {
      display: flex;
      flex-direction: column;
      gap: 0.6rem;
    }

    .item-categories {
      font-size: 0.6rem;

      a {
        display: inline-block;
        margin-right: 0.3rem;
      }
    }
  }
}

.tag-nav {
  li {
    margin: 0;
    display: flex;

    a {
      display: inline-block;
      line-height: 1.5;
    }
  }

  .active a {
    color: red;
  }

  .parent a {
    font-weight: bold;

    &:hover {
      color: variables.$primary-color;
    }
  }
}

.image-placeholder {
  display: inline-block;
  width: $photo-width;
  height: 140px;
  background: #eee;
  max-width: 100%;
}

.destroy-button,
.destroy-area {
  padding-top: 3rem;
}

fieldset {
  margin-top: 1rem;
}

legend {
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  font-weight: bold;
}

.label-required-field {
  font-size: 0.8em;
  margin-left: 1em;
  letter-spacing: 1px;
  text-transform: uppercase;
  float: right;
}

.form-group.has-error .label-required-field {
  background-color: color.adjust(
    variables.$error-color,
    $lightness: 20%,
    $space: hsl
  );
  color: inherit;
}

.multi-select-summary {
  font-size: 0.9em;
  background: #f5f5f5;
  padding: 0.5em;
  white-space: pre;
}

.signup-steps {
  margin: 1rem 0 1rem;
  .step-item {
    margin-left: 0;
  }
}

.signup-logo {
  text-align: center;
  margin-top: 1rem;
  img {
    max-width: 30%;
    margin-bottom: 0.6rem;
  }
  &.on-step {
    img {
      display: inline;
      max-width: 8%;
      vertical-align: middle;
    }
    h1 {
      display: inline;
      font-size: 1.3rem;
      margin: 0 0 0 0.3em;
      position: relative;
      top: 0.25em;
    }
  }
}

form.membership-amount {
  label,
  .input-group {
    float: left;
  }
  label {
    margin-right: 1rem;
    line-height: 2.3rem;
  }
  .form-input {
    height: 3rem;
    width: 4rem;
    font-size: 1.5rem;
    text-align: center;
  }
  .form-input-hint {
    float: left;
    margin-left: 0.5rem;
    line-height: 2.3rem;
  }
  .input-group-addon {
    line-height: 2.4rem;
    font-size: 1.1rem;
  }
  .form-group {
    overflow: hidden;
  }
  .form-buttons {
    margin-top: 1.5rem;
  }
}

$min-width: variables.$size-md + 1;

@media (min-width: $min-width) {
  .complete-in-person {
    margin-left: 1rem;
  }

  .pay-online {
    margin-right: 1rem;
  }
}

.divider.small-horizontal-divider {
  margin-top: 2rem;
}

.callout-box {
  background: white;
  padding: 1rem 0.5rem 0.5rem 1.5rem;
  margin-bottom: 1rem;
  ul {
    list-style: outside;
  }
}

.signup {
  .rich-text {
    margin-bottom: 2rem;
  }
  h1 {
    margin-bottom: 0;
  }
}

.instructions {
  .main {
    color: variables.$primary-color;
    font-weight: 500;
    line-height: 1.2;
    font-size: 1.2rem;
    margin-bottom: 0.5em;
  }
  .sub {
    color: variables.$primary-color;
    font-size: 1rem;
  }
  .divider {
    margin-bottom: 1rem;
  }
  ul {
    list-style: outside;
    margin-left: 1.5rem;
  }
}

.items-summary {
  margin-bottom: 2em;
  display: flex;
  justify-content: space-between;
}

.public {
  .items-show {
    .item-image {
      position: relative;
      img {
        max-width: 100%;
      }
    }
  }
  h1 {
    margin-bottom: 0.1em;
  }
}

.landing-page {
  .landing-options {
    font-size: 1.5rem;
    line-height: 1.1;
  }
  .landing-options .column {
    margin-bottom: 0.5em;
  }
}

.member-active-loans {
  p {
    margin-bottom: 0;
  }
}

.shift-schedule {
  h3 {
    margin-top: 1rem;
  }
  .num-attending {
    color: variables.$success-color;
  }
  .attending-1 {
    color: variables.$warning-color;
  }
  .attending-0 {
    color: variables.$error-color;
  }
  .attendees {
    list-style: outside;
    font-size: 0.9em;
  }
}

.items-index-buttons {
  margin-top: 1em;
}

.item-borrow-policy,
.item-checkout-status {
  font-size: 0.8em;
  position: relative;
  top: -1px;
}

.please-wait {
  margin-top: 2rem;
}

@media (max-width: variables.$size-md) {
  img {
    max-width: 60vw;
  }
}

.signup .gift-membership {
  margin-top: 4rem;
}

.columns > .divider {
  margin-left: 8px;
  margin-right: 8px;
  width: 100%;
}

.item-panel {
  background: white;
  margin-bottom: 16px;
  h6 {
    margin-bottom: 0;
  }
  .member-stats,
  .item-stats {
    list-style: none outside;
    margin: 0 0 1.2rem;
    li {
      text-overflow: ellipsis;
      white-space: nowrap;
      overflow: hidden;
      margin-left: 0;
    }
    .feather-icon {
      margin-right: 0.2rem;
    }
    &:last-child {
      margin-bottom: 0.6rem;
    }
  }
  .item-image {
    &,
    & img {
      border-top-left-radius: 0.1rem;
      border-top-right-radius: 0.1rem;
    }
    img {
      width: 100%;
    }
  }
}

.item-stats {
  li.with-inner-stats {
    svg,
    .inner-stats {
      float: left;
    }
  }
  .inner-stats {
    list-style: none outside;
    float: left;
    margin: 0;
    li {
      margin: 0;
    }
  }
  .placeholder-text {
    color: #c0c0c0;
    font-style: italic;
  }
}

.note {
  position: relative;
  .edit-note {
    position: absolute;
    right: 0;
    top: 0.4rem;
  }
  .trix-content {
    margin-bottom: 1rem;
  }
}

.app-body,
.app-header {
  .btn {
    border-radius: 5px;
    @include globals.default-button();
    &.btn-default {
      background: variables.$gray-color-dark;
      border-color: variables.$dark-color;
      color: white;
      &:hover {
        background: variables.$dark-color;
      }
    }
    &.btn-primary {
      background: variables.$primary-color;
      border-color: color.adjust(
        variables.$primary-color,
        $lightness: -10%,
        $space: hsl
      );
      color: white;
      &:hover {
        background: color.adjust(
          variables.$primary-color,
          $lightness: -10%,
          $space: hsl
        );
      }
      &:active,
      &.active {
        background: variables.$dark-color;
        border-color: variables.$dark-color;
      }
    }
    &.btn-secondary {
      background: variables.$secondary-color;
      border-color: color.adjust(
        variables.$secondary-color,
        $lightness: -10%,
        $space: hsl
      );
      color: white;
      &:hover {
        background: color.adjust(
          variables.$secondary-color,
          $lightness: -10%,
          $space: hsl
        );
      }
      &:active,
      &.active {
        background: variables.$dark-color;
        border-color: variables.$dark-color;
      }
    }
  }
}

.style-guide {
  .colors {
    .column {
      min-height: 4rem;
    }
    .primary {
      background-color: variables.$primary-color;
    }
    .secondary {
      background-color: variables.$secondary-color;
    }

    .success {
      background-color: variables.$success-color;
    }
    .warning {
      background-color: variables.$warning-color;
    }
    .error {
      background-color: variables.$error-color;
    }

    .dark {
      background-color: variables.$dark-color;
    }
    .gray-dark {
      background-color: variables.$gray-color-dark;
    }
    .gray {
      background-color: variables.$gray-color;
    }
    .gray-light {
      background-color: variables.$gray-color-light;
    }
    .light {
      background-color: variables.$light-color;
    }
  }
}

.c-help {
  cursor: help;
}

.warning {
  color: variables.$error-color;
}

html {
  height: 100%;
  min-height: 100%;
}

body {
  display: flex;
  min-height: 100%;
  flex-direction: column;
}

footer.page-footer {
  font-size: 0.8rem;
  padding: 1rem 0 0;
  flex-shrink: 0;
  background: variables.$bg-color-dark;
  text-align: center;
  position: relative;
}

.time-override {
  display: none;
}

@media all and (min-width: 840px) {
  .time-override {
    display: block;
    position: fixed;
    top: 0;
    right: 10rem;
  }
}
