/*
 * 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 modal window header background.
 * @group window
 */
$cuba-window-modal-header-background: null !default;
/**
 * The modal window header font weight.
 * @group window
 */
$cuba-window-modal-header-font-weight: $v-font-weight !default;
/**
 * The modal window header font size.
 * @group window
 */
$cuba-window-modal-header-font-size: $v-font-size !default;
/**
 * The modal window header height.
 * @group window
 */
$cuba-window-modal-header-height: $v-unit-size !default;
/**
 * The modal window header line height.
 * @group window
 */
$cuba-window-modal-header-line-height: $cuba-window-modal-header-height - 1px !default;
/**
 * The modal window buttons line height.
 * @group window
 */
$cuba-window-modal-header-buttons-line-height: $cuba-window-modal-header-line-height - 3px !default;
/**
 * The non modal window shadow.
 * @group window
 */
$v-window-nonmodal-shadow: 0 0 20px rgba(0, 0, 0, 0.5) !default;

@mixin halo-window($primary-stylename: v-window) {
  .#{$primary-stylename}-contents {
    padding-left: round($v-unit-size/2);
    padding-right: round($v-unit-size/2);

    & > .v-scrollable > .v-layout:first-child {
      padding-top: round($v-unit-size/3);
    }
  }

  .#{$primary-stylename}-nonmodal {
    @include box-shadow($v-window-nonmodal-shadow);
  }

  .#{$primary-stylename}-footer {
    padding-bottom: round($v-unit-size/2);
  }

  .#{$primary-stylename}-outerheader:after {
    display: none;
  }

  .#{$primary-stylename}-outerheader {
    border-bottom: valo-border();

    @if ($cuba-window-modal-header-background == null) {
      $background-color: $v-table-background-color or valo-table-background-color();
      $bg-lightness: if(color-luminance($background-color) < 10, 4%, -4%);
      $cuba-window-modal-header-background: scale-color($background-color, $lightness: $bg-lightness);
    }
    background-color: $cuba-window-modal-header-background;

    .v-mac & {
        border-radius: $v-window-border-radius $v-window-border-radius 0 0;
    }
  }

  .#{$primary-stylename}-outerheader .#{$primary-stylename}-header .v-icon {
    margin-right: ceil($v-layout-margin-right/2);
  }

  .#{$primary-stylename}-outerheader {
    .#{$primary-stylename}-closebox,
    .#{$primary-stylename}-maximizebox,
    .#{$primary-stylename}-restorebox,
    .#{$primary-stylename}-header {
      color: inherit;
      background-color: inherit;
      height: $cuba-window-modal-header-height;
    }

    .#{$primary-stylename}-header {
      font-weight: $cuba-window-modal-header-font-weight;
      font-size: $cuba-window-modal-header-font-size;
      line-height: $cuba-window-modal-header-line-height;
    }

    .#{$primary-stylename}-closebox,
    .#{$primary-stylename}-maximizebox,
    .#{$primary-stylename}-restorebox {
      line-height: $cuba-window-modal-header-buttons-line-height;
    }

    .v-mac & {
      .#{$primary-stylename}-header {
        border-top-left-radius: $v-window-border-radius;
      }
    }
  }

  @if ($v-window-animations-enabled == false) {
    .#{$primary-stylename} {
      @include animation(none);
      @include transition(none);

      &[class*="animate-in"] {
        @include animation(none);
      }
      &[class*="animate-out"] {
        @include animation(none);
      }
    }

    .#{$primary-stylename}-modalitycurtain {
      @include animation(none);
    }
  }

  .#{$primary-stylename}-modalitycurtain {
    background-image: none;
  }
}