@use '../../sass/variables' as *;

.collection {
  padding-left: 0;
  list-style-type: none;
  background-color: var(--md-sys-color-surface);
  margin: $element-top-margin 0 $element-bottom-margin 0;
  border: 1px solid var(--md-sys-color-outline-variant);
  // @implement /Users/kzarshenas/Sites/RodeoFx/rodeo_toolkit_2/app/Front/style/scss/component_enhance.scss
  // Matches the 12px corner radius used across cards, dropdowns and
  // collapsibles instead of the near-square 2px default.
  border-radius: 12px;
  overflow: hidden;
  position: relative;

  .collection-item {
    background-color: transparent;
    line-height: 1.5rem;
    padding: 10px 20px;
    margin: 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);

    // Avatar Collection
    &.avatar {
      display: flex;
      flex-direction: column;
      justify-content: center;
      min-height: 84px;
      padding-left: 72px;
      position: relative;
      overflow-wrap: anywhere;

      // Keep the text clear of the trailing action, including when it wraps.
      &:has(> .secondary-content) { padding-right: 60px; }

      // Don't style circles inside preloader classes.
      &:not(.circle-clipper) > .circle,
      :not(.circle-clipper) > .circle {
        position: absolute;
        width: 42px;
        height: 42px;
        overflow: hidden;
        left: 15px;
        top: 50%;
        transform: translateY(-50%);
        display: inline-block;
        vertical-align: middle;
      }

      img.circle { object-fit: cover; }

      i.circle {
        font-size: 18px;
        line-height: 42px;
        color: #fff;
        background-color: var(--md-sys-color-shadow-light);
        text-align: center;
      }


      .title {
        font-size: 16px;
      }

      p {
        margin: 0;
      }

      > .secondary-content {
        position: absolute;
        top: 50%;
        right: 16px;
        transform: translateY(-50%);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        float: none;
        line-height: 1;

        > i { display: block; }
      }
    }

    &:last-child {
      border-bottom: none;
    }

    &.active {
      background-color: var(--md-sys-color-primary);
      color:  var(--md-sys-color-on-primary);

      .secondary-content {
        color:  var(--md-sys-color-on-primary);
      }
    }
  }

  a.collection-item {
    display: block;
    transition: .25s;
    color: var(--md-sys-color-primary);

    &:not(.active) {
      &:hover {
        background-color: rgba(0, 0, 0, 0.04);
      }
    }
  }

  &.with-header {
    .collection-header {
      // @implement /Users/kzarshenas/Sites/RodeoFx/rodeo_toolkit_2/app/Front/style/scss/component_enhance.scss
      // A tinted header reads as its own row instead of blending into the
      // list; it also isn't text, so it shouldn't be selectable.
      background-color: var(--md-sys-color-surface-variant);
      user-select: none;
      border-bottom: 1px solid var(--md-sys-color-outline-variant);
      padding: 10px 20px;
    }

    .collection-item {
      padding-left: 30px;
    }

    .collection-item.avatar {
      padding-left: 72px;
    }
  }

}

// Made less specific to allow easier overriding
.secondary-content {
  float: right;
  color: var(--md-sys-color-primary);
}

.collapsible .collection {
  margin: 0;
  border: none;
}