//
// Panels
// --------------------------------------------------


// Base class
.#{$class-prefix}-panel {
  margin-bottom: $line-height-computed;
  background-color: $panel-bg;
  border: 1px solid transparent;
  border-radius: $panel-border-radius;
  @include box-shadow(0 1px 1px rgba(0,0,0,.05));
}

// Panel contents
.#{$class-prefix}-panel-body {
  padding: $panel-body-padding;
  @include clearfix;
}

// Optional heading
.#{$class-prefix}-panel-heading {
  padding: $panel-heading-padding;
  border-bottom: 1px solid transparent;
  @include border-top-radius(($panel-border-radius - 1));

  > .#{$class-prefix}-dropdown .#{$class-prefix}-dropdown-toggle {
    color: inherit;
  }
}

// Within heading, strip any `h*` tag of its default margins for spacing.
.#{$class-prefix}-panel-title {
  margin-top: 0;
  margin-bottom: 0;
  font-size: ceil(($font-size-base * 1.125));
  color: inherit;

  > .#{$class-prefix}-html-a,
  > .#{$class-prefix}-html-small,
  > .#{$class-prefix}-small,
  > .#{$class-prefix}-html-small > .#{$class-prefix}-html-a,
  > .#{$class-prefix}-small > .#{$class-prefix}-html-a {
    color: inherit;
  }
}

// Optional footer (stays gray in every modifier class)
.#{$class-prefix}-panel-footer {
  padding: $panel-footer-padding;
  background-color: $panel-footer-bg;
  border-top: 1px solid $panel-inner-border;
  @include border-bottom-radius(($panel-border-radius - 1));
}


// List groups in panels
//
// By default, space out list group content from panel headings to account for
// any kind of custom content between the two.

.#{$class-prefix}-panel {
  > .#{$class-prefix}-list-group,
  > .#{$class-prefix}-panel-collapse > .#{$class-prefix}-list-group {
    margin-bottom: 0;

    .#{$class-prefix}-list-group-item {
      border-width: 1px 0;
      border-radius: 0;
    }

    // Add border top radius for first one
    &:first-child {
      .#{$class-prefix}-list-group-item:first-child {
        border-top: 0;
        @include border-top-radius(($panel-border-radius - 1));
      }
    }

    // Add border bottom radius for last one
    &:last-child {
      .#{$class-prefix}-list-group-item:last-child {
        border-bottom: 0;
        @include border-bottom-radius(($panel-border-radius - 1));
      }
    }
  }
  > .#{$class-prefix}-panel-heading + .#{$class-prefix}-panel-collapse > .#{$class-prefix}-list-group {
    .#{$class-prefix}-list-group-item:first-child {
      @include border-top-radius(0);
    }
  }
}
// Collapse space between when there's no additional content.
.#{$class-prefix}-panel-heading + .#{$class-prefix}-list-group {
  .#{$class-prefix}-list-group-item:first-child {
    border-top-width: 0;
  }
}
.#{$class-prefix}-list-group + .#{$class-prefix}-panel-footer {
  border-top-width: 0;
}

// Tables in panels
//
// Place a non-bordered `.table` within a panel (not within a `.panel-body`) and
// watch it go full width.

