@import 'design-tokens';

@media screen and (max-width: $media--phone-large-minimum) {
  // make input text 16px on smaller screens to avoid iOS zooming on focus
  mat-form-field.mat-form-field,
  mat-form-field.mat-form-field.galaxy-form-field {
    font-size: $font-preset-3-size;
  }
}

$mat-button-focus-transition: opacity 200ms cubic-bezier(0.35, 0, 0.25, 1),
  background-color 200ms cubic-bezier(0.35, 0, 0.25, 1) !default;

// Button hover states
.mat-icon-button:hover .mat-button-focus-overlay {
  opacity: 0.04;
}

.mat-flat-button {
  transition: $mat-button-focus-transition;
}

.mat-flat-button.mat-primary:not([disabled]):hover,
.mat-flat-button.mat-accent:not([disabled]):hover {
  // primary and accent colors are both the same color in Galaxy themes, but we only use primary buttons
  background-color: $primary-button-bg-hover-color;
}

.mat-flat-button.mat-warn:not([disabled]):hover {
  background-color: $warn-button-bg-hover-color;
}

// basic containers
.mat-elevation-z0 {
  background: $card-background-color;
  border: 1px solid $border-color;
  border-radius: $default-border-radius;

  .mat-paginator {
    border-radius: 0 0 $default-border-radius $default-border-radius;
  }
}

// basic cards
.mat-card:not([class*='mat-elevation-z']),
.mat-expansion-panel:not([class*='mat-elevation-z']) {
  box-shadow: none;
  border: 1px solid $border-color;
}
.mat-card-title {
  // mat-theming doesn't catch this one
  font-size: $font-preset-3-size;
}
.mat-card-content {
  margin: 0 (-$spacing-3);
  padding: 0 $spacing-3 $spacing-3 $spacing-3;
}
.mat-card > .mat-card-title,
.mat-card > .mat-card-title + .mat-card-content,
.mat-card-header + .mat-card-content,
.mat-card-content:first-child {
  margin: 0 (-$spacing-3);
  padding: $spacing-3;
}
.mat-card-header {
  margin: 0 (-$spacing-3);
  padding: 0 $spacing-3;
}
.mat-card-header .mat-card-title,
.mat-card-header .mat-card-subtitle {
  line-height: 1.2;
}
.mat-card > .mat-card-title:first-child {
  @include text-preset-3;
  margin-top: (-$spacing-3);
  margin-bottom: $spacing-3;

  + .mat-card-content {
    margin-top: (-$spacing-3);
  }
}
.mat-card > .mat-card-content {
  margin-bottom: 0;

  &:first-child {
    padding-top: 0;
  }

  &:last-child {
    padding-bottom: 0;
  }
}
.mat-card > .mat-card-actions:last-child {
  margin: 0 (-$spacing-3) (-$spacing-3);
  padding: $spacing-2;
}
.mat-card-header + .mat-card-content,
.mat-card-title + .mat-card-content,
.mat-card-actions {
  border-top: 1px solid $border-color;
}
.mat-card > .mat-card-title {
  border-bottom: 1px solid $border-color;
}
.mat-card > .mat-card-title + .mat-card-content {
  border-top: 0;
}
.mat-card-header > .mat-card-header-text:first-child,
.mat-card-header-text:empty {
  margin: 0;
}
.mat-card-image {
  display: block;

  &:first-child {
    margin-bottom: 0;
  }

  + .mat-card-header {
    margin-top: $spacing-3;
  }
}

// mat-card utility classes
.mat-card.mat-card--no-content-padding {
  // used in SSC, could be a glxy-card input
  padding: 0;

  mat-card-header {
    margin: 0;
    padding: $spacing-3;
  }

  .mat-card-title {
    margin: 0;
  }

  .mat-card-content,
  .mat-card-title + .mat-card-content {
    padding: 0;
    margin: 0;
  }

  .mat-card-actions:last-child {
    margin: 0;
    padding: $spacing-2;
  }
}

// expansion panels / accordion
mat-expansion-panel.mat-expansion-panel:not([class*='mat-expanded']) {
  margin-top: -1px; // make it look like a 1px border between accordion panels
}
mat-expansion-panel-header.mat-expansion-panel-header {
  padding: 0 $spacing-3;
}
.mat-expansion-panel-body.mat-expansion-panel-body {
  border-top: 1px solid $border-color;
  padding: $spacing-3;

  > *:first-child:not(.row-gutters) {
    margin-top: 0;
  }

  > *:last-child {
    margin-bottom: 0;
  }
}
.mat-expansion-panel .mat-expansion-indicator::after {
  // center the expansion triangle
  transform: translateY(-3px) rotate(45deg);
}

// modal / dialog
mat-dialog-container.mat-dialog-container {
  padding: $spacing-3;
}
.mat-dialog-container > * > .mat-dialog-title,
h2.mat-dialog-title {
  border-bottom: 1px solid $border-color;
  padding: $spacing-3;
  margin: (-$spacing-3) (-$spacing-3) $spacing-3;
}
mat-dialog-content.mat-dialog-content {
  padding: 0 $spacing-3;
  margin: 0 (-$spacing-3);

  > form:last-child {
    margin-bottom: $spacing-3;
  }
}
.mat-dialog-title + mat-dialog-content.mat-dialog-content {
  margin-top: -$spacing-3;
  padding-top: $spacing-3;

  > *:first-child:not(.row-gutters) {
    margin-top: 0;
  }
}
mat-dialog-actions.mat-dialog-actions {
  border-top: 1px solid $border-color;
  padding: $spacing-2 $spacing-3;
  margin: 0 (-$spacing-3) (-$spacing-3);
  justify-content: flex-end;
  align-items: center;
}
.dialog-secondary-actions {
  flex: 1;
}

// mat-tooltip - increase default font size
.mat-tooltip {
  font-size: $font-preset-5-size;
}
