/* PDF Pro — Chat Agent Tool Artifact UI (Premium) */

.artifact-msg {
  background: transparent !important;
  padding: 0 !important;
  max-width: 100% !important;
  width: 100%;
  align-self: stretch;
}
.artifact-msg .msg-bubble,
.artifact-msg > .msg-bubble { display: none; }

.artifact-card {
  background: #fff;
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 32px rgba(73, 62, 229, .07);
  margin: 10px 0;
  overflow: hidden;
  max-width: 100%;
  transition: box-shadow .18s ease, transform .18s ease;
  animation: artifact-in .32s cubic-bezier(.2, .9, .3, 1.2);
}
.artifact-card:hover {
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08), 0 10px 40px rgba(73, 62, 229, .12);
}
@keyframes artifact-in {
  0%   { opacity: 0; transform: translateY(6px) scale(.98); }
  100% { opacity: 1; transform: none; }
}

/* Header — hero / report-style */
.artifact-header {
  padding: 20px 20px 18px;
  background:
    radial-gradient(circle at top left, rgba(124, 58, 237, .07), transparent 55%),
    radial-gradient(circle at top right, rgba(73, 62, 229, .04), transparent 55%),
    linear-gradient(180deg, #ffffff 0%, #fafaff 100%);
  border-bottom: 1px solid #ecebf6;
  position: relative;
}
.artifact-header::after {
  content: '';
  position: absolute;
  left: 20px; right: 20px; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, #493ee5, #7c3aed 50%, transparent);
  opacity: .22;
  border-radius: 2px;
}
.artifact-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #7c3aed;
  margin-bottom: 14px;         /* more breathing before title */
  opacity: .6;                 /* fader — secondary info */
}
.artifact-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;       /* was center — visual grounding */
  justify-content: space-between;
  gap: 14px 14px;
}
.artifact-title-block {
  min-width: 0;
  flex: 1 1 180px;
  max-width: 100%;
}
.artifact-title {
  font-weight: 700;
  font-size: 22px;             /* hero size — 18 → 22 */
  line-height: 1.2;
  color: var(--text, #0F172A);
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}
.artifact-ai-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, #493ee5 0%, #7c3aed 100%);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .18);
  flex-shrink: 0;
  animation: ai-pulse 2.2s ease-in-out infinite;
}
@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(124, 58, 237, .18); }
  50%      { box-shadow: 0 0 0 6px rgba(124, 58, 237, .06); }
}

