// Sync page — Reconciliation & Sync screen layout
// Uses UI components: StatusCard, SyncTableRow, Input, SelectFilter, Button

.page {
  display: flex;
  flex-direction: column;
  gap: map.get($spacing-scale, 'lg');
  max-width: 1200px;
  padding-bottom: map.get($spacing-scale, 'xl');
}

// ── Header ─────────────────────────────────────────
.header {
  display: flex;
  align-items: center;
  gap: map.get($spacing-scale, 'sm');
}

// Nested for (0,2,0) specificity to beat WP admin `.wrap h1` at (0,1,1)
.header .title {
  @include body-large-medium;
  line-height: 1;
  color: var(--color-text-primary);
  margin: 0;
  padding: 0;
  flex: 1;
  white-space: nowrap;
}

.headerActions {
  display: flex;
  align-items: center;
  gap: map.get($spacing-scale, 'sm');
  flex-shrink: 0;
}

.searchWrapper {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 220px;
}

.searchInput {
  flex: 1;
  min-width: 0;
}


.focusTrap {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

// ── Status Cards Row ───────────────────────────────
.statusCards {
  display: flex;
  gap: map.get($spacing-scale, 'sm');
}

.statusCard {
  max-width: none;
}

// ── Table ──────────────────────────────────────────
.tableContainer {
  background-color: var(--color-surface-primary);
  border: 1px solid var(--color-grey-soft);
  border-radius: map.get($radius, 'lg');
  overflow: hidden;
}

.tableHeader {
  display: flex;
  align-items: center;
  padding: 0 map.get($spacing-scale, 'md');
  background-color: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-grey-soft);
  min-height: 40px;
}

.headerText {
  @include caption-medium;
  color: var(--color-text-secondary);
  padding: 0 map.get($spacing-scale, 's-2');
  flex-shrink: 0;
}

.tableBody {
  max-height: 660px;
  overflow-y: auto;
}

.scrollIndicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: map.get($spacing-scale, 's-1');
  padding: map.get($spacing-scale, 'sm');
  border-top: 1px solid var(--color-grey-soft);
  cursor: pointer;
  user-select: none;

  @include caption-regular;
  color: var(--color-text-tertiary);
  @include transition(color);

  &:hover {
    color: var(--color-text-secondary);
  }

  svg {
    width: 14px;
    height: 14px;
  }
}

// ── Pagination ─────────────────────────────────────
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: map.get($spacing-scale, 'md');
  padding-top: map.get($spacing-scale, 's-2');
}

.paginationText {
  @include caption-regular;
  color: var(--color-text-secondary);
}

// ── States ─────────────────────────────────────────
.loadingContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: map.get($spacing-scale, 'md');
  padding: 80px 0;
  color: var(--color-text-tertiary);

  @include body-small-regular;
}

.emptyRow {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px map.get($spacing-scale, 'md');
  color: var(--color-text-tertiary);

  @include body-small-regular;
}

.errorBannerRow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;

  > :first-child {
    flex: 1;
  }
}

// ── First-Run Welcome Banner ────────────────────────
.welcomeBanner {
  display: flex;
  align-items: center;
  gap: map.get($spacing-scale, 'md');
  padding: map.get($spacing-scale, 'md') map.get($spacing-scale, 'lg');
  background: linear-gradient(105deg, rgba(95, 91, 243, 0.06) 0%, rgba(199, 81, 192, 0.04) 100%);
  border: 1px solid rgba(95, 91, 243, 0.2);
  border-left: 3px solid var(--color-brand-primary);
  border-radius: map.get($radius, 'lg');
  animation: welcomeFadeIn 0.4s ease;
}

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

.welcomeIcon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: rgba(95, 91, 243, 0.12);
  border: 1.5px solid rgba(95, 91, 243, 0.25);
  animation: iconPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

@keyframes iconPop {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

.welcomeBody {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.welcomeHeading {
  @include body-small-medium;
  color: var(--color-text-primary);
  margin: 0;
}

.welcomeText {
  @include body-small-regular;
  color: var(--color-text-secondary);
  margin: 0;

  strong {
    color: var(--color-text-primary);
    font-weight: 500;
  }
}

.welcomeLink {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  @include body-small-regular;
  color: var(--color-brand-primary);
  text-decoration: underline;
  text-underline-offset: 2px;

  &:hover {
    opacity: 0.8;
  }
}

.welcomeAutoLabel {
  display: flex;
  align-items: center;
  gap: 6px;
  @include body-small-regular;
  font-size: 11px;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

.welcomeDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-brand-primary);
  flex-shrink: 0;
  animation: dotPulse 1.4s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

// ── Sync Progress Banner ────────────────────────────
.syncBanner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: map.get($spacing-scale, 'md') map.get($spacing-scale, 'lg');
  background: rgba(95, 91, 243, 0.05);
  border: 1px solid rgba(95, 91, 243, 0.15);
  border-radius: map.get($radius, 'lg');
}

.syncBannerHeader {
  display: flex;
  align-items: center;
  gap: 8px;
}

.syncBannerTitle {
  @include body-small-medium;
  color: var(--color-text-primary);
  flex: 1;
}

.syncBannerPct {
  @include caption-medium;
  color: var(--color-brand-primary);
  flex-shrink: 0;
}

.syncProgressTrack {
  height: 4px;
  background: rgba(95, 91, 243, 0.12);
  border-radius: 2px;
  overflow: hidden;
}

.syncProgressFill {
  height: 100%;
  background: linear-gradient(90deg, #5F5BF3, #C751C0);
  border-radius: 2px;
  transition: width 0.4s ease;
  min-width: 4px;
}

.syncBannerSteps {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 2px;
  flex-wrap: wrap;
}

.syncBannerStepGroup {
  display: flex;
  align-items: center;
  gap: 6px;
}

.syncBannerChevron {
  @include caption-regular;
  color: var(--color-text-tertiary);
  line-height: 1;
}

.syncBannerStep {
  @include caption-regular;
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}

.step_active {
  color: var(--color-brand-primary);
  font-weight: map.get($font-weights, 'medium');
}

.step_completed {
  color: var(--color-semantic-success);
}

.step_idle {
  color: var(--color-text-tertiary);
}


// ── Responsive ─────────────────────────────────────
@media (max-width: $breakpoint-content) {
  .header {
    flex-direction: column;
    align-items: stretch;
    gap: map.get($spacing-scale, 'md');
  }

  .headerActions {
    flex-wrap: wrap;
  }

  .searchInput {
    width: 100%;
    flex: 1;
  }

  .statusCards {
    flex-wrap: wrap;
  }

  .statusCard {
    min-width: 140px;
    flex: 1;
  }
}

// ── Skeleton loader ─────────────────────────────────
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

.skeletonRow {
  display: flex;
  align-items: center;
  min-height: 60px;
  padding: 0 map.get($spacing-scale, 'md');
  border-bottom: 1px solid var(--color-grey-soft);
  gap: map.get($spacing-scale, 's-2');
}

.skeletonCell {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--color-grey-soft) 25%,
    var(--color-grey-light, #f0f0f0) 50%,
    var(--color-grey-soft) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
