/* Token Chain Viewer — Redesigned */

.token-chain-viewer {
  background: #f7f8fc;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  padding: 24px;
  margin: 20px 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.token-chain-viewer .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #e8eaf0;
}

.token-chain-viewer .header h3 {
  margin: 0;
  color: #1a1a2e;
  font-size: 1.4em;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.token-chain-viewer .btn-clear {
  background: #ff4444;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 600;
  transition: background 0.2s;
}

.token-chain-viewer .btn-clear:hover {
  background: #cc0000;
}

.events-timeline {
  max-height: 700px;
  overflow-y: auto;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.no-events {
  text-align: center;
  padding: 48px 20px;
  color: #999;
  font-style: italic;
  font-size: 0.95em;
}

/* System events */
.event.system-event {
  background: #E3F2FD;
  border-left: 3px solid #2196F3;
  padding: 10px 14px;
  border-radius: 6px;
  display: flex;
  gap: 12px;
  font-size: 0.88em;
  color: #1565C0;
}

.event.system-event.success {
  background: #E8F5E9;
  border-left-color: #4CAF50;
  color: #2E7D32;
}

.event.system-event.error {
  background: #FFEBEE;
  border-left-color: #f44336;
  color: #C62828;
}

/* ─── Base card ─────────────────────────────── */

.tc-card {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  animation: slideIn 0.3s ease-out;
  transition: box-shadow 0.2s, transform 0.2s;
}

.tc-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

.tc-card--cached {
  opacity: 0.72;
}

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

/* ─── Card header ─────────────────────────── */

.tc-card__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.tc-card__header--clickable {
  cursor: pointer;
  user-select: none;
}

.tc-card__header--clickable:hover {
  filter: brightness(0.97);
}

/* ─── Collapsible body ───────────────────────── */

.tc-card__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease;
}

.tc-card__body--open {
  max-height: 600px;
}

/* ─── Chevron toggle ─────────────────────────── */

.tc-chevron {
  font-size: 0.65em;
  color: #aaa;
  transition: transform 0.25s ease;
  flex-shrink: 0;
  margin-left: 2px;
}

.tc-chevron--open {
  transform: rotate(180deg);
}

.tc-card__icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3em;
  flex-shrink: 0;
}

.tc-card__titles {
  flex: 1;
  min-width: 0;
}

.tc-card__title {
  font-weight: 700;
  font-size: 1em;
  color: #1a1a2e;
  line-height: 1.2;
}

.tc-card__subtitle {
  font-size: 0.78em;
  color: #666;
  margin-top: 2px;
}

.tc-card__time {
  font-size: 0.8em;
  color: #888;
  font-family: 'Monaco', 'Courier New', monospace;
  white-space: nowrap;
}

.tc-cached-label {
  display: inline-block;
  background: rgba(0,0,0,0.12);
  font-size: 0.85em;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
}

/* ─── Identity badges ─────────────────────── */

.tc-identity-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tc-badge--user {
  background: #EDE7F6;
  color: #512DA8;
  border: 1px solid #B39DDB;
}

.tc-badge--agent {
  background: #FFF3E0;
  color: #E65100;
  border: 1px solid #FFCC80;
}

