/* Theme Variables
 ------------------------------------------ */
$border-color: $border-light;
$background-color: $light-100;

$img-margin-left: 10px;
$img-margin-right: 10px;

/* Layout
 ------------------------------------------ */
.note-editor {
  position: relative;
  background-color: $white;
  // dropzone
  $dropzone-color: lightskyblue;
  $dropzone-active-color: darken($dropzone-color, 30);
  .note-dropzone {
    position: absolute;
    display: none;
    z-index: 100;
    color: $dropzone-color;
    background-color: #fff;
    opacity: 0.95;

    .note-dropzone-message {
      display: table-cell;
      vertical-align: middle;
      text-align: center;
      font-size: 28px;
      font-weight: 700;
    }

    &.hover {
      color: $dropzone-active-color;
    }
  }

  &.dragover .note-dropzone {
    display: table;
  }

  .note-editing-area {
    position: relative;

    .note-editable {
      outline: none;

      sup {
        vertical-align: super;
      }

      sub {
        vertical-align: sub;
      }

      img.note-float-left {
        @if($rtl==false){
          margin-right: $img-margin-right;
        }
        @if($rtl==true){
          margin-left: $img-margin-right;
        }
      }

      img.note-float-right {
        @if($rtl==false){
          margin-left: $img-margin-left;
        }
        @if($rtl==true){
          margin-right: $img-margin-left;
        }
      }
    }
  }
}

/* Frame mode layout
 ------------------------------------------ */
.note-editor.note-frame,
.note-editor.note-airframe {
  border: 1px solid $border-color;
  border-radius: $border-radius;
  // codeview mode
  &.codeview {
    .note-editing-area {
      .note-editable {
        display: none;
      }
      .note-codable {
        display: block;
      }
    }
  }

  .note-editing-area {
    overflow: hidden;

    // editable
    .note-editable {
      padding: 10px;
      overflow: auto;
      word-wrap: break-word;

      &[contenteditable="false"] {
        background-color: $background-color;
      }
    }

    // codeable
    .note-codable {
      display: none;
      width: 100%;
      padding: 10px;
      border: none;
      box-shadow: none;
      font-family: Menlo, Monaco, monospace, sans-serif;
      font-size: 14px;
      color: #ccc;
      background-color: #222;
      resize: none;
      outline: none;

      // override BS2 default style
      @include box-sizing(border-box);
      @include rounded(0);
      margin-bottom: 0;
    }
  }

  // fullscreen mode
  &.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100% !important;
    z-index: 1050; // bs3 modal-backdrop: 1030, bs2: 1040
    .note-resizebar {
      display: none;
    }
  }

  // Notifications
  .note-status-output {
    display: block;
    width: 100%;
    font-size: 14px;
    line-height: 1.42857143;
    height: 20px;
    margin-bottom: 0;
    color: #000;
    border: 0;
    border-top: 1px solid #e2e2e2;
  }

  .note-status-output:empty {
    height: 0;
    border-top: 0 solid transparent;
  }

  .note-status-output .pull-right {
    float: right !important;
  }

  .note-status-output .text-muted {
    color: #777;
  }

  .note-status-output .text-primary {
    color: #286090;
  }

  .note-status-output .text-success {
    color: #3c763d;
  }

  .note-status-output .text-info {
    color: #31708f;
  }

  .note-status-output .text-warning {
    color: #8a6d3b;
  }

  .note-status-output .text-danger {
    color: #a94442;
  }

  .note-status-output .alert {
    margin: -7px 0 0 0;
    padding: 7px 10px 2px 10px;
    border-radius: 0;
    color: #000;
    background-color: #f5f5f5;
  }

  .note-status-output .alert .note-icon {
    margin-right: 5px;
  }

  .note-status-output .alert-success {
    color: #3c763d !important;
    background-color: #dff0d8 !important;
  }

  .note-status-output .alert-info {
    color: #31708f !important;
    background-color: #d9edf7 !important;
  }

  .note-status-output .alert-warning {
    color: #8a6d3b !important;
    background-color: #fcf8e3 !important;
  }

  .note-status-output .alert-danger {
    color: #a94442 !important;
    background-color: #f2dede !important;
  }

  // statusbar
  .note-statusbar {
    background-color: $background-color;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    border-top: 1px solid $border-color;
    .note-resizebar {
      padding-top: 1px;
      height: 9px;
      width: 100%;
      cursor: ns-resize;
      .note-icon-bar {
        width: 20px;
        margin: 1px auto;
        border-top: 1px solid $border-color;
      }
    }

    &.locked {
      .note-resizebar {
        cursor: default;
        .note-icon-bar {
          display: none;
        }
      }
    }
  }
  .note-placeholder {
    padding: 10px;
  }
}

.note-editor.note-airframe {
  border: 0;

  .note-editing-area {
    .note-editable {
      padding: 0;
    }
  }
}


/* Popover
 ------------------------------------------ */
.note-popover.popover {
  display: none;
  max-width: none;

  .popover-content {
    a {
      display: inline-block;
      max-width: 200px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap; // for FF
      vertical-align: middle; // for FF
    }
  }
  .arrow {
    @if($rtl==false){
      left: 20px !important;
    }
    @if($rtl==true){
      right: 20px !important;
    }
  }
}

