/**
 * TableCrafter.js CSS Styles
 * Complete styling for advanced features
 */

/* === Base Table Styles === */
.tc-wrapper {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
}

.tc-table-container {
  overflow-x: auto;
  border: 1px solid #e1e5e9;
  border-radius: 8px;
  background: white;
}

.tc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.tc-table th,
.tc-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #e1e5e9;
}

.tc-table th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #495057;
  position: sticky;
  top: 0;
  z-index: 10;
}

.tc-table tr:hover {
  background-color: #f8f9fa;
}

.tc-sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
  position: relative;
}

.tc-sortable:hover {
  background-color: #e9ecef;
}

/* Default sorting indicator (unsorted) */
.tc-sortable::after {
  content: ' ⇅';
  opacity: 0.5;
  font-size: 12px;
  margin-left: 8px;
  color: #6c757d;
}

/* Active sorting indicators */
.tc-sortable[aria-sort="ascending"]::after {
  content: ' ↑';
  opacity: 1;
  color: #007bff;
  font-weight: bold;
}

.tc-sortable[aria-sort="descending"]::after {
  content: ' ↓';
  opacity: 1;
  color: #007bff;
  font-weight: bold;
}

/* Enhanced hover state for sorted columns */
.tc-sortable[aria-sort="ascending"]:hover,
.tc-sortable[aria-sort="descending"]:hover {
  background-color: #e3f2fd;
}

.tc-editable {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: border-color 0.2s;
}

.tc-editable:hover {
  border-color: #007bff;
  background-color: #f8f9ff;
}

.tc-edit-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  padding: 4px;
}

.tc-no-results {
  text-align: center;
  padding: 40px 20px;
  color: #6c757d;
  font-style: italic;
}

/* === Advanced Filters === */
.tc-filters {
  margin-bottom: 20px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e1e5e9;
}

.tc-clear-filters {
  background: #dc3545;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  margin-bottom: 12px;
  transition: background-color 0.2s;
}

.tc-clear-filters:hover {
  background: #c82333;
}

.tc-filters-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.tc-filter {
  display: flex;
  flex-direction: column;
}

.tc-filter-label {
  font-weight: 600;
  margin-bottom: 4px;
  color: #495057;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Base styles for all filter inputs/buttons */
.tc-filter-input,
.tc-multiselect-button,
.tc-date-from,
.tc-date-to,
.tc-number-min,
.tc-number-max {
  width: 100%;
  height: 38px;
  padding: 8px 12px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  background: white;
  color: #495057;
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-align: left;
}

.tc-filter-input:focus,
.tc-multiselect-button:focus,
.tc-date-from:focus,
.tc-date-to:focus,
.tc-number-min:focus,
.tc-number-max:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.tc-multiselect-button:hover {
  border-color: #007bff;
}

/* === Multiselect Filter === */
.tc-multiselect-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.tc-multiselect-button::after {
  content: '▼';
  color: #6c757d;
  font-size: 10px;
  margin-left: 8px;
}

.tc-multiselect-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ced4da;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tc-multiselect-option {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.tc-multiselect-option:hover {
  background-color: #f8f9fa;
}

.tc-multiselect-option input[type="checkbox"] {
  margin-right: 8px;
}

/* === Date & Number Range Filters === */
.tc-daterange-container,
.tc-numberrange-container {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tc-date-from,
.tc-date-to,
.tc-number-min,
.tc-number-max {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding-left: 4px;
  padding-right: 4px;
}

/* === Mobile Cards === */
.tc-cards-container {
  display: grid;
  gap: 16px;
}

.tc-card {
  background: white;
  border: 1px solid #e1e5e9;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s, transform 0.2s;
}

.tc-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.tc-card-header {
  font-size: 16px;
  font-weight: 600;
  color: #212529;
  margin-bottom: 12px;
  border-bottom: 1px solid #e1e5e9;
  padding-bottom: 8px;
}

.tc-card-body {
  display: grid;
  gap: 8px;
}

.tc-card-field {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
}

.tc-card-label {
  font-weight: 600;
  color: #495057;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tc-card-value {
  color: #212529;
}

.tc-card-value.tc-editable {
  cursor: pointer;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  transition: all 0.2s;
}

.tc-card-value.tc-editable:hover {
  border-color: #007bff;
  background-color: #f8f9ff;
}

/* === Expandable Cards === */
.tc-card-expandable {
  cursor: pointer;
}

.tc-card-toggle {
  float: right;
  color: #6c757d;
  font-size: 18px;
  transition: transform 0.2s;
}

.tc-card-expanded .tc-card-toggle {
  transform: rotate(180deg);
}

.tc-card-hidden-fields {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e1e5e9;
  display: none;
}

.tc-card-expanded .tc-card-hidden-fields {
  display: block;
}

/* === Bulk Operations === */
.tc-bulk-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #e3f2fd;
  border-radius: 8px;
  border: 1px solid #bbdefb;
}

.tc-bulk-select-all {
  margin-right: auto;
}

.tc-bulk-actions {
  display: flex;
  gap: 8px;
}

.tc-bulk-action {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}

.tc-bulk-delete {
  background: #dc3545;
  color: white;
}

.tc-bulk-delete:hover {
  background: #c82333;
}

.tc-bulk-export {
  background: #28a745;
  color: white;
}

.tc-bulk-export:hover {
  background: #218838;
}

.tc-bulk-edit {
  background: #007bff;
  color: white;
}

.tc-bulk-edit:hover {
  background: #0056b3;
}

.tc-row-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* === Pagination === */
.tc-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding: 12px 0;
}

.tc-pagination-info {
  color: #6c757d;
  font-size: 14px;
}

.tc-pagination-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tc-prev-btn,
.tc-next-btn {
  padding: 8px 16px;
  border: 1px solid #007bff;
  background: white;
  color: #007bff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.tc-prev-btn:hover:not(:disabled),
.tc-next-btn:hover:not(:disabled) {
  background: #007bff;
  color: white;
}

.tc-prev-btn:disabled,
.tc-next-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tc-current-page {
  font-weight: 600;
  color: #212529;
}

/* === Enhanced Pagination for Large Datasets === */
.tc-pagination {
  flex-wrap: wrap;
  gap: 12px;
}

.tc-pagination-info[title] {
  cursor: help;
  position: relative;
}

.tc-pagination-info[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 0;
  background: #333;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
}

.tc-pagination-controls {
  gap: 8px;
}

/* Enhanced pagination buttons */
.tc-first-btn,
.tc-last-btn {
  padding: 8px 10px;
  border: 1px solid #007bff;
  background: white;
  color: #007bff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.2s;
  min-width: 36px;
  text-align: center;
}

.tc-first-btn:hover:not(:disabled),
.tc-last-btn:hover:not(:disabled) {
  background: #007bff;
  color: white;
}

.tc-first-btn:disabled,
.tc-last-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Page jump controls for large datasets */
.tc-page-jump {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 8px;
}

.tc-page-input {
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-align: center;
  font-size: 13px;
  width: 60px;
  font-family: inherit;
}

.tc-page-input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Page size controls for large datasets */
.tc-page-size-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #e9ecef;
}

.tc-page-size-label {
  font-size: 13px;
  color: #6c757d;
  margin: 0;
  white-space: nowrap;
}

.tc-page-size-select {
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  background: white;
  cursor: pointer;
  font-family: inherit;
}

.tc-page-size-select:focus {
  outline: none;
  border-color: #007bff;
}

/* === Export Controls === */
.tc-export-controls {
  margin-bottom: 16px;
}

.tc-export-csv {
  background: #28a745;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.tc-export-csv:hover {
  background: #218838;
}

/* === Advanced Export Dropdown === */
.tc-export-dropdown-wrapper {
  position: relative;
  display: inline-block;
  margin-right: 8px;
}

.tc-export-main-btn {
  background: #007bff;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.tc-export-main-btn:hover {
  background: #0056b3;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.tc-dropdown-arrow {
  font-size: 10px;
  transition: transform 0.2s;
}

.tc-export-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border: 1px solid #e1e5e9;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 280px;
  overflow: hidden;
  margin-top: 4px;
}