/* Toolbar (primary + secondary) */
.artifact-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.artifact-btn {
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: background .14s ease, color .14s ease, border-color .14s ease, opacity .14s ease, transform .08s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.artifact-btn:active { transform: translateY(1px); }
.artifact-btn-primary {
  background: linear-gradient(135deg, #5d52ef 0%, #493ee5 50%, #7c3aed 100%);
  background-size: 220% 100%;
  background-position: 0% 0%;
  color: #fff;
  border: 1px solid rgba(73, 62, 229, .5);
  padding: 11px 18px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow:
    0 1px 2px rgba(73, 62, 229, .3),
    0 6px 20px rgba(108, 92, 231, .28),  /* premium glow — user spec */
    inset 0 1px 0 rgba(255, 255, 255, .16);
  position: relative;
  overflow: hidden;
  transition: background-position .35s ease, box-shadow .22s ease, transform .14s ease;
}
/* Subtle shimmer sweep on hover */
.artifact-btn-primary::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(100deg, transparent 0%, rgba(255,255,255,.28) 50%, transparent 100%);
  transform: skewX(-20deg);
  transition: left .6s ease;
  pointer-events: none;
}
.artifact-btn-primary:hover {
  background-position: 100% 0%;
  box-shadow:
    0 4px 8px rgba(73, 62, 229, .36),
    0 14px 34px rgba(124, 58, 237, .42),
    inset 0 1px 0 rgba(255, 255, 255, .2);
  transform: translateY(-2px);
}
.artifact-btn-primary:hover::before { left: 120%; }
.artifact-btn-primary:active { transform: translateY(0); }
.artifact-btn-primary svg { fill: #fff; position: relative; z-index: 1; }
.artifact-btn-label { white-space: nowrap; letter-spacing: .005em; position: relative; z-index: 1; }
.artifact-btn-secondary {
  background: #f6f7fa;
  border: 1px solid var(--border, #E2E8F0);
  color: var(--text-2, #475569);
  padding: 7px 11px;
  min-width: 44px;
  justify-content: center;
}
.artifact-btn-secondary:hover {
  background: #eef0fd;
  border-color: #c7c0f2;
  color: var(--primary, #493ee5);
}
.artifact-btn:disabled { opacity: .55; cursor: default; }
.artifact-btn.loading { animation: artifact-pulse 1s ease-in-out infinite; }
.artifact-btn.error {
  background: #fee2e2 !important;
  color: var(--danger, #dc2626) !important;
  border-color: var(--danger, #dc2626) !important;
}
@keyframes artifact-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}

/* Body — clear separation from above sections */
.artifact-body {
  padding: 10px 16px 4px;
  background: #fff;
}

/* Document source — data-source block */
.artifact-source-block {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 16px 18px 0;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fbfaff 0%, #f5f4fd 100%);
  border: 1px solid #eeecf7;
  border-left: 4px solid #6b5cff;   /* thicker accent — user spec */
  border-radius: 12px;
}
.artifact-source-icon {
  width: 38px; height: 38px;         /* 32 → 38 — user spec */
  border-radius: 10px;
  background: #fff;
  border: 1px solid #eeecf7;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b5cff;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(108, 92, 231, .06);
}
.artifact-source-icon svg { width: 16px; height: 16px; }
.artifact-source-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.artifact-source-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #6b5cff;
  opacity: .9;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.artifact-doctype {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7c0f2;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 600;
  opacity: 1;
}
.artifact-doctype-sec {
  background: #f5f3ff;
  color: #6b5cff;
  border-color: #e3defc;
  opacity: .9;
}
.artifact-classconf {
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 2px;
  opacity: .92;
}
.artifact-classconf.conf-high   { background: #dcfce7; color: #166534; }
.artifact-classconf.conf-medium { background: #fef3c7; color: #92400e; }
.artifact-classconf.conf-low    { background: #fee2e2; color: #991b1b; }
.artifact-source-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text, #0F172A);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.005em;
}

/* AI narrative — above the table, clearly separated */
.artifact-narrative {
  display: flex;
  gap: 10px;
  margin: 14px 16px 2px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--text-2, #475569);
  line-height: 1.55;
  background: #fbfbff;
  border: 1px solid #eeecf7;
  border-radius: 10px;
}
.artifact-narrative svg {
  color: #7c3aed;
  flex-shrink: 0;
  margin-top: 2px;
}
.artifact-narrative p {
  margin: 0;
  font-style: italic;
  font-weight: 500;
}

/* Table */
.artifact-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 460px;
  border-radius: 10px;
  border: 1px solid var(--border, #E2E8F0);
  scrollbar-width: thin;
  scrollbar-color: #d6d3e7 transparent;
}
/* Modern scrollbar (webkit) */
.artifact-table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.artifact-table-wrap::-webkit-scrollbar-track { background: transparent; }
.artifact-table-wrap::-webkit-scrollbar-thumb {
  background: #d6d3e7;
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.artifact-table-wrap::-webkit-scrollbar-thumb:hover { background: #b5aee2; background-clip: padding-box; border: 2px solid transparent; }
.artifact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  color: var(--text, #0F172A);
}
.artifact-table th,
.artifact-table td {
  padding: 11px 16px;
  border-bottom: 1px solid #eef0f5;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
.artifact-table th.num,
.artifact-table td.num { text-align: right; font-variant-numeric: tabular-nums; max-width: 160px; }
.artifact-table thead th {
  background: #f9f8fd;
  color: #6f65ec;
  font-weight: 600;
  letter-spacing: .08em;
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 10.5px;
  text-transform: uppercase;
  border-bottom: 1px solid #e3defc;
  padding-top: 12px;
  padding-bottom: 12px;
}
.artifact-table tbody tr { transition: background .16s ease; }
.artifact-table tbody tr:nth-child(even) td { background: #fafbfd; }
.artifact-table tbody tr:hover td { background: #f3f1ff; }  /* brighter hover — user spec */
.artifact-table tbody tr:last-child td { border-bottom: none; }
.artifact-table td:first-child { font-weight: 600; color: var(--text, #0F172A); }
.artifact-table td.num { color: var(--text, #0F172A); font-weight: 500; }

.artifact-caption {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3, #94A3B8);
  font-style: italic;
}

/* Chart */
.artifact-chart-wrap {
  position: relative;
  height: 320px;
  width: 100%;
}

/* PDF stub */
.artifact-pdf-stub {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 2px;
  color: var(--text-2, #475569);
}
.artifact-pdf-stub svg {
  color: var(--primary, #493ee5);
  flex-shrink: 0;
}
.artifact-pdf-meta { flex: 1; min-width: 0; }
.artifact-pdf-name {
  font-weight: 600;
  color: var(--text, #0F172A);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.artifact-pdf-sub {
  font-size: 11px;
  color: var(--text-3, #94A3B8);
  margin-top: 2px;
}

/* Error */
.artifact-error {
  color: var(--danger, #dc2626);
  font-size: 12px;
  padding: 12px;
  background: #fef2f2;
  border-radius: 8px;
}

/* AI Insight block — green theme */
.artifact-insights {
  margin: 14px 16px 14px;
  padding: 14px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
}
.artifact-insights-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #3c6c44;
  margin-bottom: 10px;
  text-transform: none;
}
.artifact-insights-head svg {
  color: #3c6c44;
  flex-shrink: 0;
}
/* Microcopy trust indicator */
.insights-meta {
  font-weight: 500;
  letter-spacing: 0;
  font-size: 10.5px;
  color: #6b8a70;
  margin-left: auto;
  opacity: .9;
}
.artifact-insights-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.insight-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-bottom: 12px;
  border-bottom: 1px dashed rgba(76, 161, 84, .28);
}
.insight-item:last-child { border-bottom: none; padding-bottom: 0; }

/* Category + impact meta row */
.insight-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.insight-category {
  display: inline-flex;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #3c6c44;
  background: rgba(76, 161, 84, .14);
  padding: 2px 8px;
  border-radius: 4px;
  line-height: 1.35;
}
.insight-impact {
  display: inline-flex;
  align-items: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  line-height: 1.3;
  white-space: nowrap;
  opacity: .92;
}
.insight-impact.impact-high   { color: #b91c1c; background: rgba(185, 28, 28, .07); }
.insight-impact.impact-medium { color: #b45309; background: rgba(180, 83, 9, .07); }
.insight-impact.impact-low    { color: #475569; background: rgba(71, 85, 105, .07); }

/* Statement — primary finding */
.insight-statement {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #22543d;
  font-weight: 600;
}
.insight-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ca154;
  flex-shrink: 0;
  margin-top: 6px;
}

/* Interpretation — what it means */
.insight-interpretation {
  font-size: 12px;
  line-height: 1.55;
  color: #4ca154;
  font-weight: 500;
  padding-left: 16px;
}

/* Evidence — footer link */
.insight-evidence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-left: 16px;
  font-size: 10.5px;
  color: #6b8a70;
  font-style: italic;
  letter-spacing: .01em;
  opacity: .92;
}
.insight-evidence svg { color: #7c9b81; opacity: .8; }

/* Legacy confidence badges hidden */
.insight-conf { display: none; }

/* Recommendations block — subtle divider inside the green card */
.artifact-recs {
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px dashed rgba(76, 161, 84, .35);
}
.recs-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #3c6c44;
  opacity: .9;
  margin-bottom: 8px;
}
.recs-head svg { color: #3c6c44; }
.rec-item {
  margin-bottom: 7px;
  font-size: 12px;
  line-height: 1.5;
}
.rec-item:last-child { margin-bottom: 0; }
.rec-scenario {
  color: #3c6c44;
  font-weight: 600;
  margin-bottom: 1px;
}
.rec-action {
  color: #4ca154;
  font-weight: 500;
  padding-left: 2px;
}
.rec-arrow {
  display: inline-block;
  color: #3c6c44;
  font-weight: 700;
  margin-right: 5px;
}

/* Follow-up action cards — AI-suggestion feel */
.artifact-followups {
  display: block;
  padding: 12px 16px 16px;
  border-top: 1px solid #f0eef9;
  margin-top: 6px;
}
.artifact-followups-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: #7c3aed;
  margin-bottom: 10px;
  opacity: .9;
}
.artifact-followups-label svg { color: #7c3aed; }
.artifact-followups-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.artifact-chip {
  display: flex;
  align-items: center;
  gap: 13px;                    /* more icon↔text spacing — user spec */
  padding: 13px 14px 13px 14px;
  padding-top: 20px;            /* reserve space for "Suggested" badge */
  background: #fff;
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  min-width: 0;
  position: relative;
  overflow: hidden;
  transition: border-color .2s ease, box-shadow .22s ease, transform .16s ease, background .2s ease;
}
/* "Suggested" badge, top-right — subtle */
.chip-suggested {
  position: absolute;
  top: 5px;
  right: 7px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: #7c3aed;
  background: #f5f3ff;
  border: 1px solid #e7e3fb;
  border-radius: 999px;
  opacity: .85;
  transition: color .2s ease, background .2s ease, border-color .2s ease, opacity .2s ease;
  z-index: 2;
  pointer-events: none;
}
.chip-suggested svg { flex-shrink: 0; }
.artifact-chip:hover .chip-suggested {
  background: linear-gradient(135deg, #493ee5 0%, #7c3aed 100%);
  color: #fff;
  border-color: transparent;
  opacity: 1;
}
.artifact-chip::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(73,62,229,.04) 0%, rgba(124,58,237,.06) 100%);
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}
.artifact-chip:hover {
  border-color: #c7c0f2;
  box-shadow: 0 12px 25px rgba(15, 23, 42, .08);   /* user spec */
  transform: translateY(-2px);
}
.artifact-chip:hover::before { opacity: 1; }
.artifact-chip:active { transform: translateY(0); box-shadow: 0 2px 6px rgba(73, 62, 229, .12); }
.chip-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  color: #7c3aed;
  transition: background .2s ease, color .2s ease, transform .2s ease;
  position: relative;
  z-index: 1;
}
.artifact-chip:hover .chip-icon {
  background: linear-gradient(135deg, #493ee5 0%, #7c3aed 100%);
  color: #fff;
  transform: scale(1.06);
}
.chip-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}
.chip-label {
  font-weight: 600;
  color: var(--text, #0F172A);
  font-size: 12.5px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.chip-desc {
  font-size: 11px;
  color: var(--text-3, #94A3B8);
  margin-top: 3px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artifact-chip:hover .chip-label { color: #493ee5; }

/* Tool progress indicator */
.agent-progress-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2, #475569);
  font-style: italic;
}
.agent-progress-row .spinner { flex-shrink: 0; }
.agent-progress-label { white-space: nowrap; }

/* Mobile + narrow chat sidebars */
@media (max-width: 640px) {
  .artifact-card { border-radius: 12px; }
  .artifact-header { padding: 14px 14px 12px; }
  .artifact-header::after { left: 14px; right: 14px; }
  .artifact-title { font-size: 15px; }
  .artifact-body { padding: 12px 14px; }
  .artifact-chart-wrap { height: 240px; }
  .artifact-table th, .artifact-table td { padding: 10px 12px; font-size: 11.5px; }
  .artifact-btn-primary { padding: 9px 13px; font-size: 11.5px; }
  .artifact-btn-secondary { padding: 7px 10px; min-width: 44px; font-size: 10.5px; }
  .artifact-insights { margin: 0 14px 12px; padding: 11px 13px; }
  .artifact-insights-list { font-size: 12px; }
  .artifact-followups { padding: 4px 14px 14px; }
  .artifact-source-block { margin: 12px 14px 0; padding: 9px 11px; }
  .artifact-source-icon { width: 28px; height: 28px; }
  .artifact-source-name { font-size: 12px; }
  .artifact-narrative { padding: 10px 14px 2px; font-size: 12px; }
  .artifact-followups-chips { grid-template-columns: 1fr; gap: 7px; }
}

/* Extra-narrow chat sidebars (PDF viewer right-panel, mobile drawer) */
@media (max-width: 480px) {
  /* Force header to stack — title on top row, toolbar below */
  .artifact-title-block { flex: 1 1 100%; }
  .artifact-toolbar {
    flex: 1 1 100%;
    justify-content: flex-start;
  }
  .artifact-btn-primary { flex: 1 1 auto; justify-content: center; }
  .artifact-title { font-size: 14.5px; }
}
