@import "styles/grouping";

@mixin spreadsheet-valo {
  $spreadsheet-default-font-color: valo-font-color($v-background-color) !default;
  $spreadsheet-base-font-family: $v-font-family !default;
  $spreadsheet-base-font-size: $v-font-size !default;

  $spreadsheet-border: valo-border($strength: 0.8) !default;

  $spreadsheet-header-bg-color: $v-background-color !default;
  $spreadsheet-header-border: $spreadsheet-border !default;
  $spreadsheet-header-grouping-color: #C7C7C7 !default;

  // Fixed size due to row/column sizing from POI model
  $spreadsheet-header-font-size: 13px !default;

  $spreadsheet-functionbar-background-color: valo-table-background-color() !default;
  $spreadsheet-functionbar-font-color: valo-font-color($spreadsheet-functionbar-background-color) !default;

  $spreadsheet-cell-background-color: valo-table-background-color() !default;

  $spreadsheet-sheet-selection-border-color: $v-selection-color !default;
  $spreadsheet-sheet-selection-corner-color: $v-selection-color !default;

  $spreadsheet-freeze-pane-border: 1px solid $spreadsheet-default-font-color !default;

  $spreadsheet-popupbutton-header-sizing: $spreadsheet-base-font-size + 4 !default;

  $spreadsheet-resize-line-color: $v-selection-color !default;

  $spreadsheet-cell-comment-triangle-color: #FFCF16 !default;

  $spreadsheet-cell-invalidformula-triangle-color: $v-error-indicator-color !default;

  // These colors should be derived from valo theme colors.
  // Unfortunately due to a bug in the sass compiler,
  // we can not call any sass color functions (like scale-color,
  // lighten etc.) using valo variables as function parameters.
  // Until the compiler is fixed we must just define the colors here.

  $spreadsheet-address-field-background: #fafafa !default;
  $spreadsheet-sheet-selector-background: #fafafa !default;
  $spreadsheet-inactive-tab-background: #fafafa !default;
  $spreadsheet-active-tab-background: #ffffff !default;
  $spreadsheet-inactive-tab-text-color: #6a6a6a !default;
  $spreadsheet-active-tab-text-color: #2584e2 !default;
  $spreadsheet-tab-action-button-color: #464646 !default;
  $spreadsheet-tab-action-button-inactive-color: #d6d6d6 !default;
  $spreadsheet-selected-header-bg-color: #e6edf4 !default;
  $spreadsheet-selected-header-border-color: #63b1ff !default;
  $spreadsheet-sheet-selection-extend-corner-color: #40b527 !default;
  $spreadsheet-sheet-selection-extend-inside-bg-color: rgba(235, 247, 233, 0.8) !default;
  $spreadsheet-sheet-selection-highlight-outline-color: #222222 !default;
  $spreadsheet-sheet-selection-range-bg-color: rgba(232, 242, 252, 0.8) !default;
  $spreadsheet-popup-button-arrow-color: #676767 !default;
  $spreadsheet-cell-comment-line-color: #A7A7A7 !default;
  $spreadsheet-fill-square-border: 2px solid $spreadsheet-cell-background-color;

  // Sizing of Spreadsheet parts
  // Fixed sizes due to row/column sizing from POI model
  $spreadsheet-col-header-height: 27px;
  $spreadsheet-row-header-width: 50px;
  $spreadsheet-toolbar-height: round(0.78 * $v-unit-size) !default; // 29px
  $spreadsheet-bottom-bar-height: round(0.76 * $v-unit-size) !default; // 28px
  $spreadsheet-address-input-width: round(11 * $v-font-size) !default; // 176px
  $spreadsheet-field-padding: floor($v-font-size / 3) !default; // 5px
  $spreadsheet-tab-action-button-width: round(0.70 * $v-unit-size) !default; // 26px
  $spreadsheet-status-label-width: round(5.40 * $v-unit-size) !default; // 200px
  $spreadsheet-tab-height: round(0.54 * $v-unit-size) !default; // 20px
  $spreadsheet-tab-min-width: round(1.35 * $v-unit-size) !default; // 50px
  $spreadsheet-tab-max-width: round(5.40 * $v-unit-size) !default; // 200px
  $spreadsheet-tab-padding-vertical: round(0.05 * $v-unit-size) !default; // 2px
  $spreadsheet-tab-padding-horizontal: round(0.16 * $v-unit-size) !default; // 6px
  $spreadsheet-status-label-font-size: 11px !default;
  $spreadsheet-border-width: max(1px, first-number($v-border)) !default; // at least 1px
  $spreadsheet-tab-font-size: round(0.38 * $v-unit-size) !default; // 14px

  // Fixed sizes (do not depend on valo unit/font sizing)
  $spreadsheet-selection-widget-border-width: 2px !default;
  $spreadsheet-selection-widget-corner-size: 6px !default;
  $spreadsheet-resize-handle-size: 3px !default;
  $spreadsheet-tab-border-radius: 5px !default;
  $spreadsheet-popup-button-size: 14px !default;
  $spreadsheet-popup-button-margin: 1px !default;
  $spreadsheet-popup-button-content-padding: 3px !default;
  $spreadsheet-popup-button-overlay-height: 275px;
  $spreadsheet-touch-corner-size: 7px !default;
  $spreadsheet-touch-corner-left-offset: 7px !default;
  $spreadsheet-touch-corner-bottom-offset: 7px !default;
  $spreadsheet-touch-corner-border-radius: 5px !default;
  $spreadsheet-toucharea-corner-size: 30px !default;
  $spreadsheet-toucharea-corner-left-offset: -10px !default;
  $spreadsheet-toucharea-corner-bottom-offset: -10px !default;
  $spreadsheet-fill-square-toucharea-size: 30px;
  $spreadsheet-fill-square-toucharea-offset: -15px;
  $spreadsheet-fill-square-size: 6px;
  $spreadsheet-fill-square-offset: -4px;
  $spreadsheet-fill-square-lr-offset: 11px;
  $spreadsheet-fill-square-top-offset: 20px;
  $spreadsheet-fill-square-bottom-offset: 8px;

  .v-spreadsheet {
    overflow: hidden;
    position: relative;

    padding-bottom: $spreadsheet-toolbar-height;
    padding-left: $spreadsheet-row-header-width;
    padding-top: $spreadsheet-toolbar-height + $spreadsheet-bottom-bar-height;

    border: $spreadsheet-border;
    font-family: $spreadsheet-base-font-family;
    font-size: $spreadsheet-base-font-size;
    color: $spreadsheet-default-font-color;

    &.hidefunctionbar {
      padding-top: $spreadsheet-col-header-height + $spreadsheet-border-width;

      .functionbar {
        height: 0;
        display: none;
      }

      .sheet {
        &.top-right-pane,
        &.top-left-pane {
          top: 0px;
        }
      }
      .corner {
        top: 0px;
      }
    }

    &.hidetabsheet {
      padding-bottom: 0px;

      .sheet-tabsheet {
        height: 0;
        display: none;
      }

      .sheet {
        &.bottom-right-pane {
          bottom: 0px;
        }
      }
    }

    > div {
      outline: none;
    }

    > div,
    .sheet > div {
      -webkit-touch-callout: none;
      @include user-select(none);
    }

    &.row-resizing,
    &.row-resizing div {
      cursor: row-resize;
    }

    &.col-resizing,
    &.col-resizing div {
      cursor: col-resize;
    }

    &.selecting {
      cursor: crosshair;
    }

    // FUNCTION BAR
    .functionbar {
      background-color: $spreadsheet-functionbar-background-color;
      border-bottom: $spreadsheet-border;
      height: $spreadsheet-toolbar-height;
      left: 0;
      position: absolute;
      top: 0;
      width: 100%;
      z-index: 200;

      .functionfield,
      .addressfield {
        @include box-sizing(border-box);
        font-size: $spreadsheet-base-font-size;
        height: 100%;
        width: 100%;
        padding: 0;
        padding-left: $spreadsheet-field-padding;
        border: none;
        color: $spreadsheet-functionbar-font-color;
        outline: none;
      }

      .fixed-left-panel {
        @include box-sizing(border-box);
        float: left;
        width: $spreadsheet-address-input-width;
        height: 100%;
        border-right: $spreadsheet-border;
        background: $spreadsheet-address-field-background;
      }

      .adjusting-right-panel {
        @include box-sizing(border-box);
        overflow: hidden;
        padding-right: $spreadsheet-field-padding;
        height: 100%;
      }

      .addressfield {
        text-align: center;
        background: $spreadsheet-address-field-background;
      }

      .functionfield {
        font: 400 14px/1.55 Helvetica;
      }

      .formulaoverlay {

        // Replicate input style

        font: 400 14px/1.55 Helvetica;
        position: absolute;
        top: 3px;
        left: 181px;
        pointer-events: none;

        //transparent
        color: rgba(0, 0, 0, 0);

        span {
          border-radius: 2px;
        }
      }

    }

    // SHEET (BOTTOM RIGHT PANE)
    .sheet {
      &.bottom-right-pane {
        overflow: scroll;
        right: 0;
        bottom: $spreadsheet-bottom-bar-height;
        position: absolute;
      }

      .cell {
        @include box-sizing(border-box);
        background-color: $spreadsheet-cell-background-color;
        border-right: $spreadsheet-border;
        border-bottom: $spreadsheet-border;
        overflow: visible;
        padding: 0 2px;
        position: absolute;
        white-space: nowrap;
        flex-direction: column;
        justify-content: flex-end;
        line-height: normal;

        &.selected-cell-highlight {
          outline: solid $spreadsheet-sheet-selection-highlight-outline-color 1px;
          -moz-outline-offset: -2px;
          outline-offset: -2px;
          z-index: 3;
        }

        > .v-button {
          overflow: hidden;
          text-overflow: ellipsis;
        }
      }

      div {
        &.cell.r {
          text-align: right;
        }

        &.merged-cell {
          display: block;
          overflow: hidden;
          z-index: 5 !important;
        }

        &.custom-editor-cell {
          padding: 2px;
        }
      }

      &.bottom-right-pane div.merged-cell {
        z-index: 5 !important;
      }

      > input[type="text"] {
        border: 0 !important;
        -webkit-box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.75);
        box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.75);
        cursor: text;
        display: block !important;
        outline: none !important;
        overflow: hidden;
        padding: 0 !important;
        position: absolute;
        z-index: 26 !important;
      }

      .floater {
        border-right: 0;
        border-bottom: 0;
        z-index: -1;
        background-color: white;
      }
    }

    &.nogrid .sheet .cell {
      border-right: 0px;
      border-bottom: 0px;
    }

    .top-left-pane div.merged-cell {
      z-index: 25 !important;
    }

    .top-right-pane div.merged-cell,
    .bottom-left-pane div.merged-cell {
      z-index: 15 !important;
    }

    // SHEET FREEZE PANES
    .top-left-pane,
    .top-right-pane,
    .bottom-left-pane {
      @include box-sizing(border-box);
      border-right: $spreadsheet-freeze-pane-border;
      border-bottom: $spreadsheet-freeze-pane-border;
      overflow: visible;
      position: absolute;

      &.inactive {
        border-right: 0;
        border-bottom: 0;
      }
    }

    .bottom-left-pane {
      height: 100%;
      left: 0;
      padding-bottom: $spreadsheet-bottom-bar-height;
      z-index: 10;

      .rh {
        left: 0;
        margin-top: 0 !important;
      }

      .cell, .sheet-image {
        margin-left: $spreadsheet-row-header-width;
      }

      .sheet-selection {
        margin-left: $spreadsheet-row-header-width + $spreadsheet-border-width;
      }
    }

    .top-left-pane {
      left: 0;
      top: 30px;
      z-index: 20;

      .ch {
        top: 0;
        margin-left: $spreadsheet-row-header-width;
      }

      .rh {
        left: 0;
        margin-top: $spreadsheet-col-header-height;
      }

      .cell, .sheet-image {
        margin-top: $spreadsheet-col-header-height;
        margin-left: $spreadsheet-row-header-width;
      }

      .sheet-selection {
        margin-top: $spreadsheet-col-header-height + $spreadsheet-border-width;
        margin-left: $spreadsheet-row-header-width + $spreadsheet-border-width;
      }
    }

    .top-right-pane {
      top: $spreadsheet-toolbar-height + $spreadsheet-border-width;
      width: 100%;
      z-index: 11;

      .ch {
        top: 0;
        margin-left: 0 !important;
      }

      .cell, .sheet-image {
        margin-top: $spreadsheet-col-header-height;
      }

      .sheet-selection {
        margin-top: $spreadsheet-col-header-height + $spreadsheet-border-width;
      }
    }

    &.noheaders {
      .top-left-pane, .top-right-pane {
        .cell, .sheet-image {
          margin-top: 0;
        }
        .sheet-selection {
          margin-top: $spreadsheet-border-width;
        }
      }

      .top-left-pane, .bottom-left-pane {
        .cell, .sheet-image {
          margin-left: 0;
        }
        .sheet-selection {
          margin-left: $spreadsheet-border-width;
        }
      }
    }

    // SHEET HEADERS
    .ch, .rh, .corner {
      background-color: $spreadsheet-header-bg-color;
      font-family: Helvetica;
      font-size: $spreadsheet-header-font-size;
      overflow: hidden;
      position: absolute;
      text-align: center;
    }

    .rh {
      @include box-sizing(border-box);
      @include user-select(none);
      border-right: $spreadsheet-header-border;
      cursor: e-resize;
      -webkit-touch-callout: none;
      width: $spreadsheet-row-header-width;
      z-index: 29;
      display: flex;
      justify-content: center;
      vertical-align: middle;
      flex-direction: column;
      line-height: 100%;

      &.selected-row-header {
        background: $spreadsheet-selected-header-bg-color !important;
        border-right: $spreadsheet-border-width * 2 solid $spreadsheet-selected-header-border-color;
      }

      .header-resize-dnd-first,
      .header-resize-dnd-second {
        background: transparent;
        cursor: row-resize;
        height: $spreadsheet-resize-handle-size;
        position: absolute;
        left: 0;
        width: $spreadsheet-row-header-width - $spreadsheet-border-width;
        z-index: 30;
      }

      .header-resize-dnd-first {
        top: 0;
      }

      .header-resize-dnd-second {
        border-bottom: $spreadsheet-header-border;
        bottom: 0;
      }

      &.resize-extra {
        border-bottom: $spreadsheet-header-border;
      }
    }

    .ch {
      @include valo-gradient($color: $spreadsheet-header-bg-color);
      @include box-sizing(border-box);
      @include user-select(none);
      border-bottom: $spreadsheet-header-border;
      cursor: s-resize;
      height: $spreadsheet-col-header-height;
      line-height: $spreadsheet-col-header-height;
      -webkit-touch-callout: none;
      z-index: 29;

      &.selected-column-header {
        background: $spreadsheet-selected-header-bg-color !important;
        border-bottom: $spreadsheet-border-width * 2 solid $spreadsheet-selected-header-border-color;
      }

      .header-resize-dnd-first,
      .header-resize-dnd-second {
        background: transparent;
        cursor: col-resize;
        height: $spreadsheet-col-header-height;
        position: absolute;
        top: 0;
        width: $spreadsheet-resize-handle-size;
        z-index: 30;
      }

      .header-resize-dnd-first {
        left: 0;
      }

      .header-resize-dnd-second {
        border-right: $spreadsheet-header-border;
        right: 0;
      }

      &.resize-extra {
        border-right: $spreadsheet-header-border;
      }
    }

    &.protected.lock-format-columns .ch,
    &.protected.lock-format-rows .rh {
      .header-resize-dnd-first,
      .header-resize-dnd-second {
        cursor: default;
      }
    }

    &.noheaders {
      padding-left: 0px;
      padding-top: $spreadsheet-toolbar-height + $spreadsheet-border-width;
      .ch, .rh, .corner {
        display: none;
      }
    }

    .ch.col1 .header-resize-dnd-first,
    .rh.row1 .header-resize-dnd-first {
      display: none;
    }

    > div.resize-line {
      background: $spreadsheet-resize-line-color;
    }

    .resize-line,
    .sheet > div.resize-line {
      border: none;
      height: 0;
      padding: 0;
      visibility: hidden;
      width: 0;
      z-index: 25;
      position: absolute;
    }

    &.col-resizing {
      .resize-line,
      .sheet > div.resize-line {
        height: 100%;
        visibility: visible;
        width: $spreadsheet-border-width;
      }

      > .resize-line {
        margin-left: $spreadsheet-row-header-width - $spreadsheet-border-width;
        margin-top: -($spreadsheet-col-header-height + $spreadsheet-border-width);
      }

      .sheet > div.resize-line {
        margin-left: -$spreadsheet-border-width;
      }
    }

    &.row-resizing {
      .resize-line, .sheet > div.resize-line {
        height: $spreadsheet-border-width;
        visibility: visible;
        width: 100%;
      }

      > .resize-line {
        margin-top: $spreadsheet-toolbar-height + $spreadsheet-bottom-bar-height - $spreadsheet-border-width;
        margin-left: -$spreadsheet-row-header-width;
      }

      .sheet > div.resize-line {
        margin-top: -$spreadsheet-border-width;;
      }
    }

    .corner {
      @include valo-gradient($color: $spreadsheet-header-bg-color);
      @include box-sizing(border-box);
      cursor: default;
      top: $spreadsheet-toolbar-height + $spreadsheet-border-width;
      left: 0;
      width: $spreadsheet-row-header-width;
      height: $spreadsheet-col-header-height;
      border-bottom: $spreadsheet-header-border;
      border-right: $spreadsheet-header-border;
      z-index: 100;
    }

    // SHEET IMAGES
    .sheet > div.sheet-image {
      background: transparent;
      border: none;
      cursor: default;
      height: auto;
      width: auto;
      position: absolute;
    }

    .bottom-right-pane.sheet > div.sheet-image {
      z-index: 10;
    }

    .top-left-pane > div.sheet-image {
      z-index: 25;
    }

    .top-right-pane,
    .bottom-left-pane {
      > div.sheet-image {
        z-index: 15;
      }
    }

    // CELL COMMENT
    .sheet {
      .cell-comment-triangle {
        border-color: transparent $spreadsheet-cell-comment-triangle-color transparent transparent;
        border-style: solid;
        border-width: 0 9px 9px 0;
        height: 0;
        line-height: 0;
        margin: 0;
        padding: 0;
        position: absolute;
        right: 0;
        top: 0;
        width: 0;
        z-index: 1;
      }

      .cell-invalidformula-triangle {
        border-color: transparent $spreadsheet-cell-invalidformula-triangle-color transparent transparent;
        border-style: solid;
        border-width: 0 9px 9px 0;
        height: 0;
        line-height: 0;
        margin: 0;
        padding: 0;
        position: absolute;
        right: 0;
        top: 0;
        width: 0;
        z-index: 2;
      }

      .comment-overlay-line {
        background-color: $spreadsheet-cell-comment-line-color !important;
        border: none !important;
        display: block !important;
        height: 1px;
        padding: 0;
        position: absolute;
        -webkit-transform-origin: 0% 50%;
        -ms-transform-origin: 0% 50%;
        transform-origin: 0% 50%;
        z-index: 21;
      }
    }

    // SELECTION WIDGET
    div.sheet-selection {
      background-color: transparent !important;
      border: none !important;
      display: block;
      position: absolute;
      width: 0px;
      height: 0px;
      overflow: visible;
      pointer-events: none;
      margin-left: $spreadsheet-border-width;
      margin-top: $spreadsheet-border-width;

      &.col0.row0 {
        display: none;
      }
    }

    &.notfocused .sheet-selection {
      opacity: 0.6;
    }

    .sheet-selection {
      .s-top, .s-left, .s-bottom, .s-right {
        padding: 0;
        background-color: $spreadsheet-sheet-selection-border-color;
        position: absolute;

        &.extend {
          background-color: $spreadsheet-sheet-selection-extend-corner-color !important;
        }
      }

      .s-top {
        top: -$spreadsheet-selection-widget-border-width;
        left: -$spreadsheet-selection-widget-border-width;
        height: $spreadsheet-selection-widget-border-width;
        pointer-events: all;
      }

      .s-left {
        width: $spreadsheet-selection-widget-border-width;
        padding-bottom: 1px;
      }

      .s-bottom {
        height: $spreadsheet-selection-widget-border-width;
        bottom: 0;
      }

      .s-right {
        right: 0;
        width: $spreadsheet-selection-widget-border-width;
      }

      .s-corner {
        background-color: $spreadsheet-sheet-selection-extend-corner-color;
        position: absolute;
        bottom: -2px;
        left: -2px;
        height: $spreadsheet-selection-widget-corner-size;
        width: $spreadsheet-selection-widget-corner-size;
        outline: 2px solid white;
        cursor: crosshair;
      }

      &.paintmode {
        background-color: $spreadsheet-sheet-selection-extend-inside-bg-color !important;
        .s-top, .s-left, .s-bottom, .s-right {
          background-color: $spreadsheet-sheet-selection-extend-corner-color;
        }
      }
    }

    // SHEET TABSHEET
    .sheet-tabsheet {
      background: $spreadsheet-sheet-selector-background;
      border-top: $spreadsheet-border;
      height: $spreadsheet-bottom-bar-height;
      width: 100%;
      cursor: default;
      position: absolute;
      bottom: 0;
      left: 0;
      overflow: hidden;
      z-index: 50;

      .sheet-tabsheet-options {
        background: $spreadsheet-sheet-selector-background;
        cursor: pointer;
        display: inline-block;
        height: $spreadsheet-bottom-bar-height;
        position: absolute;
        width: $spreadsheet-tab-action-button-width * 5;
        z-index: 60;
        left: 0;
        top: 0;

        div {
          line-height: $spreadsheet-bottom-bar-height + $spreadsheet-border-width;
          width: $spreadsheet-tab-action-button-width;
          cursor: pointer;
          display: inline-block;
          font-weight: bold;
          position: relative;
          text-align: center;
          z-index: inherit;

          color: $spreadsheet-tab-action-button-color;
          font-family: FontAwesome;

          &.scroll-tabs-beginning::before {
            content: "\f053\f053";
          }

          &.scroll-tabs-end::before {
            content: "\f054\f054";
          }

          &.scroll-tabs-left::before {
            content: "\f053";
          }

          &.scroll-tabs-right::before {
            content: "\f054";
          }

          &.add-new-tab::before {
            content: "\f067";
          }

          &:hover {
            color: $spreadsheet-sheet-selection-border-color;
          }

          &.hidden {
            color: $spreadsheet-tab-action-button-inactive-color;
            cursor: default;
          }
        }
      }

      .sheet-tabsheet-container {
        @include transition(margin-left 200ms);
        display: inline-block;
        left: $spreadsheet-tab-action-button-width * 5;
        position: absolute;
        z-index: inherit;
        margin-right: $spreadsheet-status-label-width + $spreadsheet-field-padding + $spreadsheet-border-width;
        height: $spreadsheet-tab-height + 2 * $spreadsheet-tab-padding-vertical + $spreadsheet-border-width;
        overflow: hidden;
        white-space: nowrap;

        .sheet-tabsheet-tab {
          font-family: $spreadsheet-base-font-family;
          font-size: $spreadsheet-tab-font-size;
          font-weight: 300;
          background: $spreadsheet-inactive-tab-background;
          color: $spreadsheet-inactive-tab-text-color;
          border: $spreadsheet-border;
          border-top: none;
          border-bottom-right-radius: $spreadsheet-tab-border-radius;
          border-bottom-left-radius: $spreadsheet-tab-border-radius;
          cursor: pointer;
          display: inline-block;
          height: $spreadsheet-tab-height;
          margin-left: $spreadsheet-field-padding;
          max-width: $spreadsheet-tab-max-width;
          min-width: $spreadsheet-tab-min-width;
          overflow: hidden;
          padding: $spreadsheet-tab-padding-vertical $spreadsheet-tab-padding-horizontal;
          position: relative;
          text-align: center;
          text-overflow: ellipsis;
          top: -$spreadsheet-border-width;
          z-index: inherit;

          &.selected-tab {
            background: $spreadsheet-active-tab-background;
            cursor: default;
            color: $spreadsheet-active-tab-text-color;
            max-width: none;
            position: relative;

            input[type="text"] {
              font-family: $spreadsheet-base-font-family;
              font-size: $spreadsheet-tab-font-size;
              color: $spreadsheet-active-tab-text-color;
              border: none !important;
              font-weight: 300;
              height: $spreadsheet-tab-height;
              outline: none !important;
              padding: 0 !important;
              position: relative;
              top: 0;
              left: 0;
              width: inherit;
            }
          }
        }
      }

      .sheet-tabsheet-temp {
        font-family: $spreadsheet-base-font-family;
        font-size: $spreadsheet-tab-font-size;
        display: inline;
        left: -5000px;
        position: fixed;
        white-space-collapse: preserve;
      }

      .sheet-tabsheet-infolabel {
        background: $spreadsheet-sheet-selector-background;
        z-index: inherit;
        position: absolute;
        right: 0;
        font-weight: bold;
        font-size: $spreadsheet-status-label-font-size;
        border-left: $spreadsheet-border;
        padding-left: $spreadsheet-field-padding;
        padding-right: $spreadsheet-field-padding;
        width: $spreadsheet-status-label-width;
        height: 100%;
        line-height: $spreadsheet-bottom-bar-height + $spreadsheet-border-width;
        display: inline;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
    }

    .sheet-tabsheet,
    .sheet-tabsheet div {
      -webkit-touch-callout: none;
      @include user-select(none);
    }

    // FILTER BUTTON
    .sheet div div.popupbutton {
      @include valo-button-style($padding: 0);
      @include valo-button-static-style();

      position: absolute;
      bottom: $spreadsheet-popup-button-margin;
      right: $spreadsheet-popup-button-margin;
      cursor: pointer;
      height: $spreadsheet-popup-button-size;
      width: $spreadsheet-popup-button-size;
      outline: none;
      background: url(triangle-inactive.png);
      background-size: 100% 100%;
      box-shadow: none;
      border:none;
    }

    // FILTER ACTIVE BUTTON
    .sheet div div.popupbutton.active {
      background: url(triangle-active.png);
      background-size: 100% 100%;
    }

    // TOUCH STYLES
    .sheet-selection.touch {
      &.fill {
        .fill-touch-square {
          position: relative;
          width: $spreadsheet-fill-square-toucharea-size;
          height: $spreadsheet-fill-square-toucharea-size;
          margin-left: $spreadsheet-fill-square-toucharea-offset;
          top: $spreadsheet-fill-square-toucharea-offset;
          > .square {
            position: absolute;
            background-color: $spreadsheet-sheet-selection-extend-corner-color;
            width: $spreadsheet-fill-square-size;
            height: $spreadsheet-fill-square-size;
            border: $spreadsheet-fill-square-border;
            top: $spreadsheet-fill-square-offset;
          }
        }
        .s-right, .s-left {
          > .fill-touch-square {
            top: 50%;
            margin-top: $spreadsheet-fill-square-toucharea-offset;
            > .square {
              top: $spreadsheet-fill-square-lr-offset;
              left: $spreadsheet-fill-square-lr-offset;
            }
          }
        }
        .s-top {
          > .fill-touch-square {
            top: -$spreadsheet-fill-square-top-offset;
            left: 50%;
            > .square {
              left: 50%;
              margin-top: $spreadsheet-fill-square-top-offset;
              margin-left: $spreadsheet-fill-square-offset;
            }
          }
        }
        .s-bottom {
          > .fill-touch-square {
            top: -$spreadsheet-fill-square-bottom-offset;
            left: 50%;
            > .square {
              left: 50%;
              margin-top: $spreadsheet-fill-square-bottom-offset;
              margin-left: $spreadsheet-fill-square-offset;
            }
          }
        }
      }

      .s-corner {
        width: $spreadsheet-touch-corner-size;
        height: $spreadsheet-touch-corner-size;
        left: $spreadsheet-touch-corner-left-offset;
        bottom: $spreadsheet-touch-corner-bottom-offset;
        background-color: $spreadsheet-sheet-selection-corner-color;
        border-radius: $spreadsheet-touch-corner-border-radius;
      }

      .s-corner-touch {
        width: $spreadsheet-toucharea-corner-size;
        height: $spreadsheet-toucharea-corner-size;
        position: absolute;
        left: $spreadsheet-toucharea-corner-left-offset;
        bottom: $spreadsheet-toucharea-corner-bottom-offset;
      }
    }

    @include grouping;
  }

  // CELL COMMENT OVERLAY STYLES
  .v-spreadsheet-comment-overlay {
    @include valo-overlay-style;
    padding: round($spreadsheet-base-font-size / 2);
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;

    .popupContent {
      overflow: visible;
    }

    .comment-overlay-author {
      padding-bottom: round($spreadsheet-base-font-size / 2);
      font-size: round($spreadsheet-base-font-size * 0.75);
      font-weight: bold;
      white-space: nowrap;
    }

    .comment-overlay-invalidformula {
      color: $v-error-indicator-color;
      max-width: 12 * $spreadsheet-base-font-size;
      max-height: 10 * $spreadsheet-base-font-size;
      white-space: pre-wrap;
      word-wrap: break-word;
    }

    .comment-overlay-label {
      max-width: 12 * $spreadsheet-base-font-size;
      max-height: 10 * $spreadsheet-base-font-size;
      white-space: pre-wrap;
      word-wrap: break-word;
    }

    .comment-overlay-input {
      max-width: 12 * $spreadsheet-base-font-size;
      max-height: 10 * $spreadsheet-base-font-size;
      font-family: $spreadsheet-base-font-family;
      font-size: $spreadsheet-base-font-size;
      font-weight: 300;
      outline: none;
      border: none;
    }

    .comment-overlay-separator {
      border-bottom: $spreadsheet-border;
      margin-bottom: 7px;
    }
  }

  // FILTER OVERLAY STYLES
  .v-spreadsheet-popupbutton-overlay {
    @include valo-overlay-style;

    .v-panel.spreadsheet-item-filter-layout {
      background-color: transparent;
      border: none;
      height: $spreadsheet-popup-button-overlay-height;

      .v-panel-captionwrap,
      .v-panel-content,
      .v-panel-deco {
        background-color: transparent;
        border: none;
      }
    }
  }

  .v-spreadsheet-popupbutton-overlay-header {
    background: $spreadsheet-popup-overlay-bg-color;
    height: $spreadsheet-popupbutton-header-sizing;
    position: relative;
    width: 100%;
    padding-bottom: round($spreadsheet-base-font-size / 2);

    .v-window-closebox {
      position: absolute;
      left: 0px;
      top: 0px;
      width: $spreadsheet-popupbutton-header-sizing;
      height: $spreadsheet-popupbutton-header-sizing;
      line-height: $spreadsheet-popupbutton-header-sizing;
    }

    .header-caption {
      margin: 0 $spreadsheet-popupbutton-header-sizing;
      height: $spreadsheet-popupbutton-header-sizing;
      line-height: $spreadsheet-popupbutton-header-sizing;
      text-align: center;
    }
  }

  .cell-range-bg-color {
    background-color: $spreadsheet-sheet-selection-range-bg-color;
  }

}