.tc-export-option {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border: none;
  background: white;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background-color 0.2s;
  border-bottom: 1px solid #f0f0f0;
}

.tc-export-option:last-child {
  border-bottom: none;
}

.tc-export-option:hover {
  background: #f8f9fa;
}

.tc-export-icon {
  font-size: 20px;
  margin-right: 12px;
  min-width: 24px;
}

.tc-export-details {
  flex: 1;
}

.tc-export-title {
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
}

.tc-export-desc {
  font-size: 12px;
  color: #666;
  line-height: 1.3;
}

/* === Add New Modal === */
.tc-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.tc-modal {
  background: white;
  border-radius: 8px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.tc-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e1e5e9;
}

.tc-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: #212529;
}

.tc-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6c757d;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: all 0.2s;
}

.tc-modal-close:hover {
  background: #f8f9fa;
  color: #495057;
}

.tc-modal-form {
  display: grid;
  gap: 16px;
}

.tc-form-field {
  display: flex;
  flex-direction: column;
}

.tc-form-label {
  font-weight: 600;
  margin-bottom: 4px;
  color: #495057;
}

.tc-form-input {
  padding: 8px 12px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.tc-form-input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.tc-form-error {
  color: #dc3545;
  font-size: 12px;
  margin-top: 4px;
}

.tc-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e1e5e9;
}

.tc-btn-cancel {
  padding: 8px 16px;
  border: 1px solid #6c757d;
  background: white;
  color: #6c757d;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.tc-btn-cancel:hover {
  background: #6c757d;
  color: white;
}

.tc-btn-save {
  padding: 8px 16px;
  border: none;
  background: #007bff;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.tc-btn-save:hover {
  background: #0056b3;
}

/* === Progress Indicators === */
.tc-progress-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.tc-progress {
  text-align: center;
}

.tc-spinner {
  border: 3px solid #f3f3f3;
  border-top: 3px solid #007bff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  animation: tc-spin 1s linear infinite;
  margin: 0 auto 12px;
}

@keyframes tc-spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.tc-progress-text {
  color: #495057;
  font-size: 14px;
}

/* === Enhanced Mobile-First Responsive Design === */