.tc-badge--obo {
  background: linear-gradient(135deg, #E8F5E9, #E3F2FD);
  color: #1B5E20;
  border: 1px solid #A5D6A7;
  font-size: 0.68em;
}

/* ─── CIBA card ─────────────────────────────── */

.tc-card--ciba {
  background: white;
  border: 1px solid #D1C4E9;
}

.tc-card--ciba .tc-card__header {
  background: linear-gradient(135deg, #F3E5F5 0%, #EDE7F6 100%);
  border-bottom: 1px solid #D1C4E9;
}

.tc-icon--ciba {
  background: #9C27B0;
  color: white;
}

.tc-card__email {
  padding: 8px 16px;
  font-size: 0.9em;
  color: #512DA8;
  font-weight: 500;
  border-bottom: 1px solid #EDE7F6;
  background: #F9F5FF;
}

/* ─── Actor card ────────────────────────────── */

.tc-card--actor {
  background: white;
  border: 1px solid #FFE0B2;
}

.tc-card--actor .tc-card__header {
  background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
  border-bottom: 1px solid #FFE0B2;
}

.tc-icon--actor {
  background: #FF9800;
  color: white;
}

/* ─── Exchange card ─────────────────────────── */

.tc-card--exchange {
  background: white;
  border: 2px solid #81C784;
  box-shadow: 0 4px 16px rgba(76, 175, 80, 0.15);
}

.tc-card--exchange .tc-card__header {
  background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
  border-bottom: 1px solid #A5D6A7;
}

.tc-icon--exchange {
  background: linear-gradient(135deg, #4CAF50, #1B5E20);
  color: white;
}

/* ─── OBO Delegation Diagram ─────────────────── */

.tc-obo-diagram {
  margin: 0 16px 4px;
  background: linear-gradient(135deg, #F1F8E9 0%, #E8F5E9 100%);
  border: 1px solid #C8E6C9;
  border-radius: 8px;
  padding: 14px 16px;
}

.tc-obo-title {
  font-size: 0.78em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #2E7D32;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tc-rfc-tag {
  background: #2E7D32;
  color: white;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.9em;
  letter-spacing: 0.02em;
}

.tc-obo-chain {
  display: flex;
  align-items: center;
}

.tc-obo-node {
  flex: 1;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
  min-width: 0;
}

.tc-obo-node--user {
  background: #EDE7F6;
  border: 1px solid #CE93D8;
}

.tc-obo-node--agent {
  background: #FFF3E0;
  border: 1px solid #FFCC80;
}

.tc-obo-node__icon {
  font-size: 1.4em;
  margin-bottom: 4px;
}

.tc-obo-node__label {
  font-size: 0.7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #555;
  margin-bottom: 4px;
}

.tc-obo-node__value {
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.72em;
  color: #333;
  word-break: break-all;
  line-height: 1.3;
}

.tc-obo-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 10px;
  flex-shrink: 0;
}

.tc-obo-arrow__line {
  width: 40px;
  height: 2px;
  background: linear-gradient(90deg, #9C27B0, #4CAF50);
  position: relative;
  margin-bottom: 6px;
}

.tc-obo-arrow__line::after {
  content: '▶';
  position: absolute;
  right: -8px;
  top: -7px;
  color: #4CAF50;
  font-size: 0.85em;
}

.tc-obo-arrow__label {
  font-size: 0.65em;
  color: #777;
  text-align: center;
  white-space: nowrap;
  font-style: italic;
}

/* ─── Shared meta pill rows ─────────────────── */

.tc-card__meta {
  padding: 10px 16px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tc-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.85em;
}

.tc-meta-label {
  font-weight: 600;
  color: #888;
  font-size: 0.82em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tc-meta-value {
  color: #333;
}

.tc-flow-tag {
  font-family: 'Monaco', 'Courier New', monospace;
  color: #1565C0;
  font-size: 0.88em;
}

.tc-resource-url {
  font-family: 'Monaco', 'Courier New', monospace;
  color: #1976D2;
  font-size: 0.85em;
  word-break: break-all;
}

.tc-meta-item--app {
  border-color: #CE93D8;
  background: #F3E5F5;
}

.tc-app-name {
  font-weight: 600;
  color: #6A1B9A;
}

/* ─── Scopes ─────────────────────────────────── */

.scope-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.scope-tag {
  background: #1565C0;
  color: white;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 0.82em;
  font-weight: 600;
}

/* ─── Scrollbar ──────────────────────────────── */

.events-timeline::-webkit-scrollbar {
  width: 6px;
}

.events-timeline::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 3px;
}

.events-timeline::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.events-timeline::-webkit-scrollbar-thumb:hover {
  background: #999;
}
