//
// Copyright IBM Corp. 2016, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

@use "../../config" as *;
@use "../../spacing" as *;
@use "../../motion" as *;
@use "../../type" as *;
@use "../../breakpoint" as *;
@use "../../theme" as *;
@use "../../utilities/component-reset";
@use "../../utilities/convert" as *;
@use "../../utilities/rtl" as *;
@use "../../utilities/focus-outline" as *;
@use "../../utilities/high-contrast-mode" as *;

@use "../select";

/// Pagination styles
/// @access public
/// @group pagination
@mixin pagination {
  .#{$prefix}--data-table-v2-container + .#{$prefix}--pagination {
    border-top: 0;
  }

  .#{$prefix}--pagination {
    @include component-reset.reset;
    @include font-family("sans");
    width: 100%;
    background-color: $background-main;
    padding: $spacing-03 $spacing-05;
    display: flex;
    align-items: center;
    border: 1px solid $border-subtle;
    height: calcRem(46px);

    .#{$prefix}--form-item {
      flex: auto;
    }
  }

  .#{$prefix}--pagination__left {
    display: flex;
    align-items: center;
    @include rtl {
      flex-direction: row-reverse;
    }
  }

  .#{$prefix}--pagination__right {
    display: flex;
    align-items: center;
    margin-left: auto;
  }

  .#{$prefix}--pagination__text {
    @include type-style("label");
    color: $text-body-secondary;
    display: none;
    padding-right: $spacing-02;

    //breakpoint('530px')
    @include breakpoint("sm") {
      display: block;
    }
  }

  .#{$prefix}--pagination__button-icon {
    height: calcRem(12px);
    width: calcRem(12px);
    fill: $action-default-fill-primary-default;
    color: $action-default-fill-primary-default; //fill color was't taking effect so included color and it works
    pointer-events: none;
    transition: $transition--base;
    margin-top: $spacing-01;
  }

  .#{$prefix}--pagination__button {
    @include component-reset.reset;
    border: none;
    background: none;
    cursor: pointer;

    &:hover {
      .#{$prefix}--pagination__button-icon {
        fill: $action-default-fill-primary-default;
      }
    }

    &:focus {
      @include focus-outline("border");
    }

    &:disabled:hover {
      cursor: default;

      // .#{$prefix}--pagination__button-icon {
      //   // fill: $background-primary; //$icon-tertiary
      //   opacity: 50%;
      // }
    }

    &:disabled {
      cursor: default;

      .#{$prefix}--pagination__button-icon {
        // fill: $background-primary; //$icon-tertiary
        opacity: 50%;
      }
    }
  }

  .#{$prefix}--pagination__button--backward {
    margin-left: $spacing-05;
    margin-right: $spacing-06;
  }

  .#{$prefix}--pagination__button--forward {
    margin-left: $spacing-06;
  }

  .#{$prefix}--pagination__button--no-index {
    border-right: 0;
    margin-right: 1px;
  }

  .#{$prefix}--pagination {
    .#{$prefix}--select {
      margin-right: $spacing-03;
    }

    .#{$prefix}--select--inline {
      margin-right: 0;
      width: auto;
      display: flex;
      flex-direction: row;
      align-items: center;
    }

    .#{$prefix}--select-input {
      height: calcRem(24px);
      min-width: 0;
      width: auto;
      padding: 0 1.25rem 0 0.4rem;
      margin: 0;
      font-weight: 600;
      text-align-last: center;
      box-shadow: none;
      border: 0;
      color: $brand-wfp-blue-wfp-blue50;

      &:focus {
        @include focus-outline("border");
      }
    }

    .#{$prefix}--select--inline
      .#{$prefix}--select-input
      ~ .#{$prefix}--select__arrow {
      // right: 0.3rem;
      top: 0;
    }

    .#{$prefix}--text-input {
      background-color: $fill-field;
      height: calcRem(24px);
      min-width: calcRem(24px);
      width: calcRem(24px);
      padding: 0;
      margin: 0;
      font-weight: 600;
      text-align: center;
      box-shadow: none;
      order: 0;

      &:focus {
        @include focus-outline("border");
      }
    }

    .#{$prefix}--select__arrow {
      right: 0;
      // top: 0.6rem;
    }
  }

  .#{$prefix}--pagination--inline {
    height: 42px;
    margin-top: -0.5rem;
    margin-bottom: -0.5rem;
    margin-right: -1rem;
    @include rtl {
      flex-direction: row-reverse;
      margin-right: auto;
      margin-left: 0;
    }

    .#{$prefix}--pagination__button {
      height: calcRem(46px);
      border-left: 1px solid $border-subtle;
      border-right: 1px solid $border-subtle;
      margin: 0;
    }

    .#{$prefix}--pagination__button--forward {
      border-right: 0;
      padding: 0 $spacing-05;
      margin-left: $spacing-05;
    }

    .#{$prefix}--pagination__button--backward {
      margin: 0 $spacing-05;
      padding: 0 $spacing-05;
    }
  }

  // Skeleton state
  .#{$prefix}--pagination.#{$prefix}--skeleton .#{$prefix}--skeleton__text {
    margin-right: 1rem;
    margin-bottom: 0;
  }
}
