/*
 * DDT Table CSS v1.0.0
 * Professional table styling and variations
 */

/* ========================================
   BASE TABLE STYLES
   ======================================== */

.ddt-table {
  width: 100%;
  margin-bottom: 1rem;
  color: #212529;
  background-color: transparent;
  border-collapse: collapse;
}

.ddt-table th,
.ddt-table td {
  padding: 0.75rem;
  vertical-align: top;
  border-top: 1px solid #dee2e6;
}

.ddt-table thead th {
  vertical-align: bottom;
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  background-color: #f8f9fa;
}

.ddt-table tbody + tbody {
  border-top: 2px solid #dee2e6;
}

.ddt-table caption {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  color: #6c757d;
  text-align: left;
  caption-side: top;
  font-size: 0.875rem;
}

/* ========================================
   TABLE SIZES
   ======================================== */

.ddt-table-sm th,
.ddt-table-sm td {
  padding: 0.3rem;
  font-size: 0.875rem;
}

.ddt-table-lg th,
.ddt-table-lg td {
  padding: 1rem;
  font-size: 1.125rem;
}

/* ========================================
   TABLE BORDERED
   ======================================== */

.ddt-table-bordered {
  border: 1px solid #dee2e6;
}

.ddt-table-bordered th,
.ddt-table-bordered td {
  border: 1px solid #dee2e6;
}

.ddt-table-bordered thead th,
.ddt-table-bordered thead td {
  border-bottom-width: 2px;
}

/* ========================================
   TABLE BORDERLESS
   ======================================== */

.ddt-table-borderless th,
.ddt-table-borderless td,
.ddt-table-borderless thead th,
.ddt-table-borderless tbody + tbody {
  border: 0;
}

/* ========================================
   TABLE STRIPED
   ======================================== */

.ddt-table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.02);
}

.ddt-table-striped-columns tbody tr td:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.02);
}

/* ========================================
   TABLE HOVER
   ======================================== */

.ddt-table-hover tbody tr {
  transition: background-color 0.15s ease-in-out;
}

.ddt-table-hover tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.075);
  cursor: pointer;
}

/* ========================================
   TABLE COLORS (ROW COLORS)
   ======================================== */

.ddt-table-primary {
  background-color: rgba(0, 123, 255, 0.1);
}

.ddt-table-secondary {
  background-color: rgba(108, 117, 125, 0.1);
}

.ddt-table-success {
  background-color: rgba(40, 167, 69, 0.1);
}

.ddt-table-danger {
  background-color: rgba(220, 53, 69, 0.1);
}

.ddt-table-warning {
  background-color: rgba(255, 193, 7, 0.1);
}

.ddt-table-info {
  background-color: rgba(23, 162, 184, 0.1);
}

.ddt-table-light {
  background-color: #f8f9fa;
}

.ddt-table-dark {
  background-color: #343a40;
  color: #fff;
}

/* Row specific colors */
tbody .ddt-table-primary {
  background-color: #cce5ff;
}

tbody .ddt-table-secondary {
  background-color: #e2e3e5;
}

tbody .ddt-table-success {
  background-color: #d4edda;
}

tbody .ddt-table-danger {
  background-color: #f8d7da;
}

tbody .ddt-table-warning {
  background-color: #fff3cd;
}

tbody .ddt-table-info {
  background-color: #d1ecf1;
}

tbody .ddt-table-light {
  background-color: #fdfdfe;
}

tbody .ddt-table-dark {
  background-color: #c6c8ca;
  color: #212529;
}

/* ========================================
   TABLE DARK THEME
   ======================================== */

.ddt-table-dark-theme {
  color: #fff;
  background-color: #343a40;
}

.ddt-table-dark-theme th,
.ddt-table-dark-theme td,
.ddt-table-dark-theme thead th {
  border-color: #454d55;
}

.ddt-table-dark-theme thead th {
  background-color: #23272b;
}

.ddt-table-dark-theme.ddt-table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(255, 255, 255, 0.05);
}

.ddt-table-dark-theme.ddt-table-hover tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.075);
}

/* ========================================
   RESPONSIVE TABLE
   ======================================== */

