@use '@angular/material' as mat;
@use './mat-selectors' as ms;
@use '@alfresco/adf-core/theming' as adf-core;
@import './custom-theme';
@import './variables/variables';
@include custom-theme($custom-theme);
/* stylelint-disable-next-line */
@include mat.elevation-classes();
/* stylelint-disable-next-line */
@include mat.app-background();

:root {
  --mdc-filled-text-field-container-color: transparent;
  --mdc-text-button-label-text-color: inherit;
  --mat-toolbar-container-text-color: inherit;
  --mat-form-field-container-height: 47.5px;
  --mdc-checkbox-selected-icon-color: var(--theme-blue-checkbox-color);
  --mdc-checkbox-selected-hover-icon-color: var(--theme-blue-checkbox-color);
  --mdc-checkbox-selected-focus-icon-color: var(--theme-blue-checkbox-color);
  --mat-dialog-container-max-width: 100%;

  @include mat.form-field-overrides(
    (
      outlined-label-text-populated-size: 18px,
      outlined-label-text-color: var(--theme-selected-text-color),
      outlined-hover-label-text-color: var(--adf-theme-foreground-text-color),
      outlined-disabled-input-text-color: var(--adf-theme-foreground-text-color-040),
      outlined-disabled-label-text-color: var(--adf-theme-foreground-text-color-040),
      outlined-disabled-outline-color: var(--adf-theme-foreground-text-color-040),
      subscript-text-size: 12px
    )
  );
}

.adf-search-properties-form,
.adf-search-date-range {
  @include mat.form-field-overrides(
    (
      outlined-label-text-populated-size: 14px
    )
  );

  #{ms.$mat-form-field} .mdc-text-field--outlined .mdc-notched-outline--upgraded .mdc-floating-label--float-above {
    line-height: 18px;
  }
}

.adf-property-readonly-value {
  color: var(--adf-theme-foreground-text-color-040);

  .adf-dateitem-editable-controls {
    color: var(--adf-theme-foreground-text-color-040);
  }
}

#{ms.$mat-form-field} .mdc-text-field--outlined .mdc-notched-outline--upgraded .mdc-floating-label--float-above {
  line-height: 22px;
}

mat-toolbar {
  color: var(--adf-theme-foreground-text-color-064);
}

.adf-name-location-cell-location.adf-datatable-cell-value {
  color: var(--theme-secondary-text);
}

#{ms.$mat-checkbox} {
  #{ms.$mat-checkbox-box}:has(div) {
    padding-right: 2px;
  }

  #{ms.$mdc-form-field} {
    height: auto;

    #{ms.$mat-checkbox-box} {
      padding: 0;
      margin-right: 2px;

      input {
        height: 24px;
        width: 24px;
        position: relative;
      }

      #{ms.$mat-checkbox-background} {
        top: 1px;
        left: 0;
        height: 16px;
        width: 16px;
      }
    }
  }

  #{ms.$mat-checkbox-touch-target} {
    height: 24px;
    width: 24px;
  }
}

#{ms.$mat-switch}:is(button)#{ms.$mat-switch-selected}#{ms.$mat-switch-checked} #{ms.$mat-switch-handle-track} #{ms.$mat-switch-handle}::after {
  background-color: transparent;
}

#{ms.$mat-slide-toggle}:is(mat-slide-toggle) #{ms.$mat-switch}:enabled #{ms.$mat-switch-track}::after {
  background-color: var(--theme-blue-button-color);
}

mat-slide-toggle {
  #{ms.$mat-switch-icons} {
    display: none;
  }

  #{ms.$mat-switch-unselected}#{ms.$mat-switch}:enabled #{ms.$mat-switch-track}::before,
  #{ms.$mat-switch-unselected}#{ms.$mat-switch}:enabled:active #{ms.$mat-switch-track}::before,
  #{ms.$mat-switch-unselected}#{ms.$mat-switch}:enabled:focus:not(:active) #{ms.$mat-switch-track}::before,
  #{ms.$mat-switch-unselected}#{ms.$mat-switch}:enabled:hover:not(:focus:active) #{ms.$mat-switch-track}::before {
    background: var(--adf-theme-foreground-disabled-text-color);
  }
}

#{ms.$mat-list-item-primary-text} {
  color: var(--adf-theme-foreground-text-color-087);
}

#{ms.$mat-chip}#{ms.$mat-evolution-chip}#{ms.$mat-standard-chip} {
  height: auto;

  #{ms.$mat-evolution-chip-text-label} {
    white-space: normal;
    display: flex;
  }

  #{ms.$mat-evolution-chip-action}#{ms.$mat-chip-action} {
    #{ms.$mat-evolution-chip-graphic}#{ms.$mat-chip-graphic} {
      padding: 0;
    }
  }
}

#{ms.$mdc-dialog} {
  #{ms.$mat-dialog-title} {
    margin-bottom: 20px;
    padding: 0;

    &::before {
      height: unset;
    }
  }

  #{ms.$mat-dialog-actions} {
    padding: 8px 0;
  }

  #{ms.$mat-slide-toggle} #{ms.$mdc-form-field} {
    width: 36px;
  }

  #{ms.$mat-data-table-row}:last-child #{ms.$mat-data-table-cell} {
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  }

  #{ms.$mat-dialog-content} {
    padding: 16px 0;
    color: var(--adf-theme-foreground-text-color-087);

    --mdc-dialog-supporting-text-color: var(--theme-primary-text);
  }

  #{ms.$mat-dialog-surface} {
    padding: 24px;

    #{ms.$mat-button} {
      width: auto;

      #{ms.$mat-button-label} {
        padding: 0 16px;
      }
    }
  }
}

