@border-style: 1px solid #e0e2e4;
@icon-size: 18px;

body {
  margin: 0;
}

.spreadsheet {
  font-size: 14px;
  line-height: normal;
  user-select: none;
  -moz-user-select: none;
  font-family: Roboto, Helvetica, Arial, sans-serif;

  .spreadsheet-table {
    position: relative;
  }

  .spreadsheet-fixed {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    background: #fff;

    .spreadsheet-fixed-body {
      overflow: hidden;
    }
    .spreadsheet-fixed-header {
      overflow: hidden;  
    }
  }

  .spreadsheet-body {
    overflow: scroll;
    position: relative;
  }
  .spreadsheet-header {
    overflow: hidden;
    width: 100%;
  }

  .spreadsheet-header, .spreadsheet-body, .spreadsheet-fixed {

    table {
      table-layout: fixed;
      text-align: left;
      width: 100%;
      border-collapse: separate;
      border-spacing: 0;
      color: #000;
  
      td, th {
        transition: background .1s ease,color .1s ease;
        border-bottom: @border-style;
        border-right: @border-style;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        padding: 0 4px;
        // height: 22px;
        line-height: 22px;
      }
  
      td.active, th.active {
        background: rgba(75, 137, 255, .05)!important;
      }
  
      th {
        border-top: @border-style;
        text-align: center;
      }
  
      th, td:first-child {
        font-size: 12px;
        background: #f4f5f8;
        font-weight: normal;
        color: #666;
      }
  
      td:first-child, th:first-child {
        border-left: @border-style;
        text-align: center;
      }
    }
  }

}

.spreadsheet-editor {
  position: absolute;
  text-align: left;
  // z-index: 10;
  border: 2px solid rgb(75, 137, 255);
  line-height: 0;
  z-index: 10;

  textarea {
    box-sizing: content-box;
    border: none;
    padding: 0 3px;
    outline-width: 0;
    resize: none;
    text-align: start;
    // max-width: 500px;
    overflow-y: hidden;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    white-space: normal;
    word-wrap: break-word;
    line-height: 22px;
    margin: 0;
  }
}

.spreadsheet-suggest, .spreadsheet-contextmenu {
  position: absolute;
  box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);
  background: #fff;
  z-index: 100;
}

.spreadsheet-resizer {
  position: absolute;
  z-index: 11;
  &.horizontal {
    cursor: row-resize;
  }
  &.vertical {
    cursor: col-resize;
  }
}
.spreadsheet-resizer-line {
  position: absolute;
  z-index: 100;
  &.horizontal {
    border-bottom: 2px dashed rgb(75, 137, 255);
  }
  &.vertical {
    border-right: 2px dashed rgb(75, 137, 255);
  }
}

.spreadsheet-borders {
  box-sizing: content-box;

  &.dashed {
    border: 2px dashed rgb(75, 137, 255);
    position: absolute;
    background: rgba(75, 137, 255, 0.03);
  }

  .left-border, .right-border, .bottom-border, .top-border, .area-border {
    position: absolute;
    font-size: 0;
    pointer-events: none;
    background: rgb(75, 137, 255);
  }

  .area-border {
    background: rgba(75, 137, 255, 0.03);
  }

  .corner {
    cursor: crosshair;
    font-size: 0;
    height: 5px;
    width: 5px;
    border: 2px solid rgb(255, 255, 255);
    position: absolute;
    bottom: -6px;
    right: -6px;
    background: rgb(75, 137, 255);
    // z-index: 12;
  }

  .copy-border {
    position: absolute;
    pointer-events: none;
    border: 1px dashed rgb(75, 137, 255);
    background: rgba(75, 137, 255, .03);
  }
}

.spreadsheet-paint-border {
  position: absolute;
  pointer-events: none;
  border: 1px dashed rgb(75, 137, 255);
  background: rgba(75, 137, 255, .03);
}

.spreadsheet-bars {
  .spreadsheet-toolbar {
    // width: 100%;
    height: 40px;
    text-align: left;
    padding: 0 60px;
    border-bottom: @border-style;
    background: #f5f6f7;

    >.spreadsheet-menu > .spreadsheet-item {
      margin: 7px 1px 0;
    }

  }
  .spreadsheet-editor-bar {
    width: 100%;
    height: 26px;
    line-height: 26px;
    position: relative;
    background: #fff;
    padding: 0;
  }
}

.spreadsheet-formula-bar {
  position: relative;
  height: 100%;

  .spreadsheet-formula-label {
    width: 60px;
    height: 100%;
    box-sizing: border-box;
    display: inline-block;
    text-align: center;
    // line-height: inherit;
    border-right: 1px solid #e0e2e4;
    background-color: #fff;
    font-size: 12px;
    color: #777;
    user-select: none;
    float: left;
    vertical-align: middle;
  }

  textarea {
    width: calc(~'100% - 60px');
    height: 100%;
    box-sizing: border-box;
    font-family: inherit;
    font-size: inherit;
    padding: 4px 10px;
    position: relative;
    float: left;
    resize: none;
    overflow-y: hidden;
    border: none;
    outline-width: 0;
    margin: 0;
  }
}
.spreadsheet-formula-bar-resizer {
  cursor: ns-resize;
  // border-bottom: 1px solid #c0c0c0;
  height: 4px;
  position: absolute;
  width: 100%;
  left: 0;
  bottom: 0;
}


