@import 'jquery.textile';

.content-textile,
.textile-preview {
  overflow-wrap: break-word;
  position: relative;

  em {
    font-style: italic;
  }

  h5 {
    margin-top: 2rem;

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

  img {
    max-width: 100%;
    height: auto;
  }

  ol {
    list-style-type: decimal;
  }

  p:last-child {
    margin: 0;
  }

  pre {
    background-color: $secondary-bg;
    border: 1px solid $border-color;
    border-radius: 3px;
    margin: 0.75rem 0;
    padding: 10px;
    white-space: pre-wrap;
    overflow-y: auto;
  }

  strong {
    font-weight: bold;
  }

  table {
    max-width: 100%;
    background-color: transparent;
    border-collapse: collapse;
    border-spacing: 0;
    width: 80%;
    margin: 0 auto;
    margin-bottom: 20px;

    tbody {
      > tr:nth-child(odd) > td,
      > tr:nth-child(odd) > th {
        background-color: #f9f9f9;
      }
      tr:hover td,
      tr:hover th {
        background-color: #f5f5f5;
      }
    }

    td {
      overflow-wrap: anywhere;
    }

    // Cells
    th,
    td {
      padding: 8px;
      line-height: 20px;
      text-align: left;
      vertical-align: top;
      border-top: 1px solid #ddd;
    }

    th {
      font-weight: bold;
    }

    // Bottom align for column headings
    thead th {
      vertical-align: bottom;
    }

    // Remove top border from thead by default
    caption + thead tr:first-child th,
    caption + thead tr:first-child td,
    colgroup + thead tr:first-child th,
    colgroup + thead tr:first-child td,
    thead:first-child tr:first-child th,
    thead:first-child tr:first-child td {
      border-top: 0;
    }
  }

  ul {
    list-style-type: square !important;
  }

  ul,
  ol {
    margin-bottom: 2ex;
  }
}

.markup-help {
  h5 {
    margin-top: 2rem;
  }

  .example-img {
    height: 140px;
  }

  ol,
  ul {
    padding-left: 0;
  }
}

.textile-wrap {
  background-color: #fff;
  word-break: break-word;

  &.textile-fullscreen {
    font-size: 0.9rem;
    max-height: 100vh;
    padding-top: 0;
    position: fixed;
    overflow: auto;

    .textile-inner {
      min-height: calc(100% - 3.5rem);
      position: absolute;
      top: 3.5rem;
      width: 100%;

      .textarea-container {
        padding-bottom: 0.5rem;
      }

      .textile-form-field {
        .textarea-container {
          padding-bottom: 0;
        }
      }

      .textile-preview {
        height: initial;
        padding-bottom: 0.5rem;
      }

      .sticky-toolbar .editor-toolbar {
        top: 0;
      }
    }

    .textile-toolbar {
      margin-top: 10px !important;
    }
  }

  .textile-inner {
    background: transparent;
    padding: 0;

    .editor-field {
      .textile {
        border: 0;
        border-right: 1px solid $border-color;
        border-radius: 0;
        box-shadow: none !important;
        padding: 0.5rem 1.5rem 0.5rem 1rem;
      }
    }

    .textile-form {
      .add-field {
        margin: 1rem 0.75rem;
      }

      .textile-form-body {
        background-color: $white;
        @media (min-width: 992px) {
          border-right: 1px solid $border-color;
        }
      }

      .textile-form-field {
        border-left: 4px solid transparent;
        position: relative;
        transition: border 0.2s ease-in-out;

        .actions {
          top: 0;
          opacity: 0;
          padding: 0.5rem 0;
          position: absolute;
          left: -1.25rem;
          transition: opacity 0.2s ease-in-out;
        }

        .editor-field {
          margin: 0;

          &.sticky-toolbar .editor-toolbar {
            width: initial;
          }
        }

        &:hover {
          border-color: $light;

          .actions {
            opacity: 1;
          }
        }

        .textarea-container {
          margin: 0 1rem;

          textarea {
            min-height: 34px;
            resize: none;
          }
        }
      }
    }

    .textile-preview {
      padding: 0;
      overflow: auto;
      height: 100%;

      &.preview-placeholder {
        align-items: center;
        display: flex;
        height: 100%;
        justify-content: center;

        h5 {
          color: $text-muted;
          margin-bottom: 1.75rem;
        }
      }

      @include media-breakpoint-down(lg) {
        border-top: 1px solid $border-color;
        margin-top: 2rem;
        padding-top: 2rem;
      }
    }
  }

  ul.textile-toolbar {
    background: #fff;
    border-bottom: 0px;
    margin-bottom: 1em !important;

    li {
      a {
        border-radius: 3px;
        border: 0px none;
        color: $text-link;

        &:hover {
          background: #fff;
          border: 0px none;
          color: $text-link-hover;
        }

        &.active {
          background: darken($grey-900, 10%);
          color: #fff;
        }
      }
    }
  }
}
