/* ===== AFR DATATABLE — Clean Modern Design ===== */

/* Base container — NO overflow:hidden so dropdowns aren't clipped */
.afr-datatable {
  background: var(--afr-card, #fff);
  border: 1px solid var(--afr-border, #e5e7eb);
  border-radius: 12px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* ===== TOOLBAR ===== */
.adt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  flex-wrap: wrap;
}

.adt-search {
  position: relative;
  flex: 1;
  max-width: 340px;
  min-width: 160px;
}

.adt-search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--afr-border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--afr-card);
  color: var(--afr-fg);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.adt-search input:focus {
  border-color: hsl(211, 80%, 62%);
  box-shadow: 0 0 0 3px hsl(211 98% 54% / .08);
}

.adt-search input::placeholder {
  color: var(--afr-muted-fg);
  opacity: .7;
}

.adt-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--afr-muted-fg);
  pointer-events: none;
  opacity: .6;
}

.adt-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== BUTTONS ===== */
.adt-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--afr-border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--afr-fg);
  background: var(--afr-card);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}

.adt-btn:hover {
  background: hsl(210, 15%, 96%);
  border-color: hsl(214, 20%, 85%);
}

.adt-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: .65;
}

/* ===== DROPDOWNS ===== */
.adt-dropdown {
  position: relative;
  display: inline-block;
}

.adt-dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--afr-card);
  border: 1px solid var(--afr-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .10), 0 2px 8px rgba(0, 0, 0, .05);
  z-index: 1000;
  padding: 4px;
  display: none;
  animation: adtFadeIn .12s ease;
}

.adt-dropdown-panel.adt-open {
  display: block;
}

@keyframes adtFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.adt-dropdown-panel .adt-dd-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--afr-muted-fg);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 8px 10px 6px;
}

/* ===== COLUMN VISIBILITY ===== */
.adt-col-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
  font-size: 13px;
  color: var(--afr-fg);
}

.adt-col-item:hover {
  background: hsl(210, 15%, 96%);
}

.adt-col-item .adt-col-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.adt-col-item .adt-col-label .adt-grip {
  color: var(--afr-muted-fg);
  opacity: .35;
}

/* Toggle switch */
.adt-toggle {
  position: relative;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
}

.adt-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.adt-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: hsl(210, 15%, 88%);
  transition: background .2s;
  cursor: pointer;
}

.adt-toggle input:checked+.adt-toggle-track {
  background: hsl(211, 98%, 54%);
}

.adt-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  transition: transform .2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}

.adt-toggle input:checked+.adt-toggle-track::after {
  transform: translateX(16px);
}

/* ===== EXPORT ITEMS ===== */
.adt-export-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
  font-size: 13px;
  color: var(--afr-fg);
}

.adt-export-item:hover {
  background: hsl(210, 15%, 96%);
}

.adt-export-item svg {
  width: 15px;
  height: 15px;
  color: var(--afr-muted-fg);
  opacity: .6;
}

/* ===== PER PAGE ===== */
.adt-perpage-panel {
  min-width: 70px;
}

.adt-perpage-item {
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  text-align: center;
  color: var(--afr-fg);
  transition: background .12s;
}

.adt-perpage-item:hover {
  background: hsl(210, 15%, 96%);
}

.adt-perpage-item.adt-active {
  background: hsl(211, 98%, 54% / .08);
  font-weight: 600;
  color: hsl(211, 98%, 48%);
}

/* ===== TABLE ===== */
.adt-table-wrap {
  overflow: hidden;
  border-top: 1px solid var(--afr-border);
  position: relative;
  min-height: 80px;
  overflow-x: auto;
}

/* Only allow horizontal scroll on small screens */
@media (max-width: 768px) {
  .adt-table-wrap {
    overflow-x: auto;
    overflow-y: visible;
  }
}

.adt-table {
  width: 100%;
  border-collapse: collapse;
}

.adt-table thead {
  background: hsl(210, 20%, 98%);
}

.adt-table th {
  padding: 14px 20px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--afr-muted-fg);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color .15s;
  background: transparent;
  border-bottom: 1px solid var(--afr-border);
}

.adt-table th:hover {
  color: var(--afr-fg);
}

.adt-table th .adt-sort-icon {
  display: inline-block;
  margin-left: 3px;
  opacity: .35;
  font-size: 12px;
  transition: opacity .15s;
}

.adt-table th.adt-sorted .adt-sort-icon {
  opacity: 1;
  color: hsl(211, 98%, 54%);
}

.adt-table td {
  padding: 16px 20px;
  font-size: 13.5px;
  color: var(--afr-fg);
  border-bottom: 1px solid hsl(214 20% 95%);
  white-space: nowrap;
}

.adt-table tbody tr {
  transition: background .1s;
}

.adt-table tbody tr:hover {
  background: hsl(210, 20%, 98.5%);
}

.adt-table tbody tr:last-child td {
  border-bottom: none;
}

