.formGeneratorTable {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  font-family: var(--font-family);
  min-height: 0;
  flex: 1;
  overflow: hidden;
  height: 100%;
  max-height: 100%;
}

.title {
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--color-text);
  margin: 0;
  margin-bottom: 10px;
}

/* Table wrapper */
.tableWrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  border: 1px solid var(--color-border, #E2E8F0);
  border-radius: 8px;
  background: var(--color-bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Top horizontal scrollbar */
.topScrollbar {
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border, #e2e8f0);
  border-radius: 8px 8px 0 0;
}

.topScrollbarInner {
  height: 1px;
}

/* Table Container */
.tableContainer {
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  background: var(--color-bg);
  flex: 1 1 0;
  min-height: 0;
  max-height: 100%;
  border-radius: 0 0 8px 8px;
}

.emptyTable {
  min-height: auto;
  height: auto;
  max-height: none;
}

.emptyTable .topScrollbar {
  display: none;
}

.emptyState {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 40px 20px;
}

.emptyMessage {
  text-align: center;
  padding: 20px;
  color: var(--color-text);
  opacity: 0.5;
  font-size: 0.9rem;
  line-height: 1.5;
}

.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  font-size: 14px;
  color: var(--color-text-secondary, #94a3b8);
}

/* Table Styles */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: var(--color-bg);
  table-layout: fixed;
  word-wrap: break-word;
}

.table tbody tr[data-user-enabled="false"] {
  opacity: 0.6 !important;
  background-color: rgba(0, 0, 0, 0.02) !important;
}

.table tbody tr[data-user-enabled="false"]:hover {
  opacity: 0.8 !important;
  background-color: rgba(0, 0, 0, 0.05) !important;
}

.dark .table tbody tr[data-user-enabled="false"] {
  background-color: rgba(255, 255, 255, 0.02) !important;
}

.dark .table tbody tr[data-user-enabled="false"]:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Sticky thead */
.table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.table thead tr {
  background: var(--table-header-bg, rgba(0, 0, 0, 0.03));
}

.th {
  background: var(--table-header-bg, rgba(0, 0, 0, 0.03));
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text-secondary, #64748b);
  white-space: nowrap;
  overflow: visible;
  user-select: none;
  border-bottom: 2px solid var(--color-border, #e2e8f0);
}

.th.actionsColumn {
  text-align: center;
}

.th.sortable {
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.th.sortable:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text, #334155);
}

.headerContent {
  display: flex;
  align-items: center;
  justify-content: left;
  gap: 4px;
}

.columnLabel {
  cursor: pointer;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sortIcon {
  font-size: 11px;
  color: var(--color-text-secondary, #94a3b8);
  cursor: pointer;
  padding: 2px;
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
}

.sortIcon:hover {
  color: var(--color-text, #334155);
}

.sortIcon.sortActive {
  color: var(--color-secondary);
  font-weight: 600;
}

.sortIcon sub {
  font-size: 9px;
  font-weight: 500;
}

/* Filter icon */
.filterIcon {
  background: none;
  border: none;
  color: var(--color-text-secondary, #94a3b8);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: all 0.15s ease;
}

.filterIcon:hover {
  color: var(--color-text, #334155);
  background: rgba(0, 0, 0, 0.05);
}

.filterIcon.filterActive {
  color: var(--color-secondary);
  background: rgba(var(--color-secondary-rgb), 0.1);
}

/* Filter dropdown */
.filterDropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  max-width: 300px;
  background: var(--color-bg);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  margin-top: 4px;
}

.filterDropdownHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text);
}

.filterClearBtn {
  background: none;
  border: none;
  color: var(--color-text-secondary, #94a3b8);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
}

.filterClearBtn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text, #334155);
}

.filterDropdownOptions {
  max-height: 250px;
  overflow-y: auto;
  padding: 4px 0;
}

.filterOption {
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filterOption:hover {
  background: var(--color-gray-disabled, #f1f5f9);
}

.filterOptionSelected {
  background: rgba(var(--color-secondary-rgb), 0.08);
  color: var(--color-secondary);
  font-weight: 500;
}

.filterOptionSelected:hover {
  background: rgba(var(--color-secondary-rgb), 0.12);
}

.filterOptionMore {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--color-text-secondary, #94a3b8);
  font-style: italic;
}

.resizeHandle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
  background: transparent;
}

.resizeHandle:hover {
  background: var(--color-border, #cbd5e1);
}

.resizeHandle:active {
  background: var(--color-secondary);
  opacity: 0.6;
}

/* Table cells */
.td {
  padding: 8px 12px;
  border-top: 1px solid var(--color-border, #f1f5f9);
  color: var(--color-text);
  font-weight: 400;
  font-size: 13px;
  vertical-align: middle;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  overflow: visible;
}

.fkLoading {
  color: var(--color-text);
  opacity: 0.6;
  font-style: italic;
}

/* Rows */
.tr {
  transition: background-color 0.12s ease;
}

.tr:hover {
  background: var(--color-gray-disabled, #f8fafc);
}

.tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.015);
}

.tr:nth-child(even):hover {
  background: var(--color-gray-disabled, #f8fafc);
}

.tr.selected {
  background: rgba(var(--color-secondary-rgb), 0.08);
}

.tr.clickable {
  cursor: pointer;
}

/* Selection Column */
.selectColumn {
  text-align: center;
  padding: 4px !important;
  background: var(--color-bg);
  position: relative;
}

thead .selectColumn {
  background: var(--table-header-bg, rgba(0, 0, 0, 0.03));
}

tbody .selectColumn {
  border-top: 1px solid var(--color-border, #f1f5f9);
}

.selectColumn input[type="checkbox"] {
  cursor: pointer;
  transform: scale(1.1);
  width: 14px;
  height: 14px;
  accent-color: var(--color-secondary);
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--color-border, #cbd5e1);
  border-radius: 3px;
  background: var(--color-bg);
  position: relative;
  z-index: 1;
  appearance: auto;
  -webkit-appearance: checkbox;
  -moz-appearance: checkbox;
}

.selectColumn input[type="checkbox"]:checked {
  background-color: var(--color-secondary);
  border-color: var(--color-secondary);
}

.selectColumn input[type="checkbox"]:hover {
  border-color: var(--color-secondary);
}

.selectColumn input[type="checkbox"]:focus {
  outline: 2px solid var(--color-secondary);
  outline-offset: 2px;
}

/* Actions Column */
.actionsColumn {
  white-space: nowrap;
  text-align: center;
  padding: 4px !important;
  font-weight: 400;
  box-sizing: border-box;
  background: var(--color-bg);
  position: relative;
}

thead .actionsColumn {
  background: var(--table-header-bg, rgba(0, 0, 0, 0.03));
}

tbody .actionsColumn {
  border-top: 1px solid var(--color-border, #f1f5f9);
}

.actionButtons {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 0 auto;
}

.actionButtonsWrap {
  flex-wrap: wrap;
}

.actionButton {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  position: relative;
  min-width: 26px;
  min-height: 26px;
  background: linear-gradient(180deg, #8494a7 0%, #6b7b8d 100%);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.actionButton:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.actionButton:active {
  transform: translateY(0);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.actionIcon {
  font-size: 13px;
  height: 13px;
  width: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Delete Confirmation Buttons */
.deleteConfirmButtons {
  display: flex;
  gap: 2px;
  justify-content: center;
  align-items: center;
  background: var(--color-text-secondary, #64748b);
  border-radius: 8px;
}

.confirmButton {
  background: transparent !important;
  color: white !important;
}

.confirmButton:hover {
  background: rgba(255, 255, 255, 0.15) !important;
  transform: none;
}

.cancelButton {
  background: transparent !important;
  color: white !important;
}

.cancelButton:hover {
  background: rgba(255, 255, 255, 0.15) !important;
  transform: none;
}

.actionButton:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  flex-shrink: 0;
  flex-wrap: wrap;
  background: var(--color-bg);
}

.pageSizeSelector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-secondary, #64748b);
}

.pageSizeSelector label {
  white-space: nowrap;
  font-family: var(--font-family);
}

.pageSizeSelect {
  height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
  min-width: 60px;
}

.pageSizeSelect:focus {
  outline: none;
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 2px rgba(var(--color-secondary-rgb), 0.15);
}

.paginationButton {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--color-border, #e2e8f0);
  background: linear-gradient(180deg, var(--color-bg, #fff) 0%, #f4f5f7 100%);
  color: var(--color-text, #334155);
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-family);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.paginationButton:hover:not(:disabled) {
  background: linear-gradient(180deg, #edf0f4 0%, var(--color-gray-disabled, #CBD5E0) 100%);
  border-color: var(--color-text-secondary, #94a3b8);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.paginationButton:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.paginationButton:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.paginationInfo {
  font-size: 13px;
  color: var(--color-text-secondary, #64748b);
  margin: 0 8px;
  white-space: nowrap;
}

/* Page numbers */
.pageNumbers {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
  justify-content: flex-start;
  max-width: 60vw;
  max-height: 120px;
  overflow-y: auto;
  padding: 2px;
}

.pageNumber {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--color-border, #e2e8f0);
  background: linear-gradient(180deg, var(--color-bg, #fff) 0%, #f4f5f7 100%);
  color: var(--color-text);
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 12px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.03);
}

.pageNumber:hover:not(:disabled) {
  background: linear-gradient(180deg, #edf0f4 0%, var(--color-gray-disabled, #CBD5E0) 100%);
  border-color: var(--color-text-secondary, #94a3b8);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.pageNumber:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.pageNumber:disabled {
  cursor: default;
}

.pageNumberActive {
  background: linear-gradient(180deg, #5a82b5 0%, var(--color-secondary) 100%);
  color: white;
  border-color: var(--color-secondary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(74, 111, 165, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.pageNumberActive:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--color-secondary) 0%, var(--color-secondary-hover) 100%);
  border-color: var(--color-secondary-hover);
}

.pageEllipsis {
  padding: 0 6px;
  color: var(--color-text-secondary, #94a3b8);
  font-size: 13px;
}

/* Loading overlay */
.loadingOverlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 8px;
}

.loadingOverlay p {
  margin-top: 12px;
  color: var(--color-text-secondary, #64748b);
  font-size: 13px;
}

/* Responsive */
@media (max-width: 768px) {
  .tableContainer {
    flex: 1;
    min-height: 0;
    max-height: 100%;
  }

  .emptyTable {
    min-height: auto;
    height: auto;
  }

  .th,
  .td {
    padding: 6px 8px;
    font-size: 12px;
  }

  .actionButtons {
    flex-direction: column;
    gap: 2px;
  }

  .actionButton {
    padding: 4px;
    font-size: 10px;
    min-width: 22px;
    min-height: 22px;
  }

  .pagination {
    flex-direction: column;
    gap: 10px;
    padding: 10px;
  }

  .pageSizeSelector {
    order: -1;
    justify-content: center;
  }

  .paginationInfo {
    text-align: center;
    margin: 0;
    font-size: 12px;
  }

  .pageNumbers {
    max-width: 100%;
    justify-content: center;
  }

  .pageNumber {
    min-width: 24px;
    height: 24px;
    font-size: 11px;
  }
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  .table thead tr {
    background: rgba(255, 255, 255, 0.05);
  }

  .th {
    background: rgba(255, 255, 255, 0.05);
    border-bottom-color: rgba(255, 255, 255, 0.12);
  }

  thead .selectColumn,
  thead .actionsColumn {
    background: rgba(255, 255, 255, 0.05);
  }

  .th.sortable:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  .tr:hover {
    background: rgba(255, 255, 255, 0.04);
  }

  .tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
  }

  .tr.selected {
    background: rgba(var(--color-secondary-rgb), 0.15);
  }

  .loadingOverlay {
    background: rgba(30, 30, 30, 0.9);
  }

  .pageNumber {
    background: var(--color-bg, #2d2d2d);
    border-color: var(--color-border, #444);
  }
}

/* Accessibility */
.actionButton:focus,
.paginationButton:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(var(--color-secondary-rgb), 0.3);
}

/* Scrollbar */
.tableContainer::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.tableContainer::-webkit-scrollbar-track {
  background: transparent;
}

.tableContainer::-webkit-scrollbar-thumb {
  background: var(--color-border, #cbd5e1);
  border-radius: 3px;
}

.tableContainer::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-secondary, #94a3b8);
}

.topScrollbar::-webkit-scrollbar {
  height: 6px;
}

.topScrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.topScrollbar::-webkit-scrollbar-thumb {
  background: var(--color-border, #cbd5e1);
  border-radius: 3px;
}

.topScrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-secondary, #94a3b8);
}

/* Loading State */
.loadingState {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--color-text-secondary, #64748b);
}

.loadingSpinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--color-border, #e2e8f0);
  border-top: 2px solid var(--color-text-secondary, #64748b);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Boolean Cells */
.booleanCell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-size: 14px;
  font-weight: bold;
  border-radius: 6px;
  transition: all 0.15s ease;
  user-select: none;
}

.booleanEditable {
  cursor: pointer;
  background: transparent;
  border: 1.5px solid var(--color-border, #e2e8f0);
}

.booleanEditable:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.booleanEditable:active {
  transform: scale(0.95);
}

.booleanEditable.booleanTrue {
  color: var(--color-success, #16a34a);
  border-color: var(--color-success, #16a34a);
  background: rgba(22, 163, 74, 0.08);
}

.booleanEditable.booleanTrue:hover {
  background: rgba(22, 163, 74, 0.15);
}

.booleanEditable.booleanFalse {
  color: var(--color-text-secondary, #94a3b8);
  border-color: var(--color-border, #e2e8f0);
  background: transparent;
}

.booleanEditable.booleanFalse:hover {
  color: var(--color-text, #334155);
  border-color: var(--color-text-secondary, #94a3b8);
  background: rgba(0, 0, 0, 0.03);
}

.booleanReadonly {
  cursor: default;
  background: transparent;
  border: none;
  opacity: 0.7;
}

.booleanReadonly.booleanTrue {
  color: var(--color-success, #16a34a);
}

.booleanReadonly.booleanFalse {
  color: var(--color-text-secondary, #94a3b8);
}

.booleanLoading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: booleanPulse 1s ease-in-out infinite;
  color: var(--color-text-secondary, #64748b);
  font-size: 14px;
}

@keyframes booleanPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Grouping */
.groupHeader {
  cursor: pointer;
  user-select: none;
}

.groupHeader:hover {
  background-color: var(--color-gray-disabled, #f1f5f9) !important;
}

.groupHeader .td {
  font-weight: 600;
  font-size: 12px;
}

.groupToggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 10px;
  color: var(--color-text-secondary, #64748b);
  transition: transform 0.2s ease;
}

.groupCount {
  font-size: 11px;
  color: var(--color-text-secondary, #94a3b8);
  font-weight: 400;
  margin-left: 4px;
}

.groupActions {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
