/*
 * Copyright (c) 2021 Dmitry Barashev, BarD Software s.r.o.
 *
 * This file is part of GanttProject, an open-source project management tool.
 *
 * GanttProject is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 * GanttProject is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GanttProject.  If not, see <http://www.gnu.org/licenses/>.
 */
@import "theme";

@mixin btn-normal($border: derive($gp-light-gray, -20%), $bg: $gp-light-gray) {
  -fx-background-color: $border, $bg;
  -fx-background-insets: 0, 1;
  -fx-background-radius: 5;
}

@mixin btn-hovered($border: derive($gp-light-gray, -20%), $bg: derive($gp-light-gray, 20%)) {
  -fx-background-color: $border, $bg;
  -fx-fill: derive($gp-dark-gray, -20%);
}

@mixin btn-focused($border: derive($gp-medium-gray, -20%), $bg: derive($gp-light-gray, 0%)) {
  -fx-background-color: $border, $bg;
  -fx-background-insets: 0, 1;
  -fx-background-radius: 5, 3;
  -fx-border-color: transparent;
  -fx-border-width: 0;
}

@mixin btn-regular() {
  @include btn-normal();
  &:hover {
    @include btn-hovered();
  }
  &:focused {
    @include btn-hovered();
    @include btn-focused();
  }
  &:disabled {
    -fx-opacity: .4;
  }
}

.btn-regular {
    @include btn-regular();
}

.btn-regular .secondary {
  -fx-background-color: transparent;
}

.btn-attention {
  -fx-background-color: #ffca28;
  -fx-border-color: transparent;
  -fx-border-radius: 0;
  -fx-text-fill: #424242;
  /*    -fx-font-size: 110%;*/
  -fx-font-weight: bold;
  -fx-padding: 0.75ex 2em;
  -fx-cursor: hand;

  &:hover {
    @include btn-hovered(transparent, #ffca28);
    -fx-effect: dropshadow(gaussian, #e0e0e0, 4, 0, 0, 4);
  }
  &:focused {
    @include btn-focused(transparent, #ffca28);
  }
  &:disabled {
    -fx-opacity: 0.4;
    -fx-cursor: default;
  }
  &:pressed {
    -fx-effect: none;
    -fx-background-color: derive(#ffca28, 10%);
    -fx-text-fill: derive(#424242, -10%);
  }
  &.secondary {
    -fx-background-color: transparent;
    -fx-border-color: #ffca28;

    &:hover {
      @include btn-hovered(#ffca28, transparent);
    }
    &:focused {
      @include btn-focused(#ffca28, transparent);
    }
  }
}

@mixin scroll-bar($width) {
  -fx-background-color: transparent;
  -fx-opacity: 0.8;
  -fx-max-width: $width;
  -fx-pref-width: $width;

  & > .track {
    -fx-background-color: transparent;
    -fx-background-insets: 0;
    -fx-background-radius: 0.5em;
  }

  & > .track-background {
    -fx-background-color: transparent;
    -fx-background-insets: 0, 1;
  }

  & > .thumb {
    -fx-background-color: $gp-light-gray;
  }

  & > .increment-button, .decrement-button {
    -fx-background-color: transparent;
    -fx-background-radius: 0em;
    -fx-padding: 0;

    .increment-arrow, .decrement-arrow {
      -fx-shape: " ";
      -fx-padding: 0;
    }
  }
  //& > .increment-arrow,.decrement-arrow {
  //  -fx-shape: " ";
  //  -fx-padding:0;
  //}

}

@mixin btn-toolbar-common() {
  -fx-alignment: center;
  -fx-background-color: transparent;
  -fx-border-width: 0;
  -fx-border-insets: 0;
  -fx-text-fill: $gp-medium-gray;

  .glyph-icon {
    -fx-alignment: center;
    -fx-fill: $gp-medium-gray;
  }

  &:hover {
    -fx-background-color: derive($gp-light-gray, -10%);
    -fx-background-radius: 3px;

    .glyph-icon {
      -fx-fill: derive($gp-medium-gray, -10%);
    }
  }

  &:pressed, &:hover:pressed {
    -fx-background-color: derive($gp-light-gray, -15%);
    .glyph-icon {
      -fx-fill: derive($gp-medium-gray, -15%);
    }
  }
}

@mixin btn-toolbar-small() {
  -fx-padding: 2 2 2 2;
  -fx-min-width: 24px;
  -fx-min-height: 18px;
  -fx-max-height: 24px;
  -fx-pref-height: 24px;

  .glyph-icon {
    -glyph-size: 18px;
    -fx-padding: 0;
  }
}

@mixin btn-embedded-into-text-field($bg: $gp-control-background, $fg: $gp-dark-gray) {
  -fx-background-color: $bg;
  -fx-fill: $fg;
  -fx-text-fill: $fg;
  -fx-border-insets: 0;
  -fx-border-radius: 0;
  -fx-background-insets: 1;
  -fx-background-radius: 0;

  .glyph-icon {
    -fx-fill: $fg;
  }

  &:hover {
    -fx-background-color: derive($bg, 20%);
    -fx-fill: derive($gp-dark-gray, -20%);
    -fx-cursor: hand;
    -fx-effect: none;
    .glyph-icon {
    }
  }
}