/* Column Customization Styles */

/* ========================================
   COLUMN CUSTOMIZATION BUTTON
   ======================================== */

.column-customize-btn {
  position: relative;
}

.column-customize-dropdown {
  min-width: 280px;
  max-height: 500px;
  overflow-y: auto;
  padding: 0;
}

.column-customize-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bs-border-color);
  background-color: var(--bs-secondary-bg);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.column-customize-header .reset-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  text-transform: none;
}

/* ========================================
   COLUMN LIST
   ======================================== */

.column-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.column-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bs-border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: move;
  transition: background-color 0.2s ease;
  user-select: none;
}

.column-item:hover {
  background-color: var(--bs-secondary-bg);
}

.column-item:last-child {
  border-bottom: none;
}

.column-item.dragging {
  opacity: 0.5;
  background-color: var(--bs-primary-bg-subtle);
}

.column-item.drag-over {
  border-top: 2px solid var(--bs-primary);
}

.column-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.column-item.disabled .drag-handle {
  cursor: not-allowed;
  opacity: 0.3;
}

/* Drag handle */
.drag-handle {
  cursor: grab;
  color: var(--bs-secondary-color);
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.column-item.disabled .drag-handle {
  cursor: not-allowed;
}

/* Column checkbox */
.column-checkbox {
  min-width: 20px;
  min-height: 20px;
  cursor: pointer;
}

.column-item.disabled .column-checkbox {
  cursor: not-allowed;
}

/* Column label */
.column-label {
  flex: 1;
  font-size: 0.9375rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.column-label .required-indicator {
  color: var(--bs-danger);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Column count badge */
.column-count-badge {
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background-color: var(--bs-secondary-bg);
  color: var(--bs-secondary-color);
}

/* ========================================
   HIDDEN COLUMNS INDICATOR
   ======================================== */

.hidden-columns-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  background-color: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
  border: 1px solid var(--bs-warning-border-subtle);
}

.hidden-columns-indicator i {
  font-size: 0.875rem;
}

/* ========================================
   TABLE COLUMN VISIBILITY
   ======================================== */

/* Hidden columns */
.table th[data-column].column-hidden,
.table td[data-column].column-hidden {
  display: none !important;
}

/* Column reordering classes */
.table th[data-column] {
  order: var(--column-order, 0);
}

.table td[data-column] {
  order: var(--column-order, 0);
}

/* When table uses flexbox for column reordering */
.table-reorderable thead tr {
  display: flex;
}

.table-reorderable tbody tr {
  display: flex;
}

.table-reorderable th,
.table-reorderable td {
  flex: 1;
  min-width: 0;
}

/* Maintain specific widths for certain columns */
.table-reorderable th[data-column="id"],
.table-reorderable td[data-column="id"] {
  flex: 0 0 80px;
}

.table-reorderable th[data-column="actions"],
.table-reorderable td[data-column="actions"] {
  flex: 0 0 120px;
}

/* ========================================
   DROPDOWN FOOTER
   ======================================== */

.column-customize-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--bs-border-color);
  background-color: var(--bs-secondary-bg);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.column-customize-footer .btn {
  flex: 1;
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

@media (max-width: 768px) {
  .column-customize-dropdown {
    min-width: 260px;
    max-height: 400px;
  }

  .column-item {
    padding: 0.875rem 1rem;
  }

  .drag-handle {
    font-size: 1.25rem;
  }

  .column-checkbox {
    min-width: 24px;
    min-height: 24px;
  }

  .column-label {
    font-size: 1rem;
  }

  /* Disable column reordering on mobile */
  .table-reorderable thead tr,
  .table-reorderable tbody tr {
    display: table-row;
  }

  .table-reorderable th,
  .table-reorderable td {
    display: table-cell;
  }
}

/* ========================================
   DARK MODE
   ======================================== */

[data-bs-theme="dark"] .column-customize-header {
  background-color: var(--zyte-surface-variant);
}

[data-bs-theme="dark"] .column-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .column-item.dragging {
  background-color: rgba(var(--bs-primary-rgb), 0.2);
}

[data-bs-theme="dark"] .column-customize-footer {
  background-color: var(--zyte-surface-variant);
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes columnSlideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.column-item {
  animation: columnSlideIn 0.2s ease;
}

/* Smooth transitions for show/hide */
.table th[data-column],
.table td[data-column] {
  transition: opacity 0.2s ease;
}

.table th[data-column].column-hidden,
.table td[data-column].column-hidden {
  opacity: 0;
}
