/* ═══════════════════════════════════════════════
   Phase 6 — Agent Features
   Activity panel, thinking phases, tool calls, memory
   ═══════════════════════════════════════════════ */

/* ── Activity Panel (right side) ── */
#activity-panel {
  position: absolute;
  right: 0;
  top: var(--topbar-h);
  bottom: 0;
  width: 320px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  box-shadow: -4px 0 20px rgba(0,0,0,.15);
}
#activity-panel.open { transform: translateX(0); }

.ap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
#ap-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
}
#ap-close:hover { color: var(--text); }

#ap-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.ap-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 32px 16px;
  opacity: .6;
}

/* Activity log entries */
.ap-entry {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border: 1px solid transparent;
  animation: entryIn .2s ease;
}
@keyframes entryIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }

.ap-entry.info {
  background: var(--surface-hover);
}
.ap-entry.tool_call {
  background: rgba(0,229,255,.08);
  border-color: rgba(0,229,255,.2);
}
.ap-entry.tool_result {
  background: rgba(46,213,115,.08);
  border-color: rgba(46,213,115,.2);
}
.ap-entry.thinking {
  background: rgba(255,165,2,.08);
  border-color: rgba(255,165,2,.2);
}
.ap-entry.error {
  background: rgba(255,71,87,.08);
  border-color: rgba(255,71,87,.2);
}

.ap-entry .entry-time {
  font-size: 10px;
  color: var(--text-dim);
  opacity: .6;
  margin-bottom: 2px;
}
.ap-entry .entry-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}
.ap-entry .entry-detail {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
  max-height: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ap-entry .entry-detail.expanded {
  max-height: none;
}
.ap-entry .entry-expand {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 0;
}

/* ── Thinking phase indicator ── */
.msg-think-phase {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  opacity: .7;
  transition: opacity .3s;
}
.msg-think-phase .phase-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  animation: phasePulse 1s infinite;
}
@keyframes phasePulse {
  0%, 100% { opacity: .4; }
  50% { opacity: 1; }
}
.msg-think-phase .phase-dot.blue { background: var(--accent); }
.msg-think-phase .phase-dot.yellow { background: #ffa502; }
.msg-think-phase .phase-dot.green { background: var(--success); }

/* ── Tool call inside bubble ── */
.tool-call-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 8px 0;
  overflow: hidden;
}
.tool-call-card .tcc-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface-hover);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.tool-call-card .tcc-header:hover {
  background: var(--surface-active);
}
.tool-call-card .tcc-header .tcc-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.tool-call-card .tcc-body {
  padding: 8px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-all;
  display: none;
  max-height: 200px;
  overflow: auto;
}
.tool-call-card .tcc-body.open { display: block; }

/* ── Memory Overlay ── */
#memory-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
#memory-overlay.open { display: flex; }

.mem-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.mem-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
}
#mem-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 22px; cursor: pointer;
}

.mem-search {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
#mem-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
#mem-input:focus { border-color: var(--accent); }
#mem-search-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

#mem-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

.mem-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.mem-item:last-child { border-bottom: none; }
.mem-item .mem-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.mem-item .mem-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  opacity: .6;
}

/* ── Running task status ── */
.task-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--accent);
  margin: 4px 0;
}
.task-status .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 768px) {
  #activity-panel {
    width: 100%;
    top: var(--topbar-h);
  }
  .mem-panel { width: 95%; }
}