/* Large Mobile/Small Tablet (768px and below) */
@media (max-width: 768px) {
  .tc-wrapper {
    padding: 8px;
  }

  /* Enhanced Table Mobile Experience */
  .tc-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: #ccc transparent;
    /* Firefox */
  }

  /* Webkit scrollbar styling */
  .tc-table-container::-webkit-scrollbar {
    height: 8px;
  }

  .tc-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
  }

  .tc-table-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
  }

  .tc-table-container::-webkit-scrollbar-thumb:hover {
    background: #999;
  }

  /* Mobile-optimized table cells */
  .tc-table th,
  .tc-table td {
    padding: 10px 12px;
    min-width: 120px;
    /* Prevent excessive squishing */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Improved mobile table headers */
  .tc-table th {
    font-size: 14px;
    font-weight: 600;
    background-color: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 20;
  }

  /* Better mobile cell content */
  .tc-table td {
    font-size: 14px;
    line-height: 1.4;
  }

  /* Touch-friendly sortable headers */
  .tc-table th.tc-sortable {
    min-height: 44px;
    /* WCAG touch target minimum */
    padding: 12px;
    cursor: pointer;
    user-select: none;
  }

  /* Enhanced mobile cards */
  .tc-cards-container {
    display: grid;
    gap: 12px;
    padding: 0 4px;
  }

  .tc-card {
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .tc-card:active {
    transform: scale(0.98);
    /* Touch feedback */
  }

  .tc-card-field {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .tc-card-label {
    grid-row: 1;
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .tc-card-value {
    grid-row: 2;
    font-size: 15px;
    line-height: 1.4;
    word-break: break-word;
  }

  /* Mobile-optimized filters */
  .tc-filters-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .tc-filter-item {
    width: 100%;
  }

  .tc-filter-item input,
  .tc-filter-item select {
    width: 100%;
    min-height: 44px;
    /* Touch-friendly */
    font-size: 16px;
    /* Prevents zoom on iOS */
    padding: 12px;
  }

  /* Mobile pagination */
  .tc-pagination {
    flex-direction: column;
    gap: 12px;
    align-items: center;
  }

  .tc-pagination-controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .tc-pagination button {
    min-height: 44px;
    min-width: 44px;
    font-size: 14px;
  }

  /* Mobile bulk controls */
  .tc-bulk-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .tc-bulk-actions {
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  .tc-bulk-actions button {
    min-height: 44px;
    flex: 1 1 auto;
    min-width: 120px;
  }

  /* Mobile search */
  .tc-global-search input {
    width: 100%;
    font-size: 16px;
    /* Prevents zoom on iOS */
    min-height: 44px;
    padding: 12px 16px;
  }

  /* Mobile export controls */
  .tc-export-dropdown-wrapper {
    width: 100%;
  }

  .tc-export-main-btn {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .tc-export-dropdown {
    width: 100%;
    left: 0;
    right: 0;
  }

  .tc-export-option {
    min-height: 44px;
    padding: 12px 16px;
  }

  /* Modal improvements for mobile */
  .tc-modal {
    margin: 16px;
    width: calc(100% - 32px);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
  }

  .tc-modal-content {
    padding: 20px;
  }

  .tc-modal-close {
    min-height: 44px;
    min-width: 44px;
    font-size: 20px;
  }
}

/* Standard Mobile (480px and below) */
@media (max-width: 480px) {
  .tc-wrapper {
    font-size: 14px;
    padding: 4px;
  }

  /* Smaller mobile optimizations */
  .tc-card {
    padding: 12px;
    margin-bottom: 8px;
  }

  .tc-card-header {
    font-size: 16px;
    margin-bottom: 12px;
  }

  .tc-card-value {
    font-size: 14px;
  }

  /* Compact table for very small screens */
  .tc-table th,
  .tc-table td {
    padding: 8px 10px;
    font-size: 13px;
    min-width: 100px;
  }

  /* Smaller touch targets acceptable on small screens */
  .tc-pagination button {
    min-height: 40px;
    min-width: 40px;
    font-size: 13px;
  }

  .tc-filter-item input,
  .tc-filter-item select {
    min-height: 40px;
    font-size: 15px;
    /* Still prevents iOS zoom */
    padding: 10px;
  }

  /* Compact filter controls */
  .tc-daterange-container,
  .tc-numberrange-container {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .tc-daterange-container input,
  .tc-numberrange-container input {
    width: 100%;
    min-height: 40px;
  }

  /* Compact search on very small screens */
  .tc-global-search input {
    min-height: 40px;
    font-size: 15px;
    padding: 10px 14px;
  }

  /* More compact export on tiny screens */
  .tc-export-main-btn,
  .tc-export-option {
    min-height: 40px;
    font-size: 14px;
    padding: 10px 14px;
  }
}

/* Large Mobile/Phablet (up to 580px) - Enhanced coverage */
@media (max-width: 580px) {
  .tc-table-container {
    border-radius: 4px;
    /* Smaller border radius for mobile */
  }

  .tc-card {
    border-radius: 6px;
    /* Consistent smaller radius */
  }

  /* Improved card layout spacing */
  .tc-cards-container {
    gap: 10px;
    padding: 0 2px;
  }
}

/* Portrait Tablet (up to 900px) */
@media (max-width: 900px) and (min-width: 769px) {

  .tc-table th,
  .tc-table td {
    padding: 11px 14px;
    min-width: 110px;
  }

  .tc-card {
    padding: 14px;
  }

  .tc-filters-row {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
  }
}

/* Touch Device Optimizations (any touch-capable device) */
@media (pointer: coarse) {

  /* Enhance all interactive elements for touch */
  .tc-sortable,
  .tc-pagination button,
  .tc-card-expandable,
  .tc-filter-item input,
  .tc-filter-item select,
  .tc-export-main-btn,
  .tc-bulk-actions button {
    min-height: 44px;
  }

  /* Remove hover states on touch devices */
  .tc-table tr:hover {
    background-color: inherit;
  }

  .tc-card:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }

  /* Add touch-specific active states */
  .tc-sortable:active,
  .tc-pagination button:active,
  .tc-card-expandable:active {
    background-color: #e9ecef;
    transform: scale(0.98);
  }
}

/* === Utility Classes === */
.tc-hidden {
  display: none !important;
}

.tc-visible {
  display: block !important;
}

.tc-loading {
  pointer-events: none;
  opacity: 0.6;
}

.tc-selected {
  background-color: #e3f2fd !important;
}

.tc-highlighted {
  background-color: #fff3cd !important;
}

.tc-error {
  border-color: #dc3545 !important;
  background-color: #f8d7da !important;
}

.tc-success {
  border-color: #28a745 !important;
  background-color: #d4edda !important;
}

/* === Data Validation Styles === */
.tc-validation-error {
  border-color: #dc3545 !important;
  background-color: #f8d7da !important;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
}

.tc-validation-tooltip {
  background-color: #dc3545;
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  max-width: 250px;
  word-wrap: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 1000;
}

.tc-validation-tooltip::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 10px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid #dc3545;
}

/* Validation error state for form fields */
.tc-field-error {
  border-color: #dc3545;
  background-color: #fff5f5;
}

.tc-field-error:focus {
  border-color: #dc3545;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
  outline: none;
}

/* Validation success state */
.tc-field-valid {
  border-color: #28a745;
  background-color: #f8fff9;
}

.tc-field-valid:focus {
  border-color: #28a745;
  box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.25);
  outline: none;
}

/* Validation message styling */
.tc-validation-message {
  color: #dc3545;
  font-size: 12px;
  margin-top: 4px;
  display: block;
}

.tc-validation-message.tc-success {
  color: #28a745;
}

/* === Rich Cell Types Styles === */

/* Text and Textarea */
.tc-edit-textarea {
  width: 100%;
  min-width: 200px;
  min-height: 60px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
  font-size: inherit;
  resize: vertical;
}

.tc-edit-textarea:focus {
  border-color: #007bff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Number Input */
.tc-number-input {
  text-align: right;
}

/* Date and DateTime */
.tc-date-input,
.tc-datetime-input {
  min-width: 150px;
}

/* Select and Multiselect */
.tc-edit-select {
  min-width: 120px;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
}

/* Legacy multiselect container removed */

.tc-multiselect-option {
  display: block;
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
}

.tc-multiselect-option:hover {
  background-color: #f8f9fa;
}

.tc-multiselect-checkbox {
  margin-right: 8px;
}

/* Checkbox */
.tc-checkbox-container {
  display: flex;
  align-items: center;
  min-height: 36px;
}

.tc-checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 8px;
}

.tc-edit-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Radio */
.tc-radio-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 150px;
}

.tc-radio-option {
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 8px;
}

.tc-edit-radio {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* File Upload */
.tc-file-container {
  min-width: 200px;
}

.tc-edit-file {
  width: 100%;
  padding: 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
}

.tc-file-preview {
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
  padding: 4px;
  background-color: #f8f9fa;
  border-radius: 3px;
}

/* URL Input */
.tc-url-input {
  min-width: 200px;
}

/* Color Picker */
.tc-color-container {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 150px;
}

.tc-edit-color {
  width: 40px;
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
}

.tc-color-text {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: monospace;
  text-transform: uppercase;
}

/* Range Slider */
.tc-range-container {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 150px;
}

.tc-edit-range {
  flex: 1;
  min-width: 100px;
}

.tc-range-display {
  min-width: 40px;
  padding: 4px 8px;
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 12px;
  text-align: center;
}

/* Rich cell type focus states */
.tc-edit-select:focus,
.tc-edit-file:focus,
.tc-color-text:focus {
  border-color: #007bff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Rich cell type containers in edit mode */
.tc-checkbox-container,
.tc-radio-container,
.tc-file-container,
.tc-color-container,
.tc-range-container {
  position: relative;
  background-color: white;
  border-radius: 4px;
}

/* Animation for cell type transitions */
.tc-edit-input,
.tc-edit-textarea,
.tc-edit-select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* === Enhanced Form Integration Styles === */

/* Form field containers */
.tc-form-field {
  margin-bottom: 20px;
  position: relative;
}

.tc-form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.tc-required {
  color: #dc3545;
  font-weight: bold;
}

/* Form input base styles */
.tc-form-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e1e5e9;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.tc-form-input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.tc-form-input:hover:not(:focus) {
  border-color: #c6d0dd;
}

/* Textarea specific */
.tc-form-input.tc-textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

/* Select specific */
.tc-form-input.tc-select {
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><path fill="%23666" d="M6 8L2 4h8z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 40px;
  appearance: none;
  cursor: pointer;
}

/* Multiselect container */
.tc-multiselect-form-container {
  border: 2px solid #e1e5e9;
  border-radius: 6px;
  background-color: #fff;
  transition: border-color 0.2s ease;
}

.tc-multiselect-form-container:focus-within {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.tc-multiselect-checkboxes {
  max-height: 150px;
  overflow-y: auto;
  padding: 8px;
}

.tc-checkbox-item {
  display: flex;
  align-items: center;
  padding: 6px 0;
  gap: 8px;
}

.tc-checkbox-item input[type="checkbox"] {
  margin: 0;
  width: auto;
}

.tc-checkbox-item label {
  margin: 0;
  cursor: pointer;
  font-weight: normal;
  flex: 1;
}

/* Radio container */
.tc-radio-form-container {
  border: 2px solid #e1e5e9;
  border-radius: 6px;
  padding: 12px;
  background-color: #fff;
}

.tc-radio-item {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}

.tc-radio-item:last-child {
  margin-bottom: 0;
}

.tc-radio-item input[type="radio"] {
  margin: 0;
  width: auto;
}

.tc-radio-item label {
  margin: 0;
  cursor: pointer;
  font-weight: normal;
  flex: 1;
}

/* File input */
.tc-form-input.tc-file {
  padding: 8px 12px;
  cursor: pointer;
}

.tc-form-input.tc-file::-webkit-file-upload-button {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 4px 12px;
  margin-right: 12px;
  cursor: pointer;
  font-size: 13px;
}

/* Color input */
.tc-form-input.tc-color {
  width: 60px;
  height: 40px;
  padding: 2px;
  border-radius: 6px;
  cursor: pointer;
}

/* Range container */
.tc-range-form-container {
  padding: 8px 0;
}

.tc-form-input.tc-range {
  width: 100%;
  margin-bottom: 8px;
}

.tc-range-value {
  display: inline-block;
  padding: 4px 8px;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #495057;
  min-width: 40px;
  text-align: center;
}

/* Form error messages */
.tc-form-error {
  margin-top: 6px;
  padding: 6px 10px;
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  color: #721c24;
  font-size: 13px;
  line-height: 1.4;
}

/* Error state for form inputs */
.tc-form-input.tc-validation-error {
  border-color: #dc3545 !important;
  background-color: #f8d7da !important;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1) !important;
}

/* Enhanced form modal styles */
.tc-modal-form {
  max-height: 70vh;
  overflow-y: auto;
  padding: 0 4px;
}

.tc-modal-form::-webkit-scrollbar {
  width: 6px;
}

.tc-modal-form::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.tc-modal-form::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.tc-modal-form::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Enhanced form modal actions */
.tc-modal-actions {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e1e5e9;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.tc-btn-save,
.tc-btn-cancel {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 80px;
}

.tc-btn-save {
  background-color: #007bff;
  color: white;
}

.tc-btn-save:hover {
  background-color: #0056b3;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.tc-btn-save:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.tc-btn-cancel {
  background-color: #6c757d;
  color: white;
}

.tc-btn-cancel:hover {
  background-color: #545b62;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
}

.tc-btn-cancel:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(108, 117, 125, 0.3);
}

/* Mobile responsiveness for rich cell types and forms */
@media (max-width: 768px) {
  /* Legacy mobile override removed */

  .tc-radio-container {
    flex-direction: column;
  }

  .tc-color-container {
    flex-direction: column;
    align-items: stretch;
  }

  .tc-range-container {
    flex-direction: column;
    gap: 8px;
  }

  .tc-modal-form {
    max-height: 60vh;
  }

  .tc-modal-actions {
    flex-direction: column;
  }

  .tc-btn-save,
  .tc-btn-cancel {
    width: 100%;
  }

  .tc-multiselect-checkboxes {
    max-height: 120px;
  }

  .tc-range-form-container {
    padding: 12px 0;
  }
}

@media (max-width: 480px) {
  .tc-form-field {
    margin-bottom: 16px;
  }

  .tc-form-input {
    padding: 8px 10px;
    font-size: 13px;
  }

  .tc-form-label {
    font-size: 13px;
  }
}

/* === WordPress Admin Page Styles === */
.tc-admin-layout {
  display: flex !important;
  gap: 20px !important;
  margin-top: 20px !important;
  align-items: flex-start !important;
}

.tc-sidebar {
  flex: 0 0 380px !important;
}

.tc-sidebar .card {
  margin: 0 0 20px 0 !important;
  max-width: none !important;
  padding: 20px !important;
}

.tc-sidebar .card h2 {
  margin-top: 0 !important;
  margin-bottom: 15px !important;
  color: #23282d !important;
  font-size: 16px !important;
  font-weight: 600 !important;
}

.tc-sidebar .card p {
  margin: 0 0 15px 0 !important;
  line-height: 1.5 !important;
}

.tc-sidebar .card label {
  font-weight: 600 !important;
  display: block !important;
  margin-bottom: 5px !important;
  color: #23282d !important;
}

.tc-sidebar .card input.widefat,
.tc-sidebar .card textarea.widefat {
  margin-bottom: 8px !important;
  padding: 8px 12px !important;
  border: 1px solid #ddd !important;
  border-radius: 4px !important;
}

.tc-sidebar .card .description {
  margin-top: 5px !important;
  margin-bottom: 15px !important;
  font-size: 13px !important;
  color: #666 !important;
}

.tc-sidebar .card .button {
  margin: 0 5px 0 0 !important;
  padding: 8px 16px !important;
}

.tc-sidebar .card .button-primary {
  background: #0073aa !important;
  border-color: #0073aa !important;
}

.tc-sidebar .card .button-secondary {
  background: #f1f1f1 !important;
  border-color: #ddd !important;
  color: #555 !important;
}

.tc-preview-area {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  max-width: none !important;
  width: 100% !important;
}

.tc-preview-area .card {
  margin: 0 !important;
  max-width: none !important;
  width: 100% !important;
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 20px !important;
  box-sizing: border-box !important;
}

.tc-preview-area .card h2 {
  border-bottom: 1px solid #f0f0f1 !important;
  padding-bottom: 15px !important;
  margin-bottom: 15px !important;
  margin-top: 0 !important;
  color: #23282d !important;
  font-size: 16px !important;
  font-weight: 600 !important;
}

#tc-preview-wrap {
  flex: 1 1 auto !important;
  overflow: visible !important;
  background: #fff !important;
  padding: 15px !important;
  border: 1px solid #ddd !important;
  border-radius: 4px !important;
  height: auto !important;
  max-height: none !important;
}

#tc-preview-container {
  min-height: 400px !important;
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #666 !important;
}

/* When table is loaded, change alignment */
#tc-preview-container:has(.tablecrafter-container) {
  align-items: stretch !important;
  justify-content: stretch !important;
}

/* Fallback for browsers that don't support :has() */
#tc-preview-container.tc-has-table {
  align-items: stretch !important;
  justify-content: stretch !important;
}

/* TableCrafter instance inside admin preview */
#tc-preview-container .tablecrafter-container {
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
}

