/* ===================================================
   MicroChat 3.0 - Real Live Activity & Tool Trace
   Two-Phase Observability System:
     Phase 1: Live Activity with Blue Pulsing Cursor Indicator
     Phase 2: Compact Disclosure Tool Trace Summary
   =================================================== */

.tool-trace-wrapper {
  margin: 0 0 8px 0;
  width: 100%;
}

/* ===================================================
   PHASE 1: LIVE ACTIVITY (ONE COMPACT ROW)
   =================================================== */

.tool-activity-live {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0 4px 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: fadeInActivity 0.2s ease-out;
}

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

.tool-activity-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  line-height: 1.4;
  user-select: none;
}

.tool-activity-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 16px !important;
  height: 16px !important;
  max-width: 16px !important;
  max-height: 16px !important;
  color: #2563EB;
  flex-shrink: 0 !important;
}

.tool-activity-icon svg {
  width: 15px !important;
  height: 15px !important;
  max-width: 15px !important;
  max-height: 15px !important;
  display: block !important;
}

.trace-tool-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 15px !important;
  height: 15px !important;
  max-width: 15px !important;
  max-height: 15px !important;
  color: #64748B;
  flex-shrink: 0 !important;
  margin-right: 2px;
}

.trace-tool-icon svg {
  width: 14px !important;
  height: 14px !important;
  max-width: 14px !important;
  max-height: 14px !important;
  display: block !important;
}

/* Live Activity Pulsing Blue Circle Indicator */
.tool-live-pulse-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #2563EB;
  margin-right: 2px;
  vertical-align: middle;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.6);
  animation: toolLiveCursorPulse 1.2s infinite ease-in-out;
}

@keyframes toolLiveCursorPulse {
  0% {
    transform: scale(0.85);
    opacity: 0.7;
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.6);
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
    box-shadow: 0 0 0 5px rgba(37, 99, 235, 0);
  }
  100% {
    transform: scale(0.85);
    opacity: 0.7;
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
  }
}

.tool-live-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: #10B981;
  margin-right: 2px;
  flex-shrink: 0;
}

.tool-live-fail {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: #EF4444;
  margin-right: 2px;
  flex-shrink: 0;
}

.tool-activity-text {
  font-size: 13px;
  color: #475569;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.tool-activity-text code {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 11.5px;
  background: #F8FAFC;
  color: #0F172A;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #E2E8F0;
  word-break: break-all;
}

/* ===================================================
   AI TEXT-GENERATION STREAM CURSOR (Blue Pulsing Caret)
   Attached to the end of the streaming AI response text
   =================================================== */
.ai-stream-cursor {
  display: inline-block;
  width: 8.5px;
  height: 8.5px;
  border-radius: 50%;
  background-color: #2563EB;
  margin-left: 5px;
  margin-right: 2px;
  vertical-align: middle;
  box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.6);
  animation: aiCursorPulse 1.1s infinite cubic-bezier(0.4, 0, 0.6, 1);
  pointer-events: none;
  user-select: none;
}

@keyframes aiCursorPulse {
  0% {
    transform: scale(0.85);
    opacity: 0.6;
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.6);
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
    box-shadow: 0 0 0 5px rgba(37, 99, 235, 0);
  }
  100% {
    transform: scale(0.85);
    opacity: 0.6;
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
  }
}

/* ===================================================
   PHASE 2: FINAL COMPACT TOOL TRACE DISCLOSURE
   =================================================== */

.trace {
  border-bottom: none;
  padding-bottom: 4px;
  margin-bottom: 4px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: fadeInTrace 0.25s ease-out;
}

.trace:not([open]) > :not(summary) {
  display: none !important;
}

@keyframes fadeInTrace {
  from { opacity: 0; }
  to { opacity: 1; }
}

.trace summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  color: #94A3B8;
  cursor: pointer;
  user-select: none;
}

.trace summary::-webkit-details-marker {
  display: none;
}

.trace summary .chev {
  width: 13px;
  height: 13px;
  color: #94A3B8;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.trace[open] summary .chev {
  transform: rotate(90deg);
}

.trace-body {
  padding: 8px 0 2px 0;
  font-size: 13px;
  color: #475569;
  line-height: 1.5;
}

.trace-step {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  align-items: center;
}

.trace-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  font-size: 11px;
}

.trace-status-icon.completed {
  color: #10B981;
}

.trace-status-icon.failed {
  color: #EF4444;
}

.trace-status-icon.running {
  color: #64748B;
}

.trace-step .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #94A3B8;
  margin-top: 1px;
  flex-shrink: 0;
}

.trace-step code {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 11.5px;
  background: #F8FAFC;
  color: #0F172A;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #E2E8F0;
  word-break: break-all;
}

/* ===================================================
   DARK MODE SUPPORT
   =================================================== */

body.dark-mode .tool-activity-row,
[data-theme="dark"] .tool-activity-row {
  color: #CBD5E1;
}

body.dark-mode .tool-activity-icon,
[data-theme="dark"] .tool-activity-icon {
  color: #94A3B8;
}

body.dark-mode .tool-activity-text,
[data-theme="dark"] .tool-activity-text {
  color: #CBD5E1;
}

body.dark-mode .tool-activity-text code,
[data-theme="dark"] .tool-activity-text code {
  background: #1E293B;
  color: #F1F5F9;
  border-color: #334155;
}


body.dark-mode .trace summary,
[data-theme="dark"] .trace summary {
  color: #94A3B8;
}

body.dark-mode .trace summary .chev,
[data-theme="dark"] .trace summary .chev {
  color: #64748B;
}

body.dark-mode .trace-body,
[data-theme="dark"] .trace-body {
  color: #CBD5E1;
}

body.dark-mode .trace-step .dot,
[data-theme="dark"] .trace-step .dot {
  background: #64748B;
}

body.dark-mode .trace-step code,
[data-theme="dark"] .trace-step code {
  background: #1E293B;
  color: #F1F5F9;
  border-color: #334155;
}

body.dark-mode .tool-live-pulse-dot,
[data-theme="dark"] .tool-live-pulse-dot {
  background-color: #60A5FA;
  box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.6);
  animation-name: toolLiveCursorPulseDark;
}

@keyframes toolLiveCursorPulseDark {
  0% {
    transform: scale(0.85);
    opacity: 0.7;
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.6);
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
    box-shadow: 0 0 0 5px rgba(96, 165, 250, 0);
  }
  100% {
    transform: scale(0.85);
    opacity: 0.7;
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0);
  }
}

body.dark-mode .ai-stream-cursor,
[data-theme="dark"] .ai-stream-cursor {
  background-color: #60A5FA;
  box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.6);
  animation-name: aiCursorPulseDark;
}

@keyframes aiCursorPulseDark {
  0% {
    transform: scale(0.85);
    opacity: 0.6;
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.6);
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
    box-shadow: 0 0 0 5px rgba(96, 165, 250, 0);
  }
  100% {
    transform: scale(0.85);
    opacity: 0.6;
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0);
  }
}
