@import "../../globals.ios";
@import "./item";

// iOS Item
// --------------------------------------------------

$item-ios-body-text-font-size:        1.6rem !default;
$item-ios-paragraph-text-color:       #666 !default;

$item-ios-avatar-size:                3.6rem !default;
$item-ios-thumbnail-size:             5.6rem !default;
$item-ios-note-color:                 darken($list-ios-border-color, 10%) !default;
$item-ios-detail-push-color:          $list-ios-border-color !default;

$item-ios-divider-background:         #f7f7f7 !default;
$item-ios-divider-color:              #222 !default;
$item-ios-divider-padding:            5px 15px !default;

$item-ios-sliding-content-background: $list-ios-background-color !default;


// iOS Item
// --------------------------------------------------

.item {
  position: relative;

  padding-left: $item-ios-padding-left;

  border-radius: 0;
  font-size: $item-ios-body-text-font-size;
  color: $list-ios-text-color;
  background-color: $list-ios-background-color;
  transition-duration: 200ms;

  h1 {
    margin: 0 0 2px;

    font-size: 2.4rem;
    font-weight: normal;
  }

  h2 {
    margin: 0 0 2px;

    font-size: 1.6rem;
    font-weight: normal;
  }

  h3,
  h4,
  h5,
  h6 {
    margin: 0 0 3px;

    font-size: 1.4rem;
    font-weight: normal;
    line-height: normal;
  }

  p {
    margin: 0 0 2px;

    font-size: 1.2rem;
    line-height: normal;
    color: $item-ios-paragraph-text-color;
  }

  h2:last-child,
  h3:last-child,
  h4:last-child,
  h5:last-child,
  h6:last-child,
  p:last-child {
    margin-bottom: 0;
  }

  a {
    text-decoration: none;
  }
}

.item.activated {
  background-color: $list-ios-activated-background-color;
  transition-duration: 0ms;
}

.item-inner {
  padding-right: ($item-ios-padding-right / 2);

  border-bottom: 1px solid $list-ios-border-color;
}

&.hairlines .item-inner {
  border-bottom-width: $hairlines-width;
}


// iOS Item Media
// --------------------------------------------------

[item-left] {
  margin: $item-ios-padding-media-top $item-ios-padding-left $item-ios-padding-media-bottom 0;
}

[item-right] {
  margin: $item-ios-padding-media-top ($item-ios-padding-left / 2) $item-ios-padding-media-bottom ($item-ios-padding-right / 2);
}

ion-icon[item-left],
ion-icon[item-right] {
  margin-top: $item-ios-padding-icon-top;
  margin-bottom: $item-ios-padding-icon-bottom;
  margin-left: 0;
}

ion-avatar[item-left],
ion-thumbnail[item-left] {
  margin: ($item-ios-padding-right / 2) $item-ios-padding-right ($item-ios-padding-right / 2) 0;
}

ion-avatar[item-right],
ion-thumbnail[item-right] {
  margin: ($item-ios-padding-right / 2);
}

.item-button {
  padding: 0 .5em;

  height: 24px;

  font-size: 1.3rem;
}

.item-button.button-icon-only ion-icon,
.item-button.button-icon-only {
  padding: 0 1px;
}

ion-avatar {
  min-width: $item-ios-avatar-size;
  min-height: $item-ios-avatar-size;

  img {
    max-width: $item-ios-avatar-size;
    max-height: $item-ios-avatar-size;

    border-radius: $item-ios-avatar-size / 2;
  }
}

ion-thumbnail {
  min-width: $item-ios-thumbnail-size;
  min-height: $item-ios-thumbnail-size;

  img {
    max-width: $item-ios-thumbnail-size;
    max-height: $item-ios-thumbnail-size;
  }
}

ion-note {
  color: $item-ios-note-color;
}

button.item:not([detail-none]) .item-inner,
a.item:not([detail-none]) .item-inner,
.item[detail-push] .item-inner {
  @include ios-detail-push-icon($item-ios-detail-push-color);

  padding-right: 32px;

  background-repeat: no-repeat;
  background-position: right ($item-ios-padding-right - 2) center;
  background-size: 14px 14px;
}


// iOS Item Group
// --------------------------------------------------

ion-item-group {
  .item:first-child {
    .item-inner {
      border-top-width: 0;
    }
  }

  .item:last-child .item-inner,
  ion-item-sliding:last-child .item-inner {
    border: 0;
  }
}


// iOS Item Divider
// --------------------------------------------------

ion-item-divider {
  padding: $item-ios-padding-top $item-ios-padding-right $item-ios-padding-bottom $item-ios-padding-left;

  color: $item-ios-divider-color;
  background-color: $item-ios-divider-background;
}


// Generate iOS Item Divider Colors
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {
  ion-item-divider[#{$color-name}] {
    color: $color-contrast;
    background-color: $color-base;
  }
}


// iOS Item Sliding
// --------------------------------------------------

ion-item-sliding {
  background-color: $item-ios-sliding-content-background;
}

// iOS item right-to-left
// --------------------------------------------------
@if $include-rtl {
  @at-root {

    .rtl.ios {

      // todo

    }

  }
}
