// ---------------------------
// PAGE PAGES
// ---------------------------


// Page navigation

.page-nav {
  font-size: 0;
  color: $bodyFgFaded;
  display: inline-block;
  vertical-align: middle;
  &_prev, &_next, &_info {
    padding: 0 0.6em;
    line-height: 2.2;
    display: table-cell;
    border-radius: 1.2em;
    text-decoration: none;
    font-size: $fontSizeSmall;
    background: mix(#FFF, $bodyBg, 25);
    background-clip: padding-box;
    border: 1px solid $borderColor;
  }
  &_prev, &_next { color: rgba($bodyFgFaded, 0.5); }
  &_info {
    border-radius: 0;
    border-width: 1px 0;
  }
  &_prev {
    padding-left: 0.8em;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }
  &_next {
    padding-right: 0.8em;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }
  a {
    color: inherit;
    &:hover {
      color: $bodyFg;
      background-color: mix(#FFF, $bodyBg, 80);
    }
    &:active { @include button-state(active); }
  }
}


// Page editor full screen mode

.page-editor {
  margin: -3rem 0 2rem 0;

  &.fullscreen {
    top: 0;
    left: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    overflow: auto;
    position: fixed;
    background: $bodyBg;
    box-sizing: border-box;
    padding: 0 3rem 3rem 3rem;

    .page-navigator,
    .auto-fullscreen {
      display: inline-block;
    }

    .page-imagescan {
      bottom: -3rem;
    }
  }

  .page-navigator,
  .auto-fullscreen {
    display: none;
  }
}


// Page toolbar

.page-toolbar {
  top: 0;
  z-index: 999;
  padding: 2rem 0;
  position: sticky;
  height: 73px;
  box-sizing: border-box;
  background-color: $bodyBg;

  label { margin-right: 6px; }

  @media screen and (max-width: $widthL) {
    .hide-l { display: none; }
  }

  @media screen and (max-width: $widthM) {
    .hide-m { display: none; }
  }
}

#blankPageButton {
  margin: 0px 10px;
}

#custom-alert {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 9999;
}
#custom-alert-box {
  background-color: #fff;
  max-width: 400px;
  margin: 20% auto;
  padding: 20px;
  text-align: center;
  border-radius: 5px;
  box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
}

// Page columns

.page-headlines {
  width: 100%;
  display: inline-block;
  .headline {
    width: 50%;
    float: left;
    margin-bottom: $gapSize / 2;
  }
}

.page-columns {
  width: 100%;
  display: flex;
  min-height: 50vh;
  position: relative;
  column-gap: 2rem;
  row-gap: 2rem;

  &[data-layout-mode='rtl'] {
    flex-direction: row-reverse;
  }

  &[data-layout-mode='ttb'] {
    flex-direction: column;
  }

  &[data-layout-mode='btt'] {
    flex-direction: column-reverse;
  }

  &[data-layout-mode='btt'],
  &[data-layout-mode='ttb'] {
    .cm-editor {
      min-height: 30vh;
    }
  }
}

.page-column {
  z-index: 0;
  min-width: 0;
  min-height: 0;
  flex: 1 1 50%;
  display: flex;
  box-sizing: border-box;
  flex-direction: column;

  [data-layout-mode='ttb'] &,
  [data-layout-mode='btt'] & {
    // min-height: calc((100vh - 74px - 3rem) / 2);
  }
}

.page-imagescan {
  top: 74px;
  bottom: 0;
  z-index: 1;
  width: 100%;
  overflow: hidden;
  position: sticky;
  align-self: flex-start;
  // background: rgba(#000, 0.03);
  height: calc(100vh - 74px - 3rem);

  [data-layout-mode='ttb'] &,
  [data-layout-mode='btt'] & {
    flex-basis: auto;
    max-height: calc(50vh);
  }
}

.page-editarea {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;

  &_title {
    height: 45px;
    display: flex;
    flex-shrink: 0;
    padding-left: 10px;
    margin-bottom: 2rem;
    align-items: center;
    background: $bgWhite;
    font-size: $fontSizeBig;
    border: 1px solid $inputBorderColor;

    input {
      border: 0;
      background: none;
      box-shadow: none;
    }
  }

  &_textarea {
    border: 0;
    height: 100%;
    resize: none;
    padding: 10px;
    flex: 1 1 auto;
    box-shadow: none;
    background: $bgWhite;
  }
}

.cm-editor {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;

  .CodeMirror {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    font-family: $fontFamily;
    height: auto !important;

    &-buttonsPanel:not(:empty) {
      top: 73px;
      z-index: 1;
      display: flex;
      flex-wrap: wrap;
      position: sticky;
      padding-bottom: 5px;
      background-color: $bodyBg;

      // [data-layout-mode='ttb'] & {
      //   padding-top: 8px;
      //   top: calc(74px + (100vh - 74px - 3rem) / 2);
      // }

      button {
        padding: 0 4px;
        font-size: 13px;
        box-shadow: none;
        margin: 0 3px 3px 0;
        line-height: 1.75em;
        font-family: monospace;
      }
    }

    &-wrap {
      z-index: 0;
      border: 1px solid $inputBorderColor;
    }

    &-scroll {
      flex-grow: 1;
    }
  }
}