/* ===== STATUS BADGES ===== */
.adt-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .01em;
}

.adt-badge-green {
  background: hsl(152, 60%, 42% / .1);
  color: hsl(152, 60%, 32%);
}

.adt-badge-yellow {
  background: hsl(38, 92%, 50% / .1);
  color: hsl(30, 80%, 38%);
}

.adt-badge-red {
  background: hsl(0, 72%, 55% / .1);
  color: hsl(0, 65%, 42%);
}

.adt-badge-blue {
  background: hsl(211, 98%, 54% / .1);
  color: hsl(211, 90%, 40%);
}

/* ===== PAGINATION ===== */
.adt-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--afr-border);
  flex-wrap: wrap;
  gap: 12px;
}

.adt-showing {
  font-size: 13px;
  color: hsl(211, 60%, 50%);
  font-weight: 500;
}

.adt-pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.adt-page-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--afr-border);
  background: var(--afr-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--afr-fg);
  cursor: pointer;
  transition: all .15s;
}

.adt-page-btn:hover:not(:disabled):not(.adt-active) {
  background: hsl(210, 15%, 96%);
  border-color: hsl(214, 20%, 85%);
}

.adt-page-btn.adt-active {
  background: hsl(192.86deg 98.72% 30.59%);
  color: #fff;
  border-color: hsl(192.86deg 98.72% 30.59%);
  box-shadow: 0 2px 6px hsl(211, 98%, 54% / .25);
}

.adt-page-btn:disabled {
  opacity: .3;
  cursor: not-allowed;
}

.adt-page-btn svg {
  width: 15px;
  height: 15px;
}

/* ===== MOBILE LIST VIEW — Separated Card Style ===== */
.adt-mobile-list {
  display: none;
  padding: 12px 16px;
  flex-direction: column;
  gap: 12px;
}

.adt-mobile-card {
  background: var(--afr-card, #fff);
  border: 1px solid var(--afr-border, #e5e7eb);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  transition: box-shadow .15s;
}

.adt-mobile-card:active {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Card header: title + badge */
.adt-mobile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.adt-mobile-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--afr-fg);
  line-height: 1.3;
}

.adt-mobile-card-subtitle {
  font-size: 12.5px;
  color: var(--afr-muted-fg);
  margin-top: 2px;
  line-height: 1.3;
}

/* Card body: meta on left, value on right */
.adt-mobile-card-body {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.adt-mobile-card-meta {
  font-size: 13px;
  color: var(--afr-muted-fg);
  line-height: 1.4;
}

.adt-mobile-card-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--afr-fg);
  white-space: nowrap;
}

/* Fallback row style for tables without special mobile config */
.adt-mobile-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 0;
}

.adt-mobile-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--afr-muted-fg);
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
  min-width: 80px;
}

.adt-mobile-value {
  font-size: 13px;
  color: var(--afr-fg);
  text-align: right;
  word-break: break-word;
}

/* View More / View Less toggle button */
.adt-mobile-row-hidden {
  display: none !important;
}

.adt-mobile-view-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 0;
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--afr-muted-fg, #6b7280);
  background: var(--afr-bg, #f9fafb);
  border: 1px solid var(--afr-border, #e5e7eb);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.adt-mobile-view-more:hover {
  background: var(--afr-sidebar-accent, #eff6ff);
  color: var(--afr-primary, #2563eb);
}

.adt-mobile-view-more svg {
  flex-shrink: 0;
}

/* ===== MOBILE FILTER SIDEBAR ===== */
.adt-mobile-filter-btn {
  display: none;
}

.adt-filter-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .3);
  z-index: 2000;
  animation: adtFadeIn .15s ease;
}

.adt-filter-overlay.adt-open {
  display: block;
}

.adt-filter-sidebar {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  max-width: 85vw;
  height: 100vh;
  background: var(--afr-card);
  z-index: 2001;
  box-shadow: -4px 0 20px rgba(0, 0, 0, .08);
  transition: right .25s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.adt-filter-sidebar.adt-open {
  right: 0;
}

.adt-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--afr-border);
}

.adt-filter-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.adt-filter-close {
  width: 30px;
  height: 30px;
  border: none;
  background: hsl(210, 15%, 95%);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--afr-fg);
  transition: background .15s;
}

.adt-filter-close:hover {
  background: hsl(210, 15%, 90%);
}

.adt-filter-body {
  padding: 16px 20px;
  flex: 1;
}

.adt-filter-section {
  margin-bottom: 20px;
}

.adt-filter-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--afr-muted-fg);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
}

/* ===== DATE FILTER ===== */
.adt-date-fields {
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.adt-date-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--afr-muted-fg);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.adt-date-field input[type="date"] {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--afr-border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--afr-card);
  color: var(--afr-fg);
  outline: none;
  transition: border-color .2s;
}

.adt-date-field input[type="date"]:focus {
  border-color: hsl(211, 80%, 62%);
  box-shadow: 0 0 0 3px hsl(211 98% 54% / .08);
}

