.table-filters {
  margin-bottom: 1rem;

  .table-filters-buttons {
    display: flex;

    .table-filters-option {
      margin: 0;
      margin-right: -1px;
      padding: 2px 10px;
      border: 1px solid var(--bulma-border);
      color: var(--bulma-text);
      cursor: pointer;
      background-color: var(--bulma-scheme-main);
      border-radius: 0;
      text-decoration: none;

      &.active {
        color: #fff;
        background: #009fe3;
        border: 1px solid #009fe3;
      }
    }
  }
}

.space-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.table-pagination-wrapper {
  align-items: center;
  margin: 16px 32px 0 0; 

  .table-pagination {
    display: flex;
    gap: 3px;

    .table-pagination-button a,
    .table-pagination-button span {
      background-color: var(--bulma-scheme-main);
      border-radius: 3px;
      border: 1px solid transparent;
      color: var(--bulma-text);
      padding: 4.5px 10px;
      text-decoration: none;
    }

    .table-pagination-button a {
      cursor: pointer;
      transition: background-color 0.2s ease-in-out;

      &:hover {
        background-color: var(--bulma-scheme-main-ter);
      }
    }

    .table-pagination-button span {
      cursor: not-allowed;
      color: var(--bulma-text-weak);

      &.active {
        background: #009fe3;
        border: 1px solid #009fe3;
        color: #fff;
      }
    }
  }
}

.table-filters-search-bar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  text-decoration: none;
  width: 100%;
  min-width: 0;

  .table-filters-search-submit {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    height: 100%;

    .fa-search {
      font-size: 0.8rem;
      color: var(--bulma-text-weak);
      margin-left: 0.5rem;
      line-height: 1;
    }

    &:hover .fa-search {
      color: var(--bulma-text);
    }
  }

  .table-filters-search-input {
    border: none;
    flex-grow: 1;
    background-color: transparent;
    color: inherit;
    font-size: inherit;

    &:focus {
      outline: none;
    }
  }
}

.table-container {
  overflow: visible;
}

.new-dropdown {
  position: relative;

  .new-dropdown-title {
    align-items: center;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    margin: 0;
    text-decoration: none;
    width: 100%;
    min-width: 0;

    .fa-chevron-down {
      font-size: 0.6rem;
      color: var(--bulma-text-weak);
      margin-left: 0.5rem;
      display: flex;
      align-items: center;
      height: 100%;
      line-height: 1;
    }

    > span:first-child {
      flex: 1;
      text-align: left;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .new-dropdown-search-input {
      border: none;
      width: 100%;
      background-color: transparent;
      color: inherit;
      font-size: inherit;

      &:focus {
        outline: none;
      }
    }
  }

  .new-dropdown-menu {
    position: absolute;
    background-color: var(--bulma-scheme-main);
    border: 1px solid var(--bulma-border);
    border-radius: var(--bulma-radius);
    display: flex;
    flex-direction: column;
    z-index: 9;
    min-width: 100%;
    width: max-content;
    max-height: 0px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: max-height 0.3s ease;

    &.top-dropdown {
      top: auto;
      bottom: 100%;
      max-height: 300px;
    }
    &.bottom-dropdown {
      top: 100%;
      bottom: auto;
      max-height: 300px;
    }
    &.has-been-top-dropdown {
      top: auto;
      bottom: 100%;
    }

    a {
      width: 100%;
      color: var(--bulma-text);
      text-decoration: none;
      padding: 2px 10px;

      &.active {
        color: #fff;
        background-color: #009fe3;
      }

      &:hover {
        color: #009fe3;
        background-color: var(--bulma-scheme-main-bis);
      }
    }
  }
}

.table-column-options-filterer {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.table-filters-multi-select {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.table-filters-multi-select .new-dropdown-title {
  width: auto;
  flex-wrap: nowrap;
  gap: 0.25rem;
}

.filter-icon-dropdown {
  position: absolute;
  left: auto;
  right: 0;
  z-index: 20;
  min-width: 12rem;
  width: max-content;
  max-width: min(10rem, 45vw);
  display: flex;
  flex-direction: column;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;

  &.top-dropdown {
    background-color: var(--bulma-scheme-main);
    border: 1px solid var(--bulma-border);
    border-radius: var(--bulma-radius);
    box-shadow: var(--bulma-shadow);
    top: auto;
    bottom: 100%;
    margin-bottom: 2px;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  &.bottom-dropdown {
    background-color: var(--bulma-scheme-main);
    border: 1px solid var(--bulma-border);
    border-radius: var(--bulma-radius);
    box-shadow: var(--bulma-shadow);
    top: 100%;
    bottom: auto;
    margin-top: 2px;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  &.has-been-top-dropdown {
    top: auto;
    bottom: 100%;
  }

}

.filter-icon-dropdown-header {
  padding: 0.5rem 0.75rem;
}

.filter-icon-dropdown-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.table-filters-multi-select .table-filters-options {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem 0;
}

.table-filters-multi-select .table-filters-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.table-filters-multi-select .table-filters-option-checkbox {
  flex-shrink: 0;
}

.table-filters-multi-select .table-filters-option-label {
  cursor: pointer;
  flex: 1;
  margin: 0;
}

.table-filters-multi-select-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
}



.filter-icon-dropdown-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
}

/* Datetime Filter Styles */
.datetime-filter-container {
  border-bottom: 1px solid var(--bulma-border-weak);
  background-color: var(--bulma-scheme-main-bis);
}

.datetime-filter-row .label {
  color: var(--bulma-text-weak);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.datetime-filter-selects {
  gap: 4px;
}

/* Ensure the dropdown is wide enough for the composite filter */
.table-filters-multi-select[data-controller*="datetime-filter"] .filter-icon-dropdown {
  min-width: 360px;
  max-width: 420px;
}
