/*
 * Copyright (c) 2008-2016 Haulmont.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

@mixin halo-cuba-listeditor($primary-stylename: c-listeditor) {
  .#{$primary-stylename} {
    display: inline-table;
  }

  .#{$primary-stylename}-layout {
    display: table-row;
  }

  .v-textfield.#{$primary-stylename}-text {
    @if $v-textfield-background-color {
      background: $v-textfield-background-color;
    }

    color: valo-font-color($v-textfield-background-color);

    border-top-right-radius: 0;
    border-bottom-right-radius: 0;

    @include box-shadow(valo-bevel-and-shadow(
            $bevel: $v-textfield-bevel,
            $shadow: $v-textfield-shadow,
            $background-color: $v-textfield-background-color, $gradient: none));
    &:focus {
      @include valo-textfield-focus-style;
    }
  }

  .v-button.#{$primary-stylename}-button {
    display: table-cell !important;
    text-align: center !important;
    vertical-align: middle;
    overflow: hidden;
    padding: 0;
    width: $v-unit-size;
    min-width: $v-unit-size;

    border: valo-border($v-textfield-border,
                darkest-color($v-textfield-background-color, $v-app-background-color));

    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;

    border-left: 0;

    color: mix($v-textfield-background-color, valo-font-color($v-textfield-background-color));
    background: $v-textfield-background-color;
    @include box-shadow(valo-bevel-and-shadow(
                $bevel: $v-textfield-bevel,
                $shadow: $v-textfield-shadow,
                $background-color: $v-textfield-background-color,
                $gradient: none));

    .v-ie8 & {
      background-color: $v-textfield-background-color;
    }

    @if $v-hover-styles-enabled and type-of($v-textfield-background-color) == color {
      &:hover {
        color: valo-font-color($v-textfield-background-color);
      }
    }

    &:after,
    &:hover:after {
      background: transparent;

      border: 0;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;

      height: $v-unit-size;
    }

    &:before {
      height: 100% !important;
    }

    &:focus:after {
      border-color: transparent;
      @include box-shadow(none);
    }

    &:active:after {
      @if type-of($v-textfield-background-color) == color {
        @include valo-button-active-style($v-textfield-background-color);
      }
    }

    .v-button-caption {
      display: none;
    }
  }

  .#{$primary-stylename}-layout .v-slot-c-listeditor-button:last-child > .v-button.#{$primary-stylename}-button {
    border-top-right-radius: $v-border-radius;
    border-bottom-right-radius: $v-border-radius;

    &:focus {
      border-top-right-radius: $v-border-radius;
      border-bottom-right-radius: $v-border-radius;
    }
  }

  .#{$primary-stylename}.v-customcomponent-error{
    .v-textfield.v-textfield-readonly {
      @include valo-textfield-error-style;
    }
  }

  .#{$primary-stylename}.v-readonly {
    .v-textfield.v-textfield-readonly {
      @include valo-textfield-readonly-style;
    }
  }

  .#{$primary-stylename}.v-disabled {
    .v-button:hover {
      color: mix($v-textfield-background-color, valo-font-color($v-textfield-background-color));
    }
  }
}