// Sass modules
@use "sass:color";

// Variables
$color-primary: #2563eb;
$color-primary-dark: #1d4ed8;
$color-border: #e5e7eb;
$color-text: #1f2937;
$color-text-light: #6b7280;
$color-bg-light: #f9fafb;
$color-white: #ffffff;
$color-danger: #dc3545;
$color-link: #2563eb;

// Status colors
$color-status-reviewed: #0d9488;
$color-status-reviewed-bg: #d1fae5;
$color-status-extracted: #f59e0b;
$color-status-extracted-bg: #fef3c7;
$color-status-activated: #10b981;
$color-status-activated-bg: #d1fae5;
$color-status-normalized: #8b5cf6;
$color-status-normalized-bg: #ede9fe;
$color-status-failed: #ef4444;
$color-status-failed-bg: #fee2e2;
$color-status-received: #3b82f6;
$color-status-received-bg: #dbeafe;

// ─── Layout ──────────────────────────────────────────────
.ingestion-console {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: $color-text;
  background: $color-bg-light;
  min-height: 100vh;
}

// ─── Header ──────────────────────────────────────────────
.console-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 32px 40px 24px;
}

.header-left {
  .title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 4px;
    color: $color-text;
  }

  .subtitle {
    font-size: 14px;
    color: $color-text-light;
    margin: 0;
  }
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  white-space: nowrap;

  &-icon {
    font-size: 16px;
  }

  &-outline {
    background: $color-white;
    border-color: $color-border;
    color: $color-text;

    &:hover {
      background: $color-bg-light;
      border-color: color.adjust($color-border, $lightness: -10%);
    }

    &:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }
  }

  &-primary {
    background: $color-primary;
    color: $color-white;
    border-color: $color-primary;

    &:hover {
      background: $color-primary-dark;
    }
  }

  &-sm {
    padding: 6px 16px;
    font-size: 13px;
  }
}

// ─── Search Bar ──────────────────────────────────────────
.search-bar {
  display: flex;
  gap: 12px;
  padding: 0 40px 24px;
  align-items: center;
}

.search-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  color: $color-text-light;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  font-size: 14px;
  border: 1px solid $color-border;
  border-radius: 8px;
  outline: none;
  background: $color-white;
  color: $color-text;
  transition: border-color 0.2s;

  &::placeholder {
    color: $color-text-light;
  }

  &:focus {
    border-color: $color-primary;
    box-shadow: 0 0 0 3px rgba($color-primary, 0.1);
  }
}

.btn-filter {
  padding: 12px 20px;
}

// ─── Table ───────────────────────────────────────────────
.table-container {
  margin: 0 40px;
  background: $color-white;
  border: 1px solid $color-border;
  border-radius: 12px;
  overflow: hidden;
}

.ingestion-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;

  thead {
    tr {
      border-bottom: 1px solid $color-border;
    }

    th {
      padding: 14px 16px;
      text-align: left;
      font-size: 12px;
      font-weight: 600;
      color: $color-text-light;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      background: $color-bg-light;
    }
  }

  tbody {
    tr {
      border-bottom: 1px solid $color-border;
      transition: background 0.15s;

      &:last-child {
        border-bottom: none;
      }

      &:hover {
        background: #f8fafc;
      }
    }

    td {
      padding: 16px;
      vertical-align: middle;
    }
  }
}

.col-checkbox {
  width: 48px;
  text-align: center;

  input[type='checkbox'] {
    width: 16px;
    height: 16px;
    cursor: pointer;
  }
}

.col-action {
  width: 40px;
  text-align: center;
}

// ─── Ingestion ID ────────────────────────────────────────
.ingestion-link {
  color: $color-link;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

.duplicate-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
}

.original-ref {
  display: block;
  font-size: 12px;
  color: $color-link;
  margin-top: 2px;
}

// ─── Lane Badge ──────────────────────────────────────────
.lane-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: #f0f4ff;
  color: #3b5998;
  border: 1px solid #d0daf0;
}

// ─── People ──────────────────────────────────────────────
.people-info {
  line-height: 1.6;
}

.people-name {
  font-weight: 500;
  color: $color-text;
}

.people-dept {
  font-size: 13px;
  color: $color-text-light;
}

.people-reviewer,
.people-approver {
  font-size: 12px;
  color: $color-text-light;
}

.people-icon {
  font-size: 13px;
  margin-right: 4px;
}

// ─── Status Badge ────────────────────────────────────────
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;

  .status-icon {
    font-size: 10px;
  }
}

.status-reviewed {
  background: $color-status-reviewed-bg;
  color: $color-status-reviewed;
}

.status-extracted {
  background: $color-status-extracted-bg;
  color: $color-status-extracted;
}

.status-activated {
  background: $color-status-activated-bg;
  color: $color-status-activated;
}

.status-normalized {
  background: $color-status-normalized-bg;
  color: $color-status-normalized;
}

.status-failed {
  background: $color-status-failed-bg;
  color: $color-status-failed;
}

.status-received {
  background: $color-status-received-bg;
  color: $color-status-received;
}

// ─── Confidence ──────────────────────────────────────────
.confidence-alert {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  background: $color-status-failed-bg;
  color: $color-status-failed;
}

.confidence-value {
  font-weight: 500;
}

// ─── Submitted ───────────────────────────────────────────
.submitted-date {
  font-weight: 500;
  color: $color-text;
}

.submitted-time {
  font-size: 12px;
  color: $color-text-light;
}

// ─── Row Chevron ─────────────────────────────────────────
.row-chevron {
  font-size: 20px;
  color: $color-text-light;
}

// ─── Footer / Pagination ─────────────────────────────────
.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 40px;
}

.results-count {
  font-size: 14px;
  color: $color-text-light;
}

.pagination {
  display: flex;
  gap: 8px;
}

.table-row {
  cursor: pointer;
}

// ─── Loading & Empty States ──────────────────────────────
.loading-state {
  text-align: center;
  padding: 60px 20px;
  
  .spinner {
    margin: 0 auto 20px;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid $color-primary;
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
  
  p {
    color: $color-text-light;
    font-size: 14px;
  }
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  
  div {
    font-size: 48px;
    margin-bottom: 16px;
  }
  
  h3 {
    color: $color-text;
    margin-bottom: 8px;
    font-size: 18px;
    font-weight: 600;
  }
  
  p {
    color: $color-text-light;
    font-size: 14px;
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
