/* Custom element must be display:block for Tabulator to measure width */
tm-table2 {
  display: block;
  width: 100%;
}

/* ── Wrapper ──────────────────────────────────────────────────────────── */

.tm-table2-wrapper {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  margin: 0.75rem 0;
}

.tm-table2-error {
  color: #ef4444;
  padding: 1rem;
  font-size: 0.875rem;
}

/* ── Tabulator resets ─────────────────────────────────────────────────── */

.tm-table2-wrapper .tabulator {
  border: none !important;
  background-color: #ffffff !important;
  font-size: 0.9rem;
  color: #1f2937;
}

.tm-table2-wrapper .tabulator .tabulator-header {
  background-color: #f9fafb !important;
  color: #1f2937 !important;
  border-bottom: none !important;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.tm-table2-wrapper .tabulator .tabulator-col {
  background-color: #f9fafb !important;
  color: #1f2937 !important;
  padding: 0.375rem 0.5rem !important;
  border-right: none !important;
}

.tm-table2-wrapper .tabulator-col,
.tm-table2-wrapper .tabulator-frozen-col {
  box-shadow: none !important;
}

.tm-table2-wrapper .tabulator-col-content {
  border-right: none !important;
  background-color: transparent !important;
  width: 100%;
}

.tm-table2-wrapper .tabulator-tableholder {
  border-top: none !important;
  overflow-x: hidden !important;
}

/* ── Data cells — no vertical separators ──────────────────────────────── */

.tm-table2-wrapper .tabulator .tabulator-row .tabulator-cell,
.tm-table2-wrapper .tabulator-cell {
  border-right: none !important;
  border-left: none !important;
  box-shadow: none !important;
}

/* ── Resize handle — header-only separator ────────────────────────────── */

.tm-table2-wrapper .tabulator-col-resize-handle {
  width: 6px !important;
  position: relative;
  cursor: col-resize !important;
}

.tm-table2-wrapper .tabulator-col-resize-handle::after {
  display: none !important;
}

.tm-table2-wrapper .tabulator-header .tabulator-col-resize-handle::after {
  content: "";
  display: block !important;
  position: absolute;
  top: 20%;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  background: #d1d5db;
  border-radius: 1px;
  transition: background 0.15s ease;
}

.tm-table2-wrapper .tabulator-header .tabulator-col-resize-handle:hover::after {
  background: #2563eb;
}

.tm-table2-wrapper .tabulator-row .tabulator-col-resize-handle {
  display: none !important;
}

/* ── Column title — 3-region flex layout ──────────────────────────────── */

.tm-table2-wrapper .tabulator-col-title {
  display: flex !important;
  flex: 1 1 auto !important;
  width: 100% !important;
  min-width: 0 !important;
  padding-right: 0 !important;
  overflow: hidden;
}

.tm-table2-col-title-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.tm-table2-col-title-spacer {
  display: none;
}

.tm-table2-col-title-center {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  overflow: hidden;
}

.tm-table2-col-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.tm-table2-col-title-actions {
  position: absolute !important;
  right: 1.25rem !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  display: flex;
  align-items: center;
}

/* ── Filter-active indicator ──────────────────────────────────────────── */

.tm-table2-active-filter-icon {
  font-size: 0.9rem !important;
  color: transparent;
  flex-shrink: 0;
  transition: color 0.15s ease;
  line-height: 1 !important;
  pointer-events: none;
}

.tm-table2-active-filter-icon--on {
  color: #2563eb;
}

/* ── ⋯ menu button ────────────────────────────────────────────────────── */

.tm-table2-col-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  color: #9ca3af;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
  line-height: 1;
}

.tm-table2-col-menu-btn .material-symbols-outlined {
  font-size: 1.1rem !important;
  line-height: 1 !important;
}

.tm-table2-wrapper .tabulator-col:hover .tm-table2-col-menu-btn {
  opacity: 1;
}

.tm-table2-col-menu-btn:hover {
  color: #2563eb;
}

/* ── Sort arrows ──────────────────────────────────────────────────────── */

.tm-table2-wrapper .tabulator-col .tabulator-col-sorter {
  color: #d1d5db;
  position: absolute !important;
  right: 0.125rem !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  display: flex;
  align-items: center;
}

.tm-table2-wrapper .tabulator-col.tabulator-sortable[aria-sort="ascending"] .tabulator-col-sorter,
.tm-table2-wrapper .tabulator-col.tabulator-sortable[aria-sort="descending"] .tabulator-col-sorter {
  color: #2563eb;
}

/* ── Column dropdown menu ─────────────────────────────────────────────── */

.tm-table2-col-menu-popup {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.05);
  min-width: 180px;
  overflow: hidden;
  animation: tm-table2-popup-in 0.12s ease;
}

.tm-table2-col-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  color: #111827;
  cursor: pointer;
  transition: background 0.1s ease;
  white-space: nowrap;
  user-select: none;
}

.tm-table2-col-menu-item:hover:not(.tm-table2-col-menu-item--disabled) {
  background: #f3f4f6;
}

.tm-table2-col-menu-item--disabled {
  color: #d1d5db;
  cursor: default;
}