.ddt-table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ddt-table-responsive > .ddt-table {
  margin-bottom: 0;
}

/* Responsive breakpoints */
@media (max-width: 575.98px) {
  .ddt-table-responsive-sm {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 767.98px) {
  .ddt-table-responsive-md {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 991.98px) {
  .ddt-table-responsive-lg {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 1199.98px) {
  .ddt-table-responsive-xl {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ========================================
   TABLE FIXED LAYOUT
   ======================================== */

.ddt-table-fixed {
  table-layout: fixed;
}

.ddt-table-fixed th,
.ddt-table-fixed td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========================================
   STICKY HEADER
   ======================================== */

.ddt-table-sticky-header {
  position: relative;
}

.ddt-table-sticky-header thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #f8f9fa;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ddt-table-dark-theme.ddt-table-sticky-header thead th {
  background-color: #23272b;
}

/* ========================================
   SORTABLE TABLE
   ======================================== */

.ddt-table-sortable th {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 2rem;
}

.ddt-table-sortable th::after {
  content: "⇅";
  position: absolute;
  right: 0.75rem;
  opacity: 0.3;
  font-size: 0.875rem;
}

.ddt-table-sortable th:hover::after {
  opacity: 0.6;
}

.ddt-table-sortable th.ddt-sort-asc::after {
  content: "↑";
  opacity: 1;
}

.ddt-table-sortable th.ddt-sort-desc::after {
  content: "↓";
  opacity: 1;
}

.ddt-table-sortable th.ddt-sort-active {
  background-color: rgba(0, 123, 255, 0.1);
}

/* ========================================
   TABLE WITH ACTIONS
   ======================================== */

.ddt-table-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.ddt-table-action-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  border: none;
  background: none;
  cursor: pointer;
  color: #007bff;
  transition: color 0.15s ease-in-out;
}

.ddt-table-action-btn:hover {
  color: #0056b3;
  text-decoration: underline;
}

.ddt-table-action-btn-danger {
  color: #dc3545;
}

.ddt-table-action-btn-danger:hover {
  color: #bd2130;
}

/* ========================================
   TABLE WITH CHECKBOXES
   ======================================== */

.ddt-table-checkbox {
  width: 40px;
  text-align: center;
}

.ddt-table-checkbox input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

/* ========================================
   TABLE COLUMN WIDTHS
   ======================================== */

.ddt-table-col-xs {
  width: 5%;
}

.ddt-table-col-sm {
  width: 10%;
}

.ddt-table-col-md {
  width: 20%;
}

.ddt-table-col-lg {
  width: 30%;
}

.ddt-table-col-xl {
  width: 40%;
}

/* Fixed widths */
.ddt-table-col-50 {
  width: 50px;
}

.ddt-table-col-100 {
  width: 100px;
}

.ddt-table-col-150 {
  width: 150px;
}

.ddt-table-col-200 {
  width: 200px;
}

/* ========================================
   TABLE TEXT ALIGNMENT
   ======================================== */

.ddt-table-align-left {
  text-align: left;
}

.ddt-table-align-center {
  text-align: center;
}

.ddt-table-align-right {
  text-align: right;
}

.ddt-table th.ddt-table-align-center,
.ddt-table td.ddt-table-align-center {
  text-align: center;
}

.ddt-table th.ddt-table-align-right,
.ddt-table td.ddt-table-align-right {
  text-align: right;
}

/* ========================================
   TABLE VERTICAL ALIGNMENT
   ======================================== */

.ddt-table-valign-top th,
.ddt-table-valign-top td {
  vertical-align: top;
}

.ddt-table-valign-middle th,
.ddt-table-valign-middle td {
  vertical-align: middle;
}

.ddt-table-valign-bottom th,
.ddt-table-valign-bottom td {
  vertical-align: bottom;
}

/* ========================================
   TABLE PAGINATION
   ======================================== */

.ddt-table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-top: 1px solid #dee2e6;
  margin-top: 1rem;
}

.ddt-table-info {
  color: #6c757d;
  font-size: 0.875rem;
}

.ddt-table-pagination {
  display: flex;
  gap: 0.25rem;
}

/* ========================================
   TABLE WITH IMAGES
   ======================================== */

.ddt-table-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.ddt-table-img-square {
  border-radius: 0.375rem;
}

/* ========================================
   TABLE BADGES
   ======================================== */

.ddt-table td .ddt-badge {
  font-size: 0.75rem;
  padding: 0.25em 0.5em;
}

/* ========================================
   TABLE EMPTY STATE
   ======================================== */

.ddt-table-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #6c757d;
}

.ddt-table-empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.ddt-table-empty-text {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
}

.ddt-table-empty-subtext {
  font-size: 0.875rem;
  color: #adb5bd;
}

/* ========================================
   TABLE LOADING STATE
   ======================================== */

.ddt-table-loading {
  position: relative;
  pointer-events: none;
}

.ddt-table-loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.ddt-table-loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 11;
}