.#{$class-prefix}-panel {
  > .#{$class-prefix}-table,
  > .#{$class-prefix}-table-responsive > .#{$class-prefix}-table,
  > .#{$class-prefix}-panel-collapse > .#{$class-prefix}-table {
    margin-bottom: 0;

    .#{$class-prefix}-html-caption {
      padding-left: $panel-body-padding;
      padding-right: $panel-body-padding;
    }
  }
  // Add border top radius for first one
  > .#{$class-prefix}-table:first-child,
  > .#{$class-prefix}-table-responsive:first-child > .#{$class-prefix}-table:first-child {
    @include border-top-radius(($panel-border-radius - 1));

    > .#{$class-prefix}-html-thead:first-child,
    > .#{$class-prefix}-html-tbody:first-child {
      > .#{$class-prefix}-html-tr:first-child {
        border-top-left-radius: ($panel-border-radius - 1);
        border-top-right-radius: ($panel-border-radius - 1);

        .#{$class-prefix}-html-td:first-child,
        .#{$class-prefix}-html-th:first-child {
          border-top-left-radius: ($panel-border-radius - 1);
        }
        .#{$class-prefix}-html-td:last-child,
        .#{$class-prefix}-html-th:last-child {
          border-top-right-radius: ($panel-border-radius - 1);
        }
      }
    }
  }
  // Add border bottom radius for last one
  > .#{$class-prefix}-table:last-child,
  > .#{$class-prefix}-table-responsive:last-child > .#{$class-prefix}-table:last-child {
    @include border-bottom-radius(($panel-border-radius - 1));

    > .#{$class-prefix}-html-tbody:last-child,
    > .#{$class-prefix}-html-tfoot:last-child {
      > .#{$class-prefix}-html-tr:last-child {
        border-bottom-left-radius: ($panel-border-radius - 1);
        border-bottom-right-radius: ($panel-border-radius - 1);

        .#{$class-prefix}-html-td:first-child,
        .#{$class-prefix}-html-th:first-child {
          border-bottom-left-radius: ($panel-border-radius - 1);
        }
        .#{$class-prefix}-html-td:last-child,
        .#{$class-prefix}-html-th:last-child {
          border-bottom-right-radius: ($panel-border-radius - 1);
        }
      }
    }
  }
  > .#{$class-prefix}-panel-body + .#{$class-prefix}-table,
  > .#{$class-prefix}-panel-body + .#{$class-prefix}-table-responsive,
  > .#{$class-prefix}-table + .#{$class-prefix}-panel-body,
  > .#{$class-prefix}-table-responsive + .#{$class-prefix}-panel-body {
    border-top: 1px solid $table-border-color;
  }
  > .#{$class-prefix}-table > .#{$class-prefix}-html-tbody:first-child > .#{$class-prefix}-html-tr:first-child .#{$class-prefix}-html-th,
  > .#{$class-prefix}-table > .#{$class-prefix}-html-tbody:first-child > .#{$class-prefix}-html-tr:first-child .#{$class-prefix}-html-td {
    border-top: 0;
  }
  > .#{$class-prefix}-table-bordered,
  > .#{$class-prefix}-table-responsive > .#{$class-prefix}-table-bordered {
    border: 0;
    > .#{$class-prefix}-html-thead,
    > .#{$class-prefix}-html-tbody,
    > .#{$class-prefix}-html-tfoot {
      > .#{$class-prefix}-html-tr {
        > .#{$class-prefix}-html-th:first-child,
        > .#{$class-prefix}-html-td:first-child {
          border-left: 0;
        }
        > .#{$class-prefix}-html-th:last-child,
        > .#{$class-prefix}-html-td:last-child {
          border-right: 0;
        }
      }
    }
    > .#{$class-prefix}-html-thead,
    > .#{$class-prefix}-html-tbody {
      > .#{$class-prefix}-html-tr:first-child {
        > .#{$class-prefix}-html-td,
        > .#{$class-prefix}-html-th {
          border-bottom: 0;
        }
      }
    }
    > .#{$class-prefix}-html-tbody,
    > .#{$class-prefix}-html-tfoot {
      > .#{$class-prefix}-html-tr:last-child {
        > .#{$class-prefix}-html-td,
        > .#{$class-prefix}-html-th {
          border-bottom: 0;
        }
      }
    }
  }
  > .#{$class-prefix}-table-responsive {
    border: 0;
    margin-bottom: 0;
  }
}


// Collapsible panels (aka, accordion)
//
// Wrap a series of panels in `.panel-group` to turn them into an accordion with
// the help of our collapse JavaScript plugin.

.#{$class-prefix}-panel-group {
  margin-bottom: $line-height-computed;

  // Tighten up margin so it's only between panels
  .#{$class-prefix}-panel {
    margin-bottom: 0;
    border-radius: $panel-border-radius;

    + .#{$class-prefix}-panel {
      margin-top: 5px;
    }
  }

  .#{$class-prefix}-panel-heading {
    border-bottom: 0;

    + .#{$class-prefix}-panel-collapse > .#{$class-prefix}-panel-body,
    + .#{$class-prefix}-panel-collapse > .#{$class-prefix}-list-group {
      border-top: 1px solid $panel-inner-border;
    }
  }

  .#{$class-prefix}-panel-footer {
    border-top: 0;
    + .#{$class-prefix}-panel-collapse .#{$class-prefix}-panel-body {
      border-bottom: 1px solid $panel-inner-border;
    }
  }
}


// Contextual variations
.#{$class-prefix}-panel-default {
  @include panel-variant($panel-default-border, $panel-default-text, $panel-default-heading-bg, $panel-default-border);
}
.#{$class-prefix}-panel-primary {
  @include panel-variant($panel-primary-border, $panel-primary-text, $panel-primary-heading-bg, $panel-primary-border);
}
.#{$class-prefix}-panel-success {
  @include panel-variant($panel-success-border, $panel-success-text, $panel-success-heading-bg, $panel-success-border);
}
.#{$class-prefix}-panel-info {
  @include panel-variant($panel-info-border, $panel-info-text, $panel-info-heading-bg, $panel-info-border);
}
.#{$class-prefix}-panel-warning {
  @include panel-variant($panel-warning-border, $panel-warning-text, $panel-warning-heading-bg, $panel-warning-border);
}
.#{$class-prefix}-panel-danger {
  @include panel-variant($panel-danger-border, $panel-danger-text, $panel-danger-heading-bg, $panel-danger-border);
}