.tm-table2-col-menu-separator {
  height: 1px;
  background: #e5e7eb;
  margin: 0.2rem 0;
}

.tm-table2-menu-icon {
  font-size: 1rem !important;
  line-height: 1 !important;
  flex-shrink: 0;
}

/* ── Rows & cells ─────────────────────────────────────────────────────── */

.tm-table2-wrapper .tabulator-row {
  border-bottom: 1px solid #e5e7eb !important;
  cursor: pointer;
  position: relative;
}

/* Row hover actions */
.tm-table2-row-actions {
  display: none;
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  background: #ffffff;
  padding: 0.25rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid #e5e7eb;
}

.tm-table2-wrapper .tabulator-row:hover .tm-table2-row-actions {
  display: flex !important;
  gap: 0.25rem;
}

.tm-table2-wrapper .tabulator-row .tabulator-cell {
  background-color: #ffffff !important;
  padding: 0.5rem 0.75rem;
}

.tm-table2-wrapper .tabulator-row:nth-child(even) .tabulator-cell {
  background-color: #fcfcfc !important;
}

.tm-table2-wrapper .tabulator-row:hover .tabulator-cell {
  background-color: #eff6ff !important;
}

/* ── Placeholder ──────────────────────────────────────────────────────── */

.tm-table2-wrapper .tabulator-placeholder {
  color: #9ca3af;
  font-style: italic;
  padding: 2rem;
  text-align: center;
}

/* ── Links inside cells ───────────────────────────────────────────────── */

.tm-table2-wrapper .tabulator-cell a {
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
}

.tm-table2-wrapper .tabulator-cell a:hover {
  text-decoration: underline;
}

/* ── Badge formatter ──────────────────────────────────────────────────── */

.tm-table2-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  text-transform: capitalize;
  letter-spacing: 0.02em;
  background-color: #f3f4f6;
  color: #374151;
}

.tm-table2-badge-active        { background-color: #dcfce7; color: #166534; }
.tm-table2-badge-planning      { background-color: #fef9c3; color: #854d0e; }
.tm-table2-badge-completed     { background-color: #e0f2fe; color: #0369a1; }
.tm-table2-badge-on-hold       { background-color: #ffedd5; color: #9a3412; }
.tm-table2-badge-created       { background-color: #dcfce7; color: #166534; }
.tm-table2-badge-pending       { background-color: #fef3c7; color: #92400e; }
.tm-table2-badge-approved      { background-color: #e0f2fe; color: #0369a1; }
.tm-table2-badge-rejected      { background-color: #fee2e2; color: #991b1b; }
.tm-table2-badge-closed        { background-color: #e5e7eb; color: #374151; }
.tm-table2-badge-in-progress   { background-color: #ede9fe; color: #4c1d95; }
.tm-table2-badge-not-started   { background-color: #f3f4f6; color: #374151; }
.tm-table2-badge-running       { background-color: #dbeafe; color: #1d4ed8; }

/* ── Filter popup ─────────────────────────────────────────────────────── */

.tm-table2-filter-popup {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.625rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  min-width: 220px;
  overflow: hidden;
  animation: tm-table2-popup-in 0.12s ease;
}

@keyframes tm-table2-popup-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tm-table2-filter-popup-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.8125rem;
  color: #374151;
}

.tm-table2-filter-icon {
  font-size: 1rem !important;
  color: #2563eb;
}

.tm-table2-filter-popup-header .tm-table2-filter-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  display: flex;
  align-items: center;
  padding: 0;
}

.tm-table2-filter-popup-header .tm-table2-filter-close:hover { color: #374151; }
.tm-table2-filter-popup-header .tm-table2-filter-close .material-symbols-outlined { font-size: 1.125rem !important; }

.tm-table2-filter-popup-body {
  padding: 0.75rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.tm-table2-filter-input {
  width: 100%;
  padding: 0.4rem 0.625rem;
  border: 1px solid #d1d5db;
  border-radius: 0.4rem;
  font-size: 0.875rem;
  color: #111827;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.tm-table2-filter-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.tm-table2-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.tm-table2-btn {
  padding: 0.35rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.tm-table2-btn-ghost {
  background: transparent;
  color: #6b7280;
  border: 1px solid #d1d5db;
}

.tm-table2-btn-ghost:hover { background: #f3f4f6; }

.tm-table2-btn-primary {
  background: #2563eb;
  color: #ffffff;
}

.tm-table2-btn-primary:hover { background: #1d4ed8; }

/* ── Action buttons (e.g. edit) ──────────────────────────────────────── */

.tm-table2-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  color: #9ca3af;
  transition: color 0.15s ease, background 0.15s ease;
}

.tm-table2-action-btn:hover {
  color: #4f46e5;
  background: #eef2ff;
}

.tm-table2-actions-cell {
  text-align: center !important;
}

/* ── Pagination Dropdown ──────────────────────────────────────────────── */

.tm-table2-wrapper .tabulator-footer .tabulator-page-size {
  padding: 0.15rem 1.25rem 0.15rem 0.35rem !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  background-position: right 0.15rem center !important;
  background-size: 1rem 1rem !important;
}