.adt-date-actions {
  display: flex;
  gap: 8px;
  padding: 6px 10px 10px;
}

.adt-date-clear,
.adt-date-apply {
  flex: 1;
  height: 34px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--afr-border);
  transition: all .15s;
}

.adt-date-clear {
  background: var(--afr-card);
  color: var(--afr-fg);
}

.adt-date-clear:hover {
  background: hsl(210, 15%, 96%);
}

.adt-date-apply {
  background: hsl(211, 98%, 54%);
  color: #fff;
  border-color: hsl(211, 98%, 54%);
}

.adt-date-apply:hover {
  background: hsl(211, 98%, 48%);
}

/* ===== STATUS FILTER ITEMS ===== */
.adt-status-item {
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--afr-fg);
  transition: background .12s;
}

.adt-status-item:hover {
  background: hsl(210, 15%, 96%);
}

.adt-status-item.adt-active {
  background: hsl(211, 98%, 54% / .08);
  font-weight: 600;
  color: hsl(211, 98%, 48%);
}

/* ===== ACTIVE FILTERS BAR ===== */
.adt-active-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 12px;
  flex-wrap: wrap;
}

.adt-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: hsl(211 98% 54% / .06);
  color: hsl(211, 98%, 48%);
  border: 1px solid hsl(211 98% 54% / .15);
}

.adt-chip-x {
  background: none;
  border: none;
  color: hsl(211, 98%, 48%);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  opacity: .6;
  transition: opacity .15s;
}

.adt-chip-x:hover {
  opacity: 1;
}

.adt-filter-clear-all {
  background: none;
  border: none;
  color: var(--afr-muted-fg);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  padding: 0;
}

.adt-filter-clear-all:hover {
  color: var(--afr-fg);
}

/* ===== SORT DROPDOWN ITEMS ===== */
.adt-sort-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
  font-size: 13px;
  color: var(--afr-fg);
}

.adt-sort-item:hover {
  background: hsl(210, 15%, 96%);
}

.adt-sort-item.adt-active {
  background: hsl(211, 98%, 54% / .08);
  font-weight: 600;
  color: hsl(211, 98%, 48%);
}

.adt-sort-item .adt-sort-dir {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--afr-muted-fg);
  opacity: .7;
}

.adt-sort-item.adt-sort-clear {
  color: hsl(0, 65%, 50%);
}

.adt-sort-item.adt-sort-clear:hover {
  background: hsl(0, 72%, 55% / .06);
}

.adt-sort-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: .6;
}

.adt-sort-panel {
  max-height: 320px;
  overflow-y: auto;
}

/* ===== NO DATA ===== */
.adt-empty {
  text-align: center;
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.adt-empty-icon {
  width: 120px;
  height: 100px;
  margin-bottom: 8px;
}

.adt-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--afr-fg, #374151);
}

.adt-empty-subtitle {
  font-size: 13px;
  color: var(--afr-muted-fg, #9ca3af);
}

/* ===== LOADING OVERLAY ===== */
.adt-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 50;
  border-radius: 12px;
  backdrop-filter: blur(2px);
}

.adt-loading-overlay.adt-visible {
  display: flex;
}

.adt-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid hsl(210, 15%, 90%);
  border-top-color: hsl(211, 98%, 54%);
  border-radius: 50%;
  animation: adtSpin 0.7s linear infinite;
}

@keyframes adtSpin {
  to {
    transform: rotate(360deg);
  }
}

.adt-loading-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--afr-muted-fg, #9ca3af);
}

/* ===== MOBILE LOADING SKELETON ===== */
.adt-mobile-loading {
  display: none;
  padding: 12px 16px;
  flex-direction: column;
  gap: 12px;
}

.adt-mobile-loading.adt-visible {
  display: flex;
}

.adt-skeleton-card {
  background: var(--afr-card, #fff);
  border: 1px solid var(--afr-border, #e5e7eb);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.adt-skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, hsl(210, 15%, 93%) 25%, hsl(210, 15%, 97%) 50%, hsl(210, 15%, 93%) 75%);
  background-size: 200% 100%;
  animation: adtShimmer 1.5s ease infinite;
}

.adt-sk-w60 {
  width: 60%;
}

.adt-sk-w80 {
  width: 80%;
}

.adt-sk-w40 {
  width: 40%;
}

@keyframes adtShimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .adt-toolbar {
    flex-direction: row;
    align-items: stretch;
  }

  .adt-search {
    max-width: 100%;
  }

  .adt-actions .adt-desktop-only {
    display: none !important;
  }

  .adt-mobile-filter-btn {
    display: inline-flex !important;
  }

  .adt-table-wrap {
    display: none;
  }

  .adt-mobile-list {
    display: flex;
  }

  .adt-footer {
    justify-content: center;
  }

  .adt-showing {
    width: 100%;
    text-align: center;
  }

  .adt-loading-overlay {
    display: none !important;
  }
}