#{ms.$mat-floating-label},
#{ms.$mat-tab-list} #{ms.$mat-tab-labels} #{ms.$mat-tab-label},
#{ms.$mat-checkbox} label,
mat-toolbar#{ms.$mat-toolbar}#{ms.$mat-toolbar-multiple-row},
mat-toolbar#{ms.$mat-toolbar}#{ms.$mat-toolbar-single-row} {
  color: var(--theme-secondary-text);
  opacity: 1;
}

.adf-upload-dialog {
  &__header,
  &__content {
    color: var(--theme-secondary-text);
  }
}

.adf-version-list {
  .adf-version-list-item {
    &-comment,
    &-date {
      color: var(--theme-secondary-text);
      opacity: 1;
    }
  }
}

.adf-datatable-row {
  .adf-datatable-checkbox {
    #{ms.$mat-checkbox} label {
      display: none;
    }
  }
}

.adf-datatable-list {
  .adf-datatable-row:is(adf-datatable-row) {
    &:focus {
      outline: 1px solid var(--theme-blue-checkbox-color);
    }

    .adf-cell-value:focus {
      outline: 1px solid var(--theme-blue-checkbox-color);
    }

    .adf-datatable-cell-header:focus {
      outline: 1px solid var(--theme-blue-checkbox-color);
    }

    .adf-datatable-link:hover {
      color: var(--theme-blue-checkbox-color);
    }
  }

  .adf-datatable-body {
    .adf-datatable-row:is(adf-datatable-row) {
      &.adf-is-selected,
      &.adf-is-selected:hover {
        background-color: var(--theme-blue-active-table-row-color);
      }
    }
  }
}

.adf-property-field {
  .adf-textitem-edit-icon#{ms.$mat-icon} {
    color: var(--theme-secondary-text);
  }
}

.adf-property-field.adf-card-textitem-field:hover .adf-property-clear-value {
  color: var(--theme-secondary-text);
}

.adf-empty-content__icon {
  color: var(--theme-secondary-text);
}

.aca-details-tabs {
  #{ms.$mat-tab-label-text} {
    line-height: 19px;
  }
}

mat-snack-bar-container {
  #{ms.$mat-button}#{ms.$mat-unthemed} {
    --mdc-text-button-label-text-color: var(--theme-white-background);
  }
}

.adf-warning-snackbar,
.adf-info-snackbar,
.adf-error-snackbar {
  --mat-mdc-snack-bar-button-color: var(--theme-white-background);
  --mdc-snackbar-supporting-text-color: var(--theme-white-background);
  --mdc-text-button-label-text-color: var(--theme-white-background);
}

.adf-warning-snackbar {
  --mdc-snackbar-container-color: var(--theme-warning-snackbar-background);
}

.adf-info-snackbar {
  --mdc-snackbar-container-color: var(--theme-info-snackbar-background);
}

.adf-error-snackbar {
  --mdc-snackbar-container-color: var(--theme-warn-color);
}

#{ms.$mat-calendar} {
  #{ms.$mat-calendar-period-button}:is(button) {
    width: unset;
    height: unset;
    padding: 0 16px;
    margin: 0;
  }
}

#{ms.$mat-radio-button} #{ms.$mat-radio}:is(div) {
  padding: 0 5px 0 0;
}

#{ms.$mdc-form-field} > label:is(label) {
  padding-left: 3px;
}

#{ms.$mat-tab-ripple} {
  display: none;
}

#{ms.$mat-tab-labels} {
  border-bottom: 1px solid var(--adf-theme-foreground-text-color-014);
}

#{ms.$mat-tab-list} {
  #{ms.$mat-tab-labels} {
    #{ms.$mat-tab-label-active} {
      color: var($selected-text-color);
    }
  }
}

#{ms.$mat-tab-label}:not(#{ms.$mat-tab-disabled})#{ms.$mat-tab-label-active} #{ms.$mat-tab-label-text} {
  color: var(--theme-tab-active-text-color);
}

adf-dynamic-component {
  mat-icon#{ms.$mat-icon}#{ms.$mat-submenu-icon} {
    color: var(--theme-text-color);
  }
}

#{ms.$mat-menu-item} #{ms.$mat-icon} {
  &#{ms.$mat-icon-no-color},
  &#{ms.$mat-mdc-submenu-icon} {
    color: var(--theme-text-color);
  }
}

#{ms.$mat-menu-surface}#{ms.$mat-autocomplete-panel}:is(div) {
  padding: 0;

  span {
    font-size: 16px;
  }
}

#{ms.$mat-list-item}#{ms.$mat-list-item-disabled} {
  #{ms.$mat-list-item-primary-text}:is(div) {
    color: unset;
  }
}

#{ms.$mat-tab-group}#{ms.$mat-tab-group-stretch} > #{ms.$mat-tab-header} {
  #{ms.$mat-tab-label}:is(div) {
    min-width: 160px;
  }
}

.adf-unsaved-changes-dialog {
  .adf-unsaved-changes-dialog-actions-discard-changes-button:is(button) {
    background-color: var(--theme-blue-button-color);
  }
}

#{ms.$mat-form-field-infix} {
  min-height: unset;
}

#{ms.$mat-mdc-submenu-icon} {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
}

#{ms.$mat-form-field-hint-wrapper} {
  /* stylelint-disable-next-line declaration-no-important */
  padding-left: 0 !important;
  color: var(--adf-theme-foreground-secondary-text-color);
}
