$table-color: v("text-strong") !default
$table-background-color: v("scheme-main") !default

$table-cell-border: 1px solid v("border") !default
$table-cell-border-width: 0 0 1px !default
$table-cell-padding: 0.5em 0.75em !default
$table-cell-heading-color: v("text-strong") !default

$table-head-cell-border-width: 0 0 2px !default
$table-head-cell-color: v("text-strong") !default
$table-foot-cell-border-width: 2px 0 0 !default
$table-foot-cell-color: v("text-strong") !default

$table-head-background-color: transparent !default
$table-body-background-color: transparent !default
$table-foot-background-color: transparent !default

$table-row-hover-background-color: v("scheme-main-bis") !default

$table-row-active-background-color: v("primary") !default
$table-row-active-color: v("primary-invert") !default

$table-striped-row-even-background-color: v("scheme-main-bis") !default
$table-striped-row-even-hover-background-color: v("scheme-main-ter") !default

+register(table-background-color,$table-background-color, true)
+register(table-color,$table-color, true)
+register(table-cell-border,$table-cell-border, true)
+register(table-cell-border-width,$table-cell-border-width, true)
+register(table-cell-padding,$table-cell-padding, true)
+register(table-row-active-background-color,$table-row-active-background-color, true)
+register(table-row-active-color,$table-row-active-color, true)
+register(table-cell-heading-color,$table-cell-heading-color, true)
+register(table-head-background-color,$table-head-background-color, true)
+register(table-head-cell-border-width,$table-head-cell-border-width, true)
+register(table-head-cell-color,$table-head-cell-color, true)
+register(table-foot-background-color,$table-foot-background-color, true)
+register(table-foot-cell-border-width,$table-foot-cell-border-width, true)
+register(table-foot-cell-color,$table-foot-cell-color, true)
+register(table-body-background-color,$table-body-background-color, true)
+register(table-row-hover-background-color,$table-row-hover-background-color, true)
+register(table-striped-row-even-hover-background-color,$table-striped-row-even-hover-background-color, true)
+register(table-striped-row-even-background-color,$table-striped-row-even-background-color, true)

.table
  @extend %block
  background-color: v("table-background-color")
  color: v("table-color")
  td,
  th
    border: v("table-cell-border")
    border-width: v("table-cell-border-width")
    padding: v("table-cell-padding")
    vertical-align: top
    // Colors
    @each $name in $colors-list
      $color: v($name)
      $color-invert: v($name+"-invert")
      &.is-#{$name}
        background-color: $color
        border-color: $color
        color: $color-invert
    // Modifiers
    &.is-narrow
      white-space: nowrap
      width: 1%
    &.is-selected
      background-color: v("table-row-active-background-color")
      color: v("table-row-active-color")
      a,
      strong
        color: currentColor
    &.is-vcentered
      vertical-align: middle
  th
    color: v("table-cell-heading-color")
    &:not([align])
      text-align: inherit
  tr
    &.is-selected
      background-color: v("table-row-active-background-color")
      color: v("table-row-active-color")
      a,
      strong
        color: currentColor
      td,
      th
        border-color: v("table-row-active-color")
        color: currentColor
  thead
    background-color: v("table-head-background-color")
    td,
    th
      border-width: v("table-head-cell-border-width")
      color: v("table-head-cell-color")
  tfoot
    background-color: v("table-foot-background-color")
    td,
    th
      border-width: v("table-foot-cell-border-width")
      color: v("table-foot-cell-color")
  tbody
    background-color: v("table-body-background-color")
    tr
      &:last-child
        td,
        th
          border-bottom-width: 0
  // Modifiers
  &.is-bordered
    td,
    th
      border-width: 1px
    tr
      &:last-child
        td,
        th
          border-bottom-width: 1px
  &.is-fullwidth
    width: 100%
  &.is-hoverable
    tbody
      tr:not(.is-selected)
        &:hover
          background-color: v("table-row-hover-background-color")
    &.is-striped
      tbody
        tr:not(.is-selected)
          &:hover
            background-color: v("table-row-hover-background-color")
            &:nth-child(even)
              background-color: v("table-striped-row-even-hover-background-color")
  &.is-narrow
    td,
    th
      padding: 0.25em 0.5em
  &.is-striped
    tbody
      tr:not(.is-selected)
        &:nth-child(even)
          background-color: v("table-striped-row-even-background-color")

.table-container
  @extend %block
  +overflow-touch
  overflow: auto
  overflow-y: hidden
  max-width: 100%