#tc-preview-container .tc-wrapper {
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
}

#tc-preview-container .tc-table-container {
  flex: 1 1 auto !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

#tc-preview-container .tc-table {
  width: 100% !important;
  height: 100% !important;
}

/* Preview area table optimization */
.tc-preview-area .tc-table th,
.tc-preview-area .tc-table td {
  min-width: 100px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 200px !important;
}

.tc-preview-area .tc-table td {
  white-space: normal !important;
  word-wrap: break-word !important;
  line-height: 1.4 !important;
}

.tc-demo-links {
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}

.tc-demo-links li {
  margin-bottom: 8px !important;
}

.tc-demo-links .button {
  width: 100% !important;
  text-align: left !important;
  background: white !important;
  border: 2px solid #0073aa !important;
  color: #0073aa !important;
  font-weight: 600 !important;
  transition: all 0.2s ease !important;
  padding: 10px 15px !important;
}

.tc-demo-links .button:hover {
  background: #0073aa !important;
  color: white !important;
  border-color: #0073aa !important;
}

/* Admin form field containers */
.tc-admin-layout .card .form-field {
  margin-bottom: 15px !important;
}

.tc-admin-layout .card .form-row {
  display: flex !important;
  gap: 20px !important;
  margin-bottom: 15px !important;
}

