/* ============================================================================
   OZO AI Agent — panel.css
   Lean B안 14번째 시범 (2026-05-19).
   위젯 슬라이드 패널(380px) 안에서 채팅 형식 + tool trace 카드 표시.
   ============================================================================ */

.dash-widget-slot[data-widget="ai-agent"] {
  height: 100%;
}

.ozo-agent-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  font-family: 'Pretendard', 'Inter', -apple-system, 'Malgun Gothic', sans-serif;
}

/* 컨텍스트 바 (사용자·프로젝트·활성 앱 chips + 초기화 버튼) */
.ozo-agent-context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #0c4a6e 0%, #1e1b4b 100%);
  border-bottom: 1px solid #312e81;
  flex-shrink: 0;
}
.ozo-agent-context {
  flex: 1;
  min-width: 0;
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ozo-agent-reset {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.1);
  color: #fde047;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.ozo-agent-reset:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}
.ozo-agent-reset:active {
  transform: translateY(0);
}
.ozo-agent-reset svg { flex-shrink: 0; }
.ozo-agent-context-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #fde047;
  font-weight: 700;
}
.ozo-agent-context-chip.muted {
  color: #c4b5fd;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 500;
}

/* 결과 영역 */
.ozo-agent-results {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ozo-agent-welcome {
  padding: 18px 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(15,23,42,0.04);
}
.ozo-agent-welcome-title {
  font-size: 14px;
  font-weight: 800;
  color: #0c4a6e;
  margin-bottom: 6px;
}
.ozo-agent-welcome-hint {
  font-size: 11.5px;
  color: #64748b;
  line-height: 1.55;
}

/* 메시지 (사용자 입력 + 어시스턴트 응답) */
.ozo-agent-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
}
.ozo-agent-msg.user {
  align-items: flex-end;
}
.ozo-agent-msg.assistant {
  align-items: flex-start;
}
.ozo-agent-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  max-width: 92%;
  word-break: break-word;
  white-space: pre-wrap;
}
.ozo-agent-msg.user .ozo-agent-bubble {
  background: linear-gradient(135deg, #0284c7 0%, #4338ca 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.ozo-agent-msg.assistant .ozo-agent-bubble {
  background: #fff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

/* 작업 진행 표시 (loading) */
.ozo-agent-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  color: #4338ca;
  font-size: 12px;
  font-weight: 600;
}
.ozo-agent-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #c7d2fe;
  border-top-color: #4338ca;
  border-radius: 50%;
  animation: ozo-spin 0.8s linear infinite;
}
@keyframes ozo-spin {
  to { transform: rotate(360deg); }
}

/* iframe 자동 갱신 알림 칩 (2026-05-19 후속: 새로고침 없이 즉시 반영) */
.ozo-agent-reload-notice {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 4px 9px;
  background: linear-gradient(135deg, #ecfeff 0%, #dbeafe 100%);
  border: 1px solid #93c5fd;
  border-radius: 12px;
  color: #1e40af;
  font-size: 10.5px;
  font-weight: 700;
  align-self: flex-start;
}

/* Tool trace 카드 — 단순 회색 chip 한 줄 + 클릭 시 펼치기 (2026-05-19 후속: 최소화) */
.ozo-agent-traces {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  width: 100%;
}
.ozo-agent-trace {
  padding: 5px 9px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 10.5px;
  line-height: 1.4;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ozo-agent-trace:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.ozo-agent-trace.error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}
.ozo-agent-trace.error:hover {
  background: #fee2e2;
}
.ozo-agent-trace-head {
  display: flex;
  align-items: center;
  gap: 5px;
}
.ozo-agent-trace-turn {
  display: inline-block;
  padding: 0 5px;
  background: #e2e8f0;
  color: #475569;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
  flex-shrink: 0;
}
.ozo-agent-trace.error .ozo-agent-trace-turn {
  background: #fee2e2;
  color: #991b1b;
}
.ozo-agent-trace-summary {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ozo-agent-trace-status {
  font-size: 10px;
  flex-shrink: 0;
}
.ozo-agent-trace-toggle {
  font-size: 9px;
  color: #94a3b8;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.ozo-agent-trace.expanded .ozo-agent-trace-toggle {
  transform: rotate(90deg);
}
.ozo-agent-trace-body {
  display: none;
  font-family: 'Inter', 'Consolas', monospace;
  font-size: 10px;
  color: #475569;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  padding-top: 6px;
  margin-top: 5px;
  border-top: 1px dashed #cbd5e1;
}
.ozo-agent-trace.expanded .ozo-agent-trace-body {
  display: block;
}
.ozo-agent-trace.error .ozo-agent-trace-body {
  color: #7f1d1d;
  border-top-color: #fca5a5;
}

/* 입력 폼 */
.ozo-agent-input-form {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.ozo-agent-input {
  flex: 1;
  min-height: 38px;
  max-height: 120px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: #1e293b;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ozo-agent-input:focus {
  border-color: #4338ca;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.ozo-agent-input:disabled {
  background: #f1f5f9;
  color: #94a3b8;
}
.ozo-agent-mic,
.ozo-agent-send {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.ozo-agent-mic {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}
.ozo-agent-mic:hover {
  background: #e2e8f0;
  color: #4338ca;
}
.ozo-agent-mic.listening {
  background: #fef2f2;
  border-color: #ef4444;
  color: #dc2626;
  animation: ozo-pulse 1s infinite;
}
@keyframes ozo-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}
.ozo-agent-send {
  background: linear-gradient(135deg, #0284c7 0%, #4338ca 100%);
  color: #fff;
}
.ozo-agent-send:hover {
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  transform: translateY(-1px);
}
.ozo-agent-send:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 운영·유지보수 보고서 엑셀 다운로드 버튼 */
.ozo-agent-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.ozo-agent-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.ozo-agent-download:hover {
  background: #d1fae5;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}
.ozo-agent-download:active {
  transform: scale(0.97);
}
.ozo-agent-download:disabled {
  opacity: 0.7;
  cursor: default;
  box-shadow: none;
}
