/*
 * 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.
 *
 */

/**
 * The size of option group.
 * @group optiongroup
 */
$cuba-optiongroup-size: $v-unit-size/2 !default;

@mixin halo-optiongroup($primary-stylename: v-select-optiongroup) {
  .#{$primary-stylename} {
    .v-radiobutton {
      :root & {
        line-height: $cuba-optiongroup-size;
        padding-left: round($cuba-optiongroup-size * 1.33);
      }

      :root & > input {
        & ~ label:before {
          height: round($cuba-optiongroup-size);
          width: round($cuba-optiongroup-size);
        }

        & ~ label:after {
          width: $cuba-optiongroup-size;
          height: $cuba-optiongroup-size;
          top: 0;
          left: 0;
        }

        &:checked ~ label:after {
          $factor: $cuba-optiongroup-size * 2 / $v-unit-size;
          $size: ceil(($cuba-optiongroup-size * $factor) / 3);
          $offset: round($cuba-optiongroup-size / (3 * $factor));

          width: $size;
          height: $size;
          top: $offset;
          left: $offset;
        }
      }
    }
  }

  .#{$primary-stylename}-horizontal {
    white-space: nowrap;

    .v-select-option:last-child {
      margin-right: 0;
    }
  }
}