/* Popover and Toolbar (Button container)
 ------------------------------------------ */
.note-toolbar {
  position: relative;
}

.note-popover .popover-content, .note-editor .note-toolbar {
  margin: 0;
  @if($rtl==false){
    padding: 0 0 .5rem .5rem;
  }
  @if($rtl==true){
    padding: 0 .5rem .5rem 0;
  }
  border-bottom: 1px solid $border-color;

  & > .note-btn-group {
    margin-top: .5rem;
    @if($rtl==false){
      margin-left: 0;
      margin-right: .5rem;
    }
    @if($rtl==true){
      margin-right: 0;
      margin-left: .5rem;
    }
  }

  .note-btn-group {
    .note-table {
      min-width: 0;
      padding: 5px;
      .note-dimension-picker {
        font-size: 18px;
        .note-dimension-picker-mousecatcher {
          position: absolute !important;
          z-index: 3;
          width: 10em;
          height: 10em;
          cursor: pointer;
        }
        .note-dimension-picker-unhighlighted {
          position: relative !important;
          z-index: 1;
          width: 5em;
          height: 5em;
          background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASAgMAAAAroGbEAAAACVBMVEUAAIj4+Pjp6ekKlAqjAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfYAR0BKhmnaJzPAAAAG0lEQVQI12NgAAOtVatWMTCohoaGUY+EmIkEAEruEzK2J7tvAAAAAElFTkSuQmCC") repeat;
        }
        .note-dimension-picker-highlighted {
          position: absolute !important;
          z-index: 2;
          width: 1em;
          height: 1em;
          background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASAgMAAAAroGbEAAAACVBMVEUAAIjd6vvD2f9LKLW+AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfYAR0BKwNDEVT0AAAAG0lEQVQI12NgAAOtVatWMTCohoaGUY+EmIkEAEruEzK2J7tvAAAAAElFTkSuQmCC") repeat;
        }
      }
    }
  }

  // dropdown-menu for toolbar and popover
  .note-dropdown-menu {
    min-width: 180px;

    // dropdown-menu right position
    // http://forrst.com/posts/Bootstrap_right_positioned_dropdown-2KB
    &.right {
      @if($rtl==false){
        right: 0;
        left: auto;
      }
      @if($rtl==true){
        left: 0;
        right: auto;
      }
      &::before {
        @if($rtl==false){
          right: 9px;
          left: auto !important;
        }
        @if($rtl==true){
          left: 9px;
          right: auto !important;
        }
      }
      &::after {
        @if($rtl==false){
          right: 10px;
          left: auto !important;
        }
        @if($rtl==true){
          left: 10px;
          right: auto !important;
        }
      }
    }
    // dropdown-menu for selectbox
    &.note-check {
      a i {
        color: deepskyblue;
        visibility: hidden;
      }
      a.checked i {
        visibility: visible;
      }
    }
  }

  .dropdown-style {
    min-width: 250px;
    padding: .5rem 0;
    blockquote, pre {
      margin: 0;
    }
    h1, h2, h3, h4, h5, h6, p {
      margin: 0;
      padding: 0;
    }
    h1{
      font-size :$h1-fs-lg - .75rem;
    }
    h2{
      font-size :$h2-fs-lg - .5rem;
    }
    h3{
      font-size :$h3-fs-lg - .25rem;
    }
    > li{
      padding: .25rem 1rem;
      &[aria-label="pre"]{
        border-bottom: 1px solid $border-color;
        margin-bottom: .5rem;
        padding-bottom: .75rem;
      }
    }
  }

  .dropdown-fontsize,.dropdown-line-height{
    min-width: 70px;
    padding: 0.75rem 0.325rem;
  }

  .note-color-all {
    .note-dropdown-menu {
      min-width: 326px;
      padding: 6px;
    }
    .note-current-color-button{
      padding-left: 0.4rem;
      padding-right: 0.4rem;
    }
    .note-recent-color{
      padding: 0 .25rem;
      border-radius: $border-radius/2;
    }
  }

  .note-color {
    .dropdown-toggle {
      width: 20px;
      @if($rtl==false){
        padding-left: 5px;
      }
      @if($rtl==true){
        padding-right: 5px;
      }
    }
    .note-dropdown-menu {
      .note-palette {
        display: inline-block;
        margin: 0;
        width: 156px;
        padding: 6px;

        .note-palette-title {
          font-size: 12px;
          margin: 2px 0;
          font-weight: 700;
        }

        .note-color-reset,
        .note-color-select {
          font-size: 11px;
          margin: 6px 0;
          padding: 0 6px;
          cursor: pointer;
          text-align: center;
          justify-content: center;
          width: 100%;
          height: 24px;
          @include rounded(3px);

          &:hover {
            background: $accent-color;
            border-color: $accent-color;
            color: $white;
          }
        }

        .note-color-row {
          height: 18px;
        }

        .note-color-select-btn {
          display: none;
        }

        .note-holder-custom {
          .note-color-btn {
            border: 1px solid #eee;
          }
        }
      }
    }
  }

  .note-para {
    .note-dropdown-menu {
      min-width: 245px;
      padding: 5px;
      & > div{
        margin: 5px;
      }
    }
  }


  .note-fontsize-10 {
    font-size: 10px;
  }

  // color palette for toolbar and popover
  .note-color-palette {
    line-height: 1;
    div {
      .note-color-btn {
        width: 18px;
        height: 18px;
        padding: 0;
        margin: 0;
        border: 0;
        border-radius: 0;
      }
      .note-color-btn:hover {
        transform: scale(1.2);
        transition: all 0.2s;
      }
    }
  }
}