/* ========================================
   TABLE CARD VIEW (Mobile Alternative)
   ======================================== */

@media (max-width: 767.98px) {
  .ddt-table-card-mobile {
    display: none;
  }

  .ddt-table-card-mobile + .ddt-table-card-list {
    display: block;
  }

  .ddt-table-card-item {
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }

  .ddt-table-card-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
  }

  .ddt-table-card-row:last-child {
    border-bottom: none;
  }

  .ddt-table-card-label {
    font-weight: 600;
    color: #6c757d;
    font-size: 0.875rem;
  }

  .ddt-table-card-value {
    text-align: right;
  }
}

@media (min-width: 768px) {
  .ddt-table-card-list {
    display: none;
  }
}

/* ========================================
   TABLE FILTERS
   ======================================== */

.ddt-table-filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.ddt-table-search {
  flex: 1;
  min-width: 200px;
}

.ddt-table-filter-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ========================================
   TABLE ROW SELECTION
   ======================================== */

.ddt-table tbody tr.ddt-selected {
  background-color: rgba(0, 123, 255, 0.1);
}

.ddt-table-hover tbody tr.ddt-selected:hover {
  background-color: rgba(0, 123, 255, 0.15);
}

/* ========================================
   TABLE EXPANDABLE ROWS
   ======================================== */

.ddt-table-expandable tbody tr {
  cursor: pointer;
}

.ddt-table-expand-icon {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-right: 0.5rem;
  transition: transform 0.2s ease;
}

.ddt-table-expand-icon::before {
  content: "▶";
}

tr.ddt-expanded .ddt-table-expand-icon {
  transform: rotate(90deg);
}

.ddt-table-expanded-content {
  display: none;
  background-color: #f8f9fa;
  padding: 1rem;
}

tr.ddt-expanded + tr .ddt-table-expanded-content {
  display: block;
}

/* ========================================
   TABLE SUMMARY/TOTALS ROW
   ======================================== */

.ddt-table tfoot {
  font-weight: 600;
  background-color: #f8f9fa;
  border-top: 2px solid #dee2e6;
}

.ddt-table tfoot td {
  border-top: 2px solid #dee2e6;
}

/* ========================================
   DATA TABLE WRAPPER
   ======================================== */

.ddt-datatable-wrapper {
  position: relative;
  background-color: #fff;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ddt-datatable-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid #dee2e6;
  background-color: #f8f9fa;
}

.ddt-datatable-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.ddt-datatable-body {
  overflow-x: auto;
}

/* ========================================
   COMPACT TABLE
   ======================================== */

.ddt-table-compact {
  font-size: 0.875rem;
}

.ddt-table-compact th,
.ddt-table-compact td {
  padding: 0.4rem 0.5rem;
}

/* ========================================
   TABLE WITH ICONS
   ======================================== */

.ddt-table-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #f0f0f0;
  margin-right: 0.5rem;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .ddt-table {
    border-collapse: collapse !important;
  }

  .ddt-table td,
  .ddt-table th {
    background-color: #fff !important;
  }

  .ddt-table-actions,
  .ddt-table-checkbox,
  .ddt-table-filters,
  .ddt-table-pagination {
    display: none !important;
  }
}