@use '../../styles/tools'
@use '../../styles/settings'
@use './variables' as *
@use './mixins' as *

// Theme
.v-table
  @include tools.theme($table-theme...)

  .v-table-divider
    border-right: $table-border

  .v-table__wrapper
    > table
      > thead
        > tr
          > th
            border-bottom: $table-border
            color: rgba(var(--v-theme-on-surface), var(--v-medium-emphasis-opacity))

      > tbody
        > tr
          &:not(:last-child)
            > td,
            > th
              border-bottom: $table-border

      > tfoot
        > tr
            > td,
            > th
              border-top: $table-border


  &.v-table--hover
    > .v-table__wrapper
      > table
        > tbody
          > tr
            &:hover td
              background: $table-hover-color

  &.v-table--fixed-header
    > .v-table__wrapper
      > table
        > thead
          > tr
            > th
              background: $table-background
              box-shadow: inset 0 -1px 0 $table-border-color
              z-index: 1

  &.v-table--fixed-footer
    > tfoot
      > tr
        > th,
        > td
          background: $table-background
          box-shadow: inset 0 1px 0 $table-border-color

// Block
.v-table
  --v-table-header-height: #{$table-header-height}

  border-radius: inherit
  // Do not inherit line-height
  line-height: $table-line-height
  max-width: 100%

  > .v-table__wrapper
    > table
      width: 100%
      border-spacing: 0

      > tbody,
      > thead,
      > tfoot
        > tr
          > td,
          > th
            padding: $table-column-padding
            transition: height settings.$standard-easing

          > th
            font-weight: $table-header-font-weight
            user-select: none
            text-align: start

  @at-root
    @include tools.density('v-table', $table-density) using ($modifier)
      > .v-table__wrapper
        > table
          > tbody,
          > thead,
          > tfoot
            > tr
              > th
                height: calc(var(--v-table-header-height) + $modifier)

              > td
                height: calc($table-row-height + $modifier)

// Elements
.v-table__wrapper
  border-radius: inherit
  overflow: auto

// Modifiers
.v-table--has-top
  > .v-table__wrapper
    > table
      > tbody
        > tr
          &:first-child
            &:hover
              > td
                &:first-child
                  border-top-left-radius: 0

                &:last-child
                  border-top-right-radius: 0

.v-table--has-bottom
  > .v-table__wrapper
    > table
      > tbody
        > tr
          &:last-child
            &:hover
              > td
                &:first-child
                  border-bottom-left-radius: 0

                &:last-child
                  border-bottom-right-radius: 0

.v-table--fixed-height
  > .v-table__wrapper
    overflow-y: auto

.v-table--fixed-header
  > .v-table__wrapper
    > table
      > thead
        > tr
          > th
            border-bottom: 0px !important
            position: sticky
            top: 0

.v-table--fixed-footer
  > .v-table__wrapper
    > table
      > tfoot
        > tr
          > td,
          > th
              border-top: 0px !important
              position: sticky
              bottom: 0