.tc-admin-layout .card .form-row>div {
  flex: 1 !important;
}

.tc-admin-layout .card .checkbox-group {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 15px !important;
  margin-bottom: 15px !important;
}

.tc-admin-layout .card .checkbox-group label {
  font-weight: 600 !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  cursor: pointer !important;
  margin-bottom: 0 !important;
}

.tc-admin-layout .card .button-group {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
  margin-top: 15px !important;
}

.tc-admin-layout .card .button-group .button {
  flex: 1 1 auto !important;
  min-width: 180px !important;
  margin: 0 !important;
}

/* Shortcode display */
#tc-shortcode-display {
  display: block !important;
  padding: 15px !important;
  background: #f1f1f1 !important;
  margin: 15px 0 !important;
  word-break: break-all !important;
  border: 1px solid #ddd !important;
  border-radius: 4px !important;
  font-family: Consolas, Monaco, monospace !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
}

/* Two-column layout for screens above 800px */
@media (min-width: 801px) {
  body.wp-admin .tc-admin-layout {
    display: flex !important;
    flex-direction: row !important;
    gap: 20px !important;
    margin-top: 20px !important;
    align-items: flex-start !important;
  }

  body.wp-admin .tc-sidebar {
    flex: 0 0 300px !important;
    min-width: 300px !important;
    max-width: 300px !important;
    width: 300px !important;
  }

  /* Button responsiveness in constrained sidebar */
  body.wp-admin .tc-sidebar .button-group .button {
    min-width: 140px !important;
    flex: 1 1 calc(50% - 5px) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Always stack buttons in 300px sidebar to prevent text truncation */
  body.wp-admin .tc-sidebar .button-group {
    flex-direction: column !important;
  }

  body.wp-admin .tc-sidebar .button-group .button {
    width: 100% !important;
    flex: none !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
  }

  body.wp-admin .tc-preview-area {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: none !important;
    width: auto !important;
  }

  body.wp-admin .tc-preview-area .card {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
  }
}

/* Responsive admin layout */
@media (max-width: 800px) {
  .tc-admin-layout {
    flex-direction: column !important;
  }

  .tc-sidebar {
    flex: none !important;
    max-width: none !important;
    width: 100% !important;
  }

  .tc-preview-area {
    min-width: auto !important;
    width: 100% !important;
  }

  .tc-preview-area .card {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
  }
}

@media (max-width: 768px) {
  .tc-admin-layout {
    gap: 15px !important;
  }

  .tc-preview-area .card {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
  }

  .tc-sidebar .card .form-row {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .tc-sidebar .card .checkbox-group {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .tc-sidebar .card .button-group {
    flex-direction: column !important;
  }

  .tc-sidebar .card .button-group .button {
    width: 100% !important;
  }
}

/* === Rich Data Presentation === */
.tc-badge {
  display: inline-block;
  padding: 0.25em 0.4em;
  font-size: 75%;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.25rem;
}

.tc-badge-success {
  color: #fff;
  background-color: #28a745;
}

.tc-badge-error {
  color: #fff;
  background-color: #dc3545;
}

.tc-link {
  color: #007bff;
  text-decoration: none;
}

.tc-link:hover {
  text-decoration: underline;
}

.tc-cell-image {
  max-height: 50px;
  border-radius: 4px;
  transition: transform 0.2s;
  cursor: zoom-in;
}

.tc-cell-image:hover {
  transform: scale(2.5);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 100;
  position: relative;
}

/* Skeleton Loading */
@keyframes tc-shimmer {
  0% {
    background-position: -1000px 0;
  }

  100% {
    background-position: 1000px 0;
  }
}

.tc-skeleton {
  animation: tc-shimmer 2s linear infinite;
  background: linear-gradient(to right, #e5e7eb 8%, #d1d5db 18%, #e5e7eb 33%);
  background-size: 1000px 100%;
}

.tc-skeleton-row {
  display: flex;
  padding: 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.tc-skeleton-cell {
  height: 20px;
  background: #f3f4f6;
  border-radius: 4px;
  margin-right: 1rem;
  flex: 1;
}

/* Dark mode support for skeleton */
@media (prefers-color-scheme: dark) {
  .tc-skeleton {
    background: linear-gradient(to right, #374151 8%, #4b5563 18%, #374151 33%);
  }

  .tc-skeleton-cell {
    background: #374151;
  }

  .tc-skeleton-row {
    border-color: #374151;
  }
}

/* === ACCESSIBILITY STYLES === */
/* WCAG 2.1 Compliant Accessibility Enhancements */

/* Screen reader only content */
.tc-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Focus indicators - WCAG 2.1 AA compliant */
.tc-wrapper *:focus,
.tc-wrapper .tc-focused {
  outline: 3px solid #005fcc !important;
  outline-offset: 2px !important;
  position: relative !important;
  z-index: 1 !important;
}

/* Enhanced focus for specific elements */
.tc-table th.tc-sortable:focus,
.tc-table th.tc-sortable.tc-focused {
  background-color: #e3f2fd !important;
  outline-color: #1976d2 !important;
}

.tc-table td.tc-editable:focus,
.tc-table td.tc-editable.tc-focused {
  background-color: #fff3e0 !important;
  outline-color: #ff9800 !important;
}

.tc-global-search:focus {
  border-color: #1976d2 !important;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.2) !important;
}

/* Pagination button focus */
.tc-pagination button:focus {
  background-color: #e3f2fd !important;
  border-color: #1976d2 !important;
}

/* High contrast mode support */
.tc-wrapper.tc-high-contrast {
  --tc-border-color: #000000;
  --tc-text-color: #000000;
  --tc-bg-color: #ffffff;
  --tc-focus-color: #ff0000;
}

.tc-high-contrast .tc-table {
  border: 2px solid var(--tc-border-color) !important;
}

.tc-high-contrast .tc-table th,
.tc-high-contrast .tc-table td {
  border: 1px solid var(--tc-border-color) !important;
  color: var(--tc-text-color) !important;
  background-color: var(--tc-bg-color) !important;
}

.tc-high-contrast *:focus,
.tc-high-contrast .tc-focused {
  outline: 3px solid var(--tc-focus-color) !important;
  background-color: yellow !important;
  color: black !important;
}

/* Reduced motion support */
.tc-wrapper.tc-reduced-motion,
.tc-wrapper.tc-reduced-motion * {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* Validation error styles */
.tc-validation-error {
  border: 2px solid #d32f2f !important;
  background-color: #ffebee !important;
  position: relative !important;
}

.tc-validation-tooltip {
  position: absolute !important;
  background: #d32f2f !important;
  color: white !important;
  padding: 4px 8px !important;
  border-radius: 4px !important;
  font-size: 12px !important;
  z-index: 1000 !important;
  max-width: 200px !important;
  word-wrap: break-word !important;
}

.tc-validation-tooltip::before {
  content: '' !important;
  position: absolute !important;
  top: -4px !important;
  left: 8px !important;
  border-left: 4px solid transparent !important;
  border-right: 4px solid transparent !important;
  border-bottom: 4px solid #d32f2f !important;
}

/* Keyboard navigation helpers */
.tc-table th[tabindex]:not([tabindex="-1"])::after {
  content: " (Press Enter to sort)" !important;
  font-size: 11px !important;
  font-weight: normal !important;
  opacity: 0 !important;
  transition: opacity 0.2s !important;
}

.tc-table th[tabindex]:focus::after,
.tc-table th[tabindex]:hover::after {
  opacity: 0.7 !important;
}

.tc-table td.tc-editable[tabindex]:not([tabindex="-1"])::after {
  content: " (Press Enter to edit)" !important;
  font-size: 11px !important;
  opacity: 0 !important;
  transition: opacity 0.2s !important;
}

.tc-table td.tc-editable:focus::after,
.tc-table td.tc-editable:hover::after {
  opacity: 0.7 !important;
}

/* Loading state accessibility */
.tc-loading[aria-busy="true"] {
  position: relative !important;
}

.tc-loading[aria-busy="true"]::before {
  content: "Loading data..." !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  background: rgba(255, 255, 255, 0.9) !important;
  padding: 10px !important;
  border-radius: 4px !important;
  z-index: 10 !important;
}

/* Text scaling support up to 200% */
@media screen and (min-width: 1280px) {
  .tc-wrapper {
    min-width: 0 !important;
    word-wrap: break-word !important;
  }

  .tc-table th,
  .tc-table td {
    word-wrap: break-word !important;
    max-width: 0 !important;
    overflow: visible !important;
  }
}

/* Color contrast improvements */
.tc-sortable {
  color: #1565c0 !important;
}

.tc-sortable:hover,
.tc-sortable:focus {
  color: #0d47a1 !important;
  background-color: #e3f2fd !important;
}

.tc-editable {
  color: #e65100 !important;
}

.tc-editable:hover,
.tc-editable:focus {
  color: #bf360c !important;
  background-color: #fff3e0 !important;
}

/* Pagination accessibility improvements */
.tc-pagination [aria-current="page"] {
  background-color: #1976d2 !important;
  color: white !important;
  font-weight: bold !important;
}

.tc-pagination button:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

/* Error state styling */
.tc-error-container {
  background-color: #ffebee !important;
  border: 2px solid #d32f2f !important;
  color: #d32f2f !important;
  padding: 16px !important;
  border-radius: 4px !important;
  margin: 16px 0 !important;
}

.tc-error-message {
  font-weight: 600 !important;
  margin-bottom: 8px !important;
}

/* Search accessibility improvements */
.tc-global-search-container {
  position: relative !important;
}

.tc-global-search[role="searchbox"] {
  border: 2px solid #ddd !important;
}

.tc-global-search[role="searchbox"]:focus {
  border-color: #1976d2 !important;
}

/* Mobile accessibility improvements */
@media screen and (max-width: 768px) {

  /* Ensure touch targets are at least 44x44px */
  .tc-table th.tc-sortable,
  .tc-table td.tc-editable,
  .tc-pagination button,
  .tc-global-search {
    min-height: 44px !important;
    min-width: 44px !important;
  }

  /* Improve text readability on small screens */
  .tc-table th,
  .tc-table td {
    font-size: 14px !important;
    line-height: 1.4 !important;
  }

  /* Focus indicators need to be more prominent on touch devices */
  .tc-wrapper *:focus,
  .tc-wrapper .tc-focused {
    outline-width: 4px !important;
    outline-offset: 3px !important;
  }
}

/* Print accessibility */
@media print {
  .tc-wrapper {
    color: black !important;
    background: white !important;
  }

  .tc-table th,
  .tc-table td {
    border: 1px solid black !important;
    background: white !important;
    color: black !important;
  }

  /* Hide interactive elements in print */
  .tc-pagination,
  .tc-global-search-container,
  .tc-filters,
  .tc-bulk-controls,
  .tc-export-controls {
    display: none !important;
  }
}

/* === Admin Preview Enhancements === */
/* Prevent table column squishing in admin preview */
.tc-preview-area .tc-table {
  min-width: 600px;
  /* Ensure minimum table width */
  table-layout: auto;
  /* Allow columns to size naturally */
}

.tc-preview-area .tc-table th,
.tc-preview-area .tc-table td {
  min-width: 100px;
  /* Minimum column width */
  white-space: nowrap;
  /* Prevent text wrapping for headers */
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  /* Maximum width to prevent extremely wide columns */
}

/* Allow text wrapping for data cells to show more content */
.tc-preview-area .tc-table td {
  white-space: normal;
  word-wrap: break-word;
  line-height: 1.4;
}

/* Specific styling for common column types */
.tc-preview-area .tc-table th:first-child,
.tc-preview-area .tc-table td:first-child {
  min-width: 120px;
  /* Usually names, need more space */
}

/* Email and URL columns */
.tc-preview-area .tc-table td[data-type="email"],
.tc-preview-area .tc-table td[data-type="url"] {
  min-width: 150px;
  max-width: 250px;
}

/* Numeric columns can be narrower */
.tc-preview-area .tc-table td[data-type="number"],
.tc-preview-area .tc-table td[data-type="numeric"] {
  min-width: 80px;
  text-align: right;
}

/* Enhanced admin preview container */
.tc-preview-area .tc-table-container {
  border: 1px solid #c3c4c7;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  background: #fff;
  overflow-x: auto;
  max-height: none;
  /* Remove height restrictions */
}

/* Better spacing for admin preview */
.tc-preview-area .tc-wrapper {
  margin: 0;
  padding: 0;
}

/* Ensure table is responsive within the admin preview area */
@media (max-width: 1400px) {
  .tc-admin-layout {
    flex-direction: column;
  }

  .tc-sidebar {
    flex: none !important;
    max-width: none !important;
    width: 100% !important;
  }

  .tc-preview-area {
    min-width: auto !important;
  }
}

/* Mobile admin improvements */
@media (max-width: 768px) {
  .tc-admin-layout {
    gap: 15px;
  }

  .tc-preview-area .tc-table th,
  .tc-preview-area .tc-table td {
    min-width: 80px;
    padding: 8px 12px;
    font-size: 13px;
  }
}