.fields-row {
  display: flex;
  align-items: stretch;
  column-gap: 5px;
  // flex-wrap: wrap;

  &:not(:last-child) {
    margin-bottom: 10px;
  }

  .field-wrapper {
    margin-bottom: 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;

    &.spreadsheet {
      padding: 0;
      width: 100%;
    }

    label {
      text-align: left;
      display: flex;
      word-break: break-word;
      flex: 1;
      align-items: flex-end;
    }
  }

  .field-instructions {
    color: $fgH2;
    padding: 6px 0 6px 10px;
    border-left: 4px solid rgba($fgH2, 0.6);

    h5 {
      margin: 0;
      color: $fgH1;
    }

    p {
      margin: 0.5em 0 0 0;
    }
  }
}

.page-preview {
  height: 100%;
  padding: 1.5rem;
  overflow-x: auto;
  box-sizing: border-box;
  font-size: $fontSizeBig;
  background: rgba(#FFF, 0.5);
  border: 1px solid rgba($borderColor, 0.5);

  p:first-child {
    margin-top: 0;
  }

  .centered_content {
    text-align: center;
  }

  .field__label {
    color: rgba($bodyFg, 0.6);
  }

  table {
    width: 100%;
    border-spacing: 0;
    font-size: $fontSize;
    border-collapse: collapse;
    background-color: rgba($bgWhite, 0.5);

    th {
      padding: 0.5em;
      line-height: 1.2;
      color: $fgSelected;
      white-space: nowrap;
      background: $bgSelected;
      border: 1px solid rgba(#000, 0.15);
    }

    td {
      line-height: 1.2;
      padding: 0.25em 0.5em;
      border: 1px solid $borderColor;
    }
  }
}
.ai-toolbar {
  top: 0;
  right: 2%;
  z-index: 1;
  opacity: 1;
  visibility: visible;
  display: flex;
  // padding: 0 8px;
  // padding: 10px 8px;
  border-radius: 18px;
  justify-content: center;
  position: absolute !important;
  background: rgba(#000, 0.8);
  transform: translate3d(0, 10px, 0);
  // transform: translate3d(-50%, -100%, 0);
  // transition: opacity 0.3s 1s, visibility 0.3s 1s, transform 0.3s 1s $easeOutCubic;

  &.fullpage,
  .page-imagescan:hover & {
    opacity: 1;
    visibility: visible;
    // transition-delay: 0s;
    // transform: translate3d(-50%, 10px, 0);
  }

  a, .dropdown dt {
    padding: 5px 10px;
    color: rgba(#FFF, 0.7);

    .icon {
      display: block;
    }
  }


}



.image-toolbar {
  top: 0;
  left: 50%;
  z-index: 1;
  opacity: 0;
  display: flex;
  padding: 0 8px;
  visibility: hidden;
  border-radius: 18px;
  justify-content: center;
  position: absolute !important;
  background: rgba(#000, 0.8);
  transform: translate3d(-50%, -100%, 0);
  transition: opacity 0.3s 1s, visibility 0.3s 1s, transform 0.3s 1s $easeOutCubic;

  &.fullpage,
  .page-imagescan:hover & {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
    transform: translate3d(-50%, 10px, 0);
  }

  a, .dropdown dt {
    padding: 10px 8px;
    color: rgba(#FFF, 0.7);

    .icon {
      display: block;
    }
  }

  a:hover,
  .dropdown dt:hover,
  .dropdown.open dt {
    color: #FFF;
  }

  .dropdown dd {
    color: rgba(#FFF, 0.7);
    background: rgba(#000, 0.8);

    &:after {
      border-bottom-color: rgba(#000, 0.8);
    }
  }

  .filter {
    display: flex;
    align-items: center;
    padding: 0.5em 0.8em;

    &:not(:first-child) {
      border-top: 1px solid rgba(#000, 0.06);
    }

    &_label {
      flex-grow: 1;
      margin-right: 1rem;
    }

    &_value {
      width: 2em;
      text-align: right;
    }
  }
}

.image-container {
  width: 100%;
  height: 100%;
  background-color: #000;
}

.page-review {
  color: $fgLink;
  max-width: 700px;
  text-align: center;
  margin: 0 auto 2rem auto;
  font-size: $fontSizeSmall;
}


// image row highlight
.image-row-highlight {
  opacity: 0.2;
  filter: alpha(opacity=20);
  background-color: green;
}


// Assign categories

.page-uncategorized {
  padding: $gapSize;
  border-radius: 4px;
  margin: $gapSize 0;
  background-clip: padding-box;
  border: 1px solid rgba(#000, 0.06);
  background-color: mix(#FFF, $bodyBg, 50%);
  &_subject:before { color: $bodyFgLight; }
}

// Page legend

.page-legend {
  margin: 2em auto 0 auto;
  max-width: 800px;
  padding: 1.5em;
  background-color: mix(#FFF, $bodyBg, 35%);
  border: 1px solid $borderColor;
  border-radius: 0.5em;
  
  .page-legend-title {
    margin: 0 0 1em 0;
    color: $bodyFg;
    font-size: $fontSize;
  }
  
  .page-legend-content {
    color: $bodyFgFaded;
    line-height: 1.6;
    
    p {
      margin: 0 0 1em 0;
      &:last-child { margin-bottom: 0; }
    }
  }
}


// Page notes

.page-notes {
  margin: 0 auto;
  max-width: 800px;
}


// Page Settings

.page-settings {
  .sidecol {
    min-width: 200px;
    big {
      display: block;
      margin: 0.5em 0 0.3em 0;
    }
    time {
      display: block;
      color: $bodyFgFaded;
    }
  }
}

.page-image-preview {
  text-align: center;
  margin-bottom: 50px;
  img {
    height: auto;
    max-width: 100%;
  }
}

.page-indent {
  margin-left: 30px;
}
