/* ============================================
   Email Ingestion Admin Page
   ============================================ */

/* ── Layout ────────────────────────────────── */

.ei-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  padding-top: 72px; /* 48px header + 24px spacing */
}

.ei-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.ei-header h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

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

/* ── Buttons ───────────────────────────────── */

.ei-btn {
  padding: 8px 16px;
  border-radius: var(--radius-md, 6px);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.ei-btn-ingest {
  background: var(--color-success, #10b981);
  color: #fff;
}
.ei-btn-ingest:hover { background: #059669; }
.ei-btn-ingest:disabled { opacity: 0.5; cursor: not-allowed; }

.ei-btn-skip {
  background: var(--color-bg-tertiary, #f3f4f6);
  color: var(--color-text-secondary, #374151);
}
.ei-btn-skip:hover { background: var(--color-border, #e5e7eb); }

.ei-btn-scan {
  background: #3b82f6;
  color: #fff;
}
.ei-btn-scan:hover { background: #2563eb; }
.ei-btn-scan:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Stat Cards ────────────────────────────── */

.ei-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.ei-stat-card {
  background: var(--color-bg, #fff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: var(--radius-md, 6px);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ei-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text, #111827);
}

.ei-stat-label {
  font-size: 13px;
  color: var(--color-text-secondary, #6b7280);
}

.ei-stat-card.pending .ei-stat-value {
  color: var(--color-warning, #f59e0b);
}

.ei-stat-card.ingested .ei-stat-value {
  color: var(--color-success, #10b981);
}

/* ── Tab Bar ───────────────────────────────── */

.ei-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
  margin-bottom: 20px;
}

.ei-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary, #6b7280);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s;
}

.ei-tab:hover {
  color: var(--color-text, #111827);
}

.ei-tab.active {
  color: var(--color-text, #111827);
  border-bottom-color: var(--color-text, #111827);
}

.ei-tab .tab-count {
  display: inline-block;
  background: var(--color-bg-tertiary, #f3f4f6);
  color: var(--color-text-secondary, #6b7280);
  border-radius: 10px;
  padding: 0 6px;
  font-size: 11px;
  margin-left: 6px;
  font-weight: 600;
}

.ei-tab.active .tab-count {
  background: var(--color-text, #111827);
  color: #fff;
}

/* ── Table ─────────────────────────────────── */

.ei-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ei-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--color-border, #e5e7eb);
  font-weight: 600;
  color: var(--color-text-secondary, #6b7280);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ei-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-bg-tertiary, #f3f4f6);
  vertical-align: top;
}

.ei-table .email-row {
  cursor: pointer;
  transition: background 0.1s;
}

.ei-table .email-row:hover {
  background: var(--color-bg-secondary, #f9fafb);
}

.ei-table .email-row.selected {
  background: #ecfdf5;
}

/* ── Cell Content ──────────────────────────── */

.ei-sender {
  font-weight: 500;
  color: var(--color-text, #111827);
}

.ei-subject {
  font-weight: 500;
  color: var(--color-text, #111827);
}

.ei-company-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--color-bg-tertiary, #f3f4f6);
  border-radius: 4px;
  font-size: 12px;
  color: var(--color-text-secondary, #374151);
}

.ei-domain {
  color: var(--color-text-muted, #9ca3af);
  font-size: 11px;
  margin-left: 4px;
}

.ei-company-display {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.ei-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--color-text-muted, #9ca3af);
  padding: 0 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.ei-company-display:hover .ei-edit-btn {
  opacity: 1;
}

.ei-preview {
  color: var(--color-text-secondary, #6b7280);
  font-size: 12px;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Status Badges ─────────────────────────── */

.ei-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.ei-status.pending {
  background: #fef3c7;
  color: #92400e;
}

.ei-status.ingested {
  background: #d1fae5;
  color: #065f46;
}

.ei-status.skipped {
  background: var(--color-bg-tertiary, #f3f4f6);
  color: var(--color-text-secondary, #6b7280);
}

/* ── Score Badges ──────────────────────────── */

.ei-scores {
  display: flex;
  gap: 4px;
}

.ei-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: var(--color-bg-tertiary, #f3f4f6);
  color: var(--color-text-secondary, #6b7280);
}

.ei-score-badge.high {
  background: #d1fae5;
  color: #065f46;
}

.ei-score-badge.medium {
  background: #fef3c7;
  color: #92400e;
}

.ei-score-badge.low {
  background: #fee2e2;
  color: #991b1b;
}

/* ── Detail Panel (click-to-expand) ────────── */

.ei-detail {
  display: none;
}

.ei-detail.open {
  display: table-row;
}

.ei-detail-inner {
  padding: 16px 24px;
  background: var(--color-bg-secondary, #f9fafb);
  border-bottom: 1px solid var(--color-border, #e5e7eb);
  border-left: 3px solid var(--color-border, #e5e7eb);
}

.ei-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--color-text-secondary, #6b7280);
}

.ei-detail-meta strong {
  color: var(--color-text, #111827);
}

.ei-detail-scores {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--color-bg, #fff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: var(--radius-md, 6px);
  font-size: 12px;
}

.ei-detail-scores .score-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ei-detail-scores .score-label {
  color: var(--color-text-secondary, #6b7280);
}

.ei-detail-scores .score-value {
  font-weight: 600;
  color: var(--color-text, #111827);
}

.ei-detail-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-text-secondary, #374151);
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: inherit;
  padding: 12px;
  background: var(--color-bg, #fff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: var(--radius-md, 6px);
}

/* ── Empty State ───────────────────────────── */

.ei-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted, #9ca3af);
}

.ei-empty h3 {
  color: var(--color-text-secondary, #6b7280);
  margin-bottom: 8px;
}