/* Dialog
 ------------------------------------------ */
.note-modal {
  .modal-dialog {
    outline: 0;
    border-radius: 5px;
  }
  .form-group { // overwrite BS's form-horizontal minus margins
    margin-left: 0;
    margin-right: 0;
  }
  .note-modal-form {
    margin: 0; // overwrite BS2's form margin bottom
  }
  .note-image-dialog {
    .note-dropzone {
      min-height: 100px;
      font-size: 30px;
      line-height: 4; // vertical-align
      color: lightgray;
      text-align: center;
      border: 4px dashed lightgray;
      margin-bottom: 10px;
    }
  }

  // [workaround] firefox fileinput
  @-moz-document url-prefix() {
    .note-image-input {
      height: auto;
    }
  }

  .modal-header{
    position: relative;
    .close{
      position: absolute;
      @if($rtl==false){
        right: .5rem;
      }
      @if($rtl==true){
        left: .5rem;
      }
      top: 50%;
      transform: translateY(-50%);
      margin: 0;
    }
  }
  .note-form-label{
    margin-bottom: 0.75rem;
  }
  .checkbox{
    &:last-child{
      label{
        margin-bottom: 0;
      }
    }
    label{
      margin-bottom: 0.75rem;
    }
    input{
      @if($rtl==false){
        margin-right: 0.5rem;
      }
      @if($rtl==true){
        margin-left: 0.5rem;
      }
    }
  }
}

/* Placeholder
 ------------------------------------------ */
.note-placeholder {
  position: absolute;
  display: none;
  color: gray;
}

/* Handle
 ------------------------------------------ */
.note-handle {
  // control selection
  .note-control-selection {
    position: absolute;
    display: none;
    border: 1px solid #000;
    & > div {
      position: absolute;
    }

    .note-control-selection-bg {
      width: 100%;
      height: 100%;
      background-color: #000;
      @include opacity(0.3);
    }

    .note-control-handle {
      width: 7px;
      height: 7px;
      border: 1px solid #000;
    }

    .note-control-holder {
      @extend .note-control-handle;
    }

    .note-control-sizing {
      @extend .note-control-handle;
      background-color: #000;
    }

    .note-control-nw {
      top: -5px;
      @if($rtl==false){
        left: -5px;
        border-right: none;
      }
      @if($rtl==true){
        right: -5px;
        border-left: none;
      }
      border-bottom: none;
    }

    .note-control-ne {
      top: -5px;
      @if($rtl==false){
        right: -5px;
        border-left: none;
      }
      @if($rtl==true){
        left: -5px;
        border-right: none;
      }
      border-bottom: none;
    }

    .note-control-sw {
      bottom: -5px;
      @if($rtl==false){
        left: -5px;
        border-right: none;
      }
      @if($rtl==true){
        right: -5px;
        border-left: none;
      }
      border-top: none;
    }

    .note-control-se {
      @if($rtl==false){
        right: -5px;
      }
      @if($rtl==true){
        left: -5px;
      }
      bottom: -5px;
      cursor: se-resize;
    }

    .note-control-se.note-control-holder {
      cursor: default;
      border-top: none;
      @if($rtl==false){
        border-left: none;
      }
      @if($rtl==true){
        border-right: none;
      }
    }

    .note-control-selection-info {
      @if($rtl==false){
        right: 0;
      }
      @if($rtl==true){
        left: 0;
      }
      bottom: 0;
      padding: 5px;
      margin: 5px;
      color: #fff;
      background-color: #000;
      font-size: 12px;
      @include rounded(5px);
      @include opacity(0.7);
    }
  }
}

.note-hint-popover {
  min-width: 100px;
  padding: 2px;

  .popover-content {
    padding: 3px;
    max-height: 150px;
    overflow: auto;

    .note-hint-group {
      .note-hint-item {
        display: block !important;
        padding: 3px;

        &.active, &:hover {
          display: block;
          clear: both;
          font-weight: 400;
          line-height: 1.4;
          color: white;
          white-space: nowrap;
          text-decoration: none;
          background-color: #428bca;
          outline: 0;
          cursor: pointer;
        }
      }
    }
  }
}


// new selectors
.note-btn{
  .note-icon-caret{
    &:not(:only-child){
      @if($rtl==false){
        margin-left: 0.5rem;
        margin-right: -0.375rem;
      }
      @if($rtl==true){
        margin-right: 0.25rem;
        margin-left: -0.125rem;
      }
    }
  }
}