.spreadsheet-menu {
  &.vertical {
    > .spreadsheet-item-separator {
      background: #e0e2e4;
      height: 1px;
      margin: 5px 0;
    }
    > .spreadsheet-item {
      padding: 2px 10px;
      border-radius: 0;
      // border-top: 1px solid #fafafa;
    }
  }
  &.horizontal {
    > .spreadsheet-item {
      display: inline-block;
    }
    > .spreadsheet-item-separator {
      display: inline-block;
      background: #e0e2e4;
      width: 1px;
      vertical-align: middle;
      height: 18px;
      margin: 0 3px;
    }
  }
  > .spreadsheet-item {
    border-radius: 2px;
    user-select: none;
    background: 0;
    border: 1px solid transparent;
    outline: none;
    height: 24px;
    color: rgba(0, 0, 0, .8);
    line-height: 24px;
    list-style: none;
    // font-weight: bold;
    cursor: default;

    &.disabled {
      pointer-events: none;
      opacity: 0.5;
    }

    &:not(.separator):hover, &.active {
      background: rgba(0, 0, 0, .08);
      // color: rgba(0, 0, 0, 0.7);
      .spreadsheet-icon-img {
        opacity: 0.7;
      }

      .spreadsheet-dropdown-icon {
        background-color: rgba(0, 0, 0, .15);
        opacity: 0.6;
      }
    }
    
    > .label {
      float: right;
      opacity: .8;
    }
  }

}

.spreadsheet-dropdown {
  position: relative;
  display: inline-block;
  width: auto!important;

  .spreadsheet-dropdown-content {
    position: absolute;
    top: calc(~'100% + 5px');
    left: 0;
    z-index: 200;
    background: #fff;
    box-shadow: 1px 2px 5px 2px rgba(51,51,51,.15);
    width: auto;
  }

  .spreadsheet-dropdown-header {
    .spreadsheet-dropdown-title {
      padding: 0 5px;
      display: inline-block;
    }
    // > .spreadsheet-icon {
    //   width: 18px;
    //   height: 16px;
    // }
    
    .spreadsheet-dropdown-icon {
      display: inline-block;
      vertical-align: top;
      // border: 1px solid transparent;
      .spreadsheet-icon {
        width: 10px;
        .arrow-down {
          left: -7 * @icon-size - 4px;
        }
      }
    }
  }
}

.spreadsheet-color-panel {
  padding: 10px;
  width: 100%;

  table {
    border-collapse: separate;
    border-spacing: 0;
    border: none;
  }

  table tr td {
    padding: 0;
    border: none;

  }

  .color-cell {
    width: 20px;
    height: 20px;
    margin: 3px;

    &:hover {
      box-shadow: 0 0 2px rgba(0,0,0,.8);
    }
  }
}

.spreadsheet-icon {
  height: 18px;
  width: 18px;
  margin: 0px 4px 3px 3px;
  direction: ltr;
  text-align: left;
  user-select: none;
  vertical-align: middle;
  overflow: hidden;
  position: relative;
  display: inline-block;
}
.spreadsheet-icon-img {
  background-image: url('../assets/sprite.svg');
  position: absolute;
  width: 262px;
  height: 444px;
  opacity: 0.55;

  &.undo {
    left: 0;
    top: 0;
  }
  &.redo {
    left: -1 * @icon-size;
    top: 0;
  }
  &.print {
    left: -2 * @icon-size;
    top: 0;
  }
  &.paintformat {
    left: -3 * @icon-size;
    top: 0;
  }
  &.clearformat {
    left: -4 * @icon-size;
    top: 0;
  }
  &.bold {
    left: -5 * @icon-size;
    top: 0;
  }
  &.italic {
    left: -6 * @icon-size;
    top: 0;
  }
  &.underline {
    left: -7 * @icon-size;
    top: 0;
  }
  &.strikethrough {
    left: -8 * @icon-size;
    top: 0;
  }
  &.text-color {
    left: -9 * @icon-size;
    top: 0;
  }
  &.cell-color {
    left: -10 * @icon-size;
    top: 0;
  }
  &.merge {
    left: -11 * @icon-size;
    top: 0;
  }
  &.align-left {
    left: -12 * @icon-size;
    top: 0;
  }
  &.align-center {
    left: -13 * @icon-size;
    top: 0;
  }
  &.align-right {
    left: 0;
    top: -1 * @icon-size;
  }
  &.valign-top {
    left: -1 * @icon-size;
    top: -1 * @icon-size;
  }
  &.valign-middle {
    left: -2 * @icon-size;
    top: -1 * @icon-size;
  }
  &.valign-bottom {
    left: -3 * @icon-size;
    top: -1 * @icon-size;
  }
  &.textwrap {
    left: -4 * @icon-size;
    top: -1 * @icon-size;
  }
  &.autofilter {
    left: -5 * @icon-size;
    top: -1 * @icon-size;
  }
  &.formula {
    left: -6 * @icon-size;
    top: -1 * @icon-size;
  }
  &.arrow-down {
    left: -7 * @icon-size;
    top: -1 * @icon-size;
  }
  &.arrow-right {
    left: -8 * @icon-size;
    top: -1 * @icon-size;
  }
}