:root {
  --rc-picker-accent-color: #1677ff;
  --rc-picker-focus-color: #4096ff;
  --rc-picker-header-color: #0d64de;
  --rc-picker-range-color: #e6f4ff;
  --rc-picker-background-color: #fff;
  --rc-picker-range-hover-color: #c8dfff;
  --rc-picker-hover-color: rgba(0, 0, 0, 0.05);
  --rc-picker-range-outline-color: #7cb3ff;
  --rc-picker-cell-border-radius: 4px;
  --rc-picker-border-color: rgba(5, 5, 5, 0.06);
  --rc-picker-scrollbar-color: rgba(5, 5, 5, 0.2);
}

.rc-picker {
  margin: 0;
  padding: 4px 11px;
  font-size: 14px;
  line-height: 1;
  position: relative;
  display: inline-flex;
  align-items: center;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  transition: border 0.2s, box-shadow 0.2s;
  background-color: var(--rc-picker-background-color);
  $that: &;

  &:hover {
    #{$that}-clear {
      opacity: 1;
    }
  }

  &-rtl {
    direction: rtl;

    #{$that}-input {
      text-align: right;
    }

    #{$that}-clear {
      right: unset;
      left: 0;
    }
  }

  &-focused {
    outline: none;
    border-color: var(--rc-picker-focus-color);
  }

  &-panel {
    display: inline-flex;
    flex-direction: column;
    text-align: center;
    vertical-align: top;
    border-radius: 8px;
    outline: none;

    &-rtl {
      direction: rtl;

      #{$that}-header {
        &-view {
          > button {
            &:nth-child(1) {
              margin-left: 8px;
            }

            &:nth-child(2) {
              margin-left: 0;
            }
          }
        }
      }

      #{$that}-header-nav-icon,
      #{$that}-header-nav-icon-super {
        &-prev {
          transform: rotate(135deg);
        }

        &-next {
          transform: rotate(-45deg);
        }
      }
    }

    @supports (scrollbar-width: thin) {
      * {
        scrollbar-width: thin;
        scrollbar-color: var(--rc-picker-scrollbar-color) transparent;
      }
    }

    ::-webkit-scrollbar {
      width: 6px;
      height: 6px;

      &-track {
        background-color: transparent;
      }

      &-thumb {
        background-color: var(--rc-picker-scrollbar-color);
        border-radius: 10px;
        min-height: 30px;
      }

      &-corner {
        display: none;
      }
    }
  }

  &-inner {
    display: flex;
  }

  // ===================== Shared Panel =====================
  &-decade-panel,
  &-year-panel,
  &-month-panel,
  &-week-panel,
  &-date-panel,
  &-time-panel {
    display: flex;
    flex-direction: column;

    table {
      text-align: center;
      border-collapse: collapse;
    }
  }

  // Header
  &-header {
    display: flex;
    padding: 0 8px;
    border-bottom: 1px solid var(--rc-picker-border-color);

    > button {
      padding: 0 6px;
      opacity: 0.7;
      background-color: transparent;
      border: none;
      cursor: pointer;
      transition: color 0.2s, opacity 0.2s;
      font-size: inherit;
      color: inherit;
      flex-shrink: 0;
      direction: ltr;

      &:hover {
        opacity: 1;
      }

      &:focus-visible {
        opacity: 1;
      }
    }

    &-view {
      padding: 10px 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      text-align: center;
      font-weight: 600;
      flex-grow: 1;

      > button {
        padding: 0;
        position: relative;
        border: 0;
        color: inherit;
        font-weight: inherit;
        vertical-align: middle;
        background-color: transparent;
        cursor: pointer;
        transition: color 0.2s;
        font-size: inherit;
        flex-shrink: 0;
        line-height: 1;

        &:after {
          content: '';
          display: block;
          position: absolute;
          bottom: 0px;
          left: 0;
          width: 100%;
          height: 1px;
          background-color: currentColor;
          opacity: 0.3;
          transition: opacity 0.2s;
        }

        &:hover {
          color: var(--rc-picker-accent-color);

          &:after {
            opacity: 1;
          }
        }

        &:focus-visible {
          color: var(--rc-picker-accent-color);

          &:after {
            opacity: 1;
          }
        }
      }
    }
  }

  //Nav Icons
  &-header-nav-icon,
  &-header-nav-icon-super {
    position: relative;
    display: inline-block;
    width: 6px;
    height: 6px;
    opacity: 0.5;
    color: inherit;

    &:before,
    &:after {
      position: absolute;
      width: 100%;
      height: 100%;
      display: inline-block;
      border: 0 solid currentcolor;
      border-block-start-width: 1.5px;
      border-block-end-width: 0;
      border-inline-start-width: 1.5px;
      border-inline-end-width: 0;
    }

    &:before {
      top: 0;
      inset-inline-start: 0;
    }

    &:after {
      top: 4px;
      inset-inline-start: 4px;
    }

    &-prev {
      transform: rotate(-45deg);
    }

    &-next {
      transform: rotate(135deg);
    }
  }

  &-header-nav-icon {
    &:before {
      content: '';
    }
  }

  &-header-nav-icon-super {
    &:before,
    &:after {
      content: '';
    }
  }

  // Content
  &-body {
    padding: 8px 18px;
  }

  &-content {
    th,
    td {
      min-width: 24px;
      font-weight: 400;
      padding-block: 4px;
    }

    th {
      color: var(--rc-picker-header-color);
      font-weight: 600;
    }
  }

  &-cell {
    opacity: 0.4;
    position: relative;

    &:before {
      position: absolute;
      inset: 4px 0;
      z-index: 1;
      transition: all 0.3s;
    }

    &-inner {
      position: relative;
      display: inline-block;
      box-sizing: border-box;
      width: 100%;
      margin: 0;
      padding: 0;
      font-size: 12px;
      line-height: 20px;
      background: transparent;
      border: none;
      outline: none;
      cursor: pointer;
      border-radius: var(--rc-picker-cell-border-radius);
      transition: background-color 0.2s, border 0.2s;
      z-index: 2;

      &:hover {
        background-color: var(--rc-picker-hover-color);
      }
    }

    &-in-view {
      opacity: 1;
    }

    &-disabled {
      opacity: 0.2;
    }

    &-in-range,
    &-range-start,
    &-range-end {
      &:before {
        content: '';
        background-color: var(--rc-picker-range-color);
      }

      &#{$that}-cell-range-hover {
        &:before {
          background-color: var(--rc-picker-range-hover-color);
        }
      }
    }

    &-range-start:before {
      border-top-left-radius: var(--rc-picker-cell-border-radius);
      border-bottom-left-radius: var(--rc-picker-cell-border-radius);
    }

    &-range-end:before {
      border-top-right-radius: var(--rc-picker-cell-border-radius);
      border-bottom-right-radius: var(--rc-picker-cell-border-radius);
    }

    &-range-hover-start,
    &-range-hover-end,
    &-range-hover {
      position: relative;

      &::after {
        position: absolute;
        inset: 4px 0;
        border: 1px dashed var(--rc-picker-range-outline-color);
        border-right: 0;
        border-left: 0;
        content: '';
        pointer-events: none;
        z-index: 2;
      }
    }

    &-range-hover-start::after {
      border-left: 1px dashed var(--rc-picker-range-outline-color) !important;
      border-top-left-radius: var(--rc-picker-cell-border-radius);
      border-bottom-left-radius: var(--rc-picker-cell-border-radius);
    }

    &-range-hover-end::after {
      border-right: 1px dashed var(--rc-picker-range-outline-color) !important;
      border-top-right-radius: var(--rc-picker-cell-border-radius);
      border-bottom-right-radius: var(--rc-picker-cell-border-radius);
    }

    &-today > &-inner {
      border: 1px solid var(--rc-picker-accent-color);
    }

    &-range-start > &-inner,
    &-range-end > &-inner,
    &-selected > &-inner {
      color: #fff;
      background-color: var(--rc-picker-accent-color);
    }
  }

  // Preset
  &-presets {
    padding: 8px;
    border-right: 1px solid var(--rc-picker-border-color);

    ul {
      margin: 0;
      padding: 0;
      list-style: none;

      &:last-child {
        margin-bottom: 0;
      }
    }

    li {
      margin-bottom: 8px;
      padding: 2px 8px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      border-radius: 4px;
      cursor: pointer;
      transition: all 0.3s;

      &:hover {
        background-color: rgba(0, 0, 0, 0.04);
      }

      &.is-active-date {
        color: #fff;
        background-color: var(--rc-picker-header-color);
      }
    }
  }

  &-footer,
  &-picker-footer {
    padding: 4px;
    border-top: 1px solid var(--rc-picker-border-color);
  }

  &-ranges {
    margin: 0;
    padding: 4px;
    overflow: hidden;
    list-style: none;

    > li {
      display: inline-block;
    }
  }

  &-btn {
    float: right;

    button {
      padding: 2px 8px;
      border-radius: 4px;
      position: relative;
      display: inline-block;
      font-weight: 400;
      white-space: nowrap;
      border: 1px solid transparent;
      cursor: pointer;
      transition: all 0.2s ease-in-out;

      &:disabled {
        cursor: not-allowed;
        border-color: #d9d9d9;
        color: rgba(0, 0, 0, 0.25);
        background-color: rgba(0, 0, 0, 0.04);
        box-shadow: none;
      }

      &:not(:focus-visible) {
        outline: none;
      }
    }
  }

  &-ok {
    button {
      color: #fff;
      background-color: var(--rc-picker-accent-color);
      box-shadow: 0 2px 0 rgba(5, 145, 255, 0.1);
    }
  }

  &-cancel {
    margin-right: 12px;

    button {
      color: var(--rc-picker-accent-color);
      background-color: #fff;
      box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.14);
    }
  }

  &-now-btn,
  &-today-btn {
    color: var(--rc-picker-accent-color);
    cursor: pointer;
  }

  // ================== Year & Month Panel ==================
  &-year-panel,
  &-month-panel {
    #{$that}-cell-inner {
      width: 80px;
    }
  }

  // ====================== Week Panel ======================
  &-week-panel {
    &-row {
      $self: &;

      &:not(&-selected):not(&-range-start):not(&-range-end):hover {
        #{$that}-cell {
          &:before {
            content: '';
            background-color: var(--rc-picker-hover-color);
          }
        }
      }

      &-range {
        &-hover {
          #{$that}-cell {
            &:before {
              content: '';
              background-color: var(--rc-picker-range-hover-color);
            }
          }
        }
      }

      &-selected,
      &-range-start,
      &-range-end {
        #{$that}-cell {
          opacity: 1;

          &:before {
            content: '';
            background-color: var(--rc-picker-accent-color);
          }

          #{$that}-cell-inner {
            color: #fff;
            background-color: var(--rc-picker-accent-color);
          }

          &:first-child {
            &:before {
              border-top-left-radius: var(--rc-picker-cell-border-radius);
              border-bottom-left-radius: var(--rc-picker-cell-border-radius);
            }
          }

          &:last-child {
            &:before {
              border-top-right-radius: var(--rc-picker-cell-border-radius);
              border-bottom-right-radius: var(--rc-picker-cell-border-radius);
            }
          }
        }
      }
    }

    #{$that}-cell-week {
      color: #999;
      font-weight: bold;
      font-size: 12px;
    }

    #{$that}-cell:hover > #{$that}-cell-inner,
    #{$that}-cell-selected > #{$that}-cell-inner {
      background: transparent;
    }
  }

  // ====================== Time Panel ======================
  &-time-panel {
    width: auto;

    #{$that}-content {
      display: flex;
      max-height: 212px;
    }

    &-column {
      flex: none;
      width: 50px;
      margin: 4px 0;
      padding: 0 0 180px 0;
      overflow-x: hidden;
      overflow-y: hidden;
      font-size: 12px;
      text-align: left;
      list-style: none;
      transition: background 0.3s;

      &:not(:last-child) {
        border-right: 1px solid var(--rc-picker-border-color);
      }

      &-active {
        background: rgba(0, 0, 255, 0.1);
      }

      &:hover {
        overflow-y: auto;
      }

      > li {
        margin: 0;
        padding: 0;
        cursor: pointer;

        &#{$that}-time-panel-cell {
          margin-inline: 4px;
          width: 36px;

          &-disabled {
            opacity: 0.5;
          }
        }

        #{$that}-time-panel-cell-inner {
          display: block;
          line-height: 26px;
          margin: 0;
          color: #333;
          text-align: center;
          border-radius: 4px;
          cursor: pointer;
          transition: background-color 0.2s;
          &:hover {
            background: rgba(0, 0, 0, 0.04);
          }
        }
      }
    }
  }

  // ====================== Date Time =======================
  &-datetime-panel {
    display: flex;

    #{$that}-time-panel {
      border-left: 1px solid var(--rc-picker-border-color);
    }

    #{$that}-date-panel,
    #{$that}-time-panel {
      transition: opacity 0.3s;
    }

    // Keyboard
    &-active {
      #{$that}-date-panel,
      #{$that}-time-panel {
        opacity: 0.3;

        &-active {
          opacity: 1;
        }
      }
    }
  }

  // ======================== Input =========================
  &-input {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 100%;
    background-color: inherit;

    > input {
      width: 100%;
      min-width: 1px;
      padding: 0;
      color: inherit;
      font-size: inherit;
      background-color: inherit;
      border-radius: 0;
      transition: all 0.2s;
      border: none;

      //this is necessary if placeholder's text starts overflowing
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;

      &::placeholder {
        font-size: 13px;
      }

      &:focus {
        outline: none;
      }

      // Firefox
      &::-moz-placeholder {
        opacity: 0.5;
      }

      &::placeholder {
        opacity: 0.5;
      }
    }
  }

  &-suffix-icon {
    opacity: 0.5;
  }

  // ======================== Range Separator =========================
  &-range-separator {
    align-items: center;
    padding: 0 8px;
    line-height: 1;

    &-inner {
      opacity: 0.5;
    }
  }

  &-clear {
    padding: 2px 0;
    position: absolute;
    top: 50%;
    right: 0;
    line-height: 1;
    transform: translateY(-50%);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    background-color: inherit;

    &-icon {
      opacity: 0.5;
      display: block;

      svg {
        display: block;
      }
    }
  }

  // ======================= Dropdown =======================
  &-dropdown {
    position: absolute;
    margin: 0;
    padding: 0;
    font-size: 14px;
    z-index: 1050;

    &-range {
      padding: 10px 0;
    }

    &-hidden {
      display: none;
    }

    // Panel
    $arrow-size: 16px;

    &-placement-topLeft,
    &-placement-topRight {
      #{$that}-range-arrow {
        bottom: 0;
        transform: translateY(100%) rotate(180deg);
      }
    }

    &-placement-bottomLeft,
    &-placement-bottomRight {
      #{$that}-range-arrow {
        top: 0;
        transform: translateY(-100%);
      }
    }

    #{$that}-range-arrow {
      position: absolute;
      width: $arrow-size;
      height: $arrow-size;
      transition: left 0.3s ease-out;
      overflow: hidden;
      z-index: 1;
      margin-inline-start: $arrow-size;

      &::before {
        content: '';
        width: $arrow-size;
        height: $arrow-size;
        left: 0;
        position: absolute;
        bottom: calc($arrow-size / -1.41);
        border-radius: 2px 0 0 0;
        background-color: var(--rc-picker-background-color);
        transform: rotate(45deg);
        box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
      }
    }

    &-rtl {
      #{$that}-range-arrow {
        margin-inline-start: 0;
        margin-inline-end: $arrow-size;
      }
    }
  }

  // ========================================================
  // =                     Range Picker                     =
  // ========================================================
  &-range {
    &-wrapper {
      display: flex;
      position: relative;
    }

    #{$that}-active-bar {
      bottom: 0px;
      height: 1px;
      margin-inline-start: 9px;
      background: var(--rc-picker-accent-color);
      opacity: 0;
      transition: all 0.3s ease-out;
    }

    &#{$that}-focused {
      #{$that}-active-bar {
        opacity: 1;
      }
    }

    #{$that}-clear {
      right: 11px;
    }

    &#{$that}-rtl {
      #{$that}-clear {
        right: unset;
        left: 11px;
      }
    }
  }

  &-panel-container {
    overflow: hidden;
    vertical-align: top;
    background: var(--rc-picker-background-color);
    border-radius: 8px;
    box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12),
      0 9px 28px 8px rgba(0, 0, 0, 0.05);
    transition: margin 0.3s;
  }

  &-panel-layout {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
  }

  &-panel-top {
    display: flex;
  }

  &-panels-top {
    display: flex;
  }

  &-panels {
    display: flex;

    &-vertical {
      flex-direction: column;
    }
  }
}
