/* =============================================================
   机器人终端（系统管理 → 机器人终端）
   卡片式设备列表：在线/待激活/停用 + 绑定ID + 项目列表
   ============================================================= */

.kx-robot__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.kx-robot__stat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--kx-surface-solid);
  border: 1px solid var(--kx-border-soft);
  border-radius: 16px;
  box-shadow: 0 3px 12px rgba(15, 42, 90, .05);
}

.kx-robot__stat-icon {
  width: 44px;
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  box-shadow: 0 6px 14px rgba(14, 165, 233, .25);
}

.kx-robot__stat.is-green .kx-robot__stat-icon {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 6px 14px rgba(16, 185, 129, .25);
}

.kx-robot__stat.is-orange .kx-robot__stat-icon {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  box-shadow: 0 6px 14px rgba(245, 158, 11, .25);
}

.kx-robot__stat-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.kx-robot__stat-body b {
  font-size: 26px;
  line-height: 1.05;
  font-family: Consolas, monospace;
  color: var(--kx-text);
}

.kx-robot__stat-body span {
  font-size: 12.5px;
  color: var(--kx-text-3);
}

.kx-robot__filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.kx-robot__search {
  flex: 1;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--kx-surface-solid);
  border: 1px solid var(--kx-border);
  border-radius: 12px;
}

.kx-robot__search .kx-icon {
  color: var(--kx-text-3);
  flex: none;
}

.kx-robot__search .kx-input {
  flex: 1;
  height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
}

.kx-robot__tip {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--kx-text-2);
  background: linear-gradient(135deg, rgba(14, 165, 233, .06), rgba(37, 99, 235, .04));
  border: 1px solid var(--kx-info-border);
  border-radius: 14px;
  padding: 11px 14px;
  margin-bottom: 14px;
}

.kx-robot__tip b {
  color: var(--kx-info-text);
}

.kx-robot__tip-icon {
  width: 28px;
  height: 28px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
}

.kx-robot__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr));
  gap: 14px;
  align-items: start;
}

.kx-robot__card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 15px 16px 14px;
  background: var(--kx-surface-solid);
  border: 1px solid var(--kx-border-soft);
  border-radius: 18px;
  box-shadow: 0 3px 14px rgba(15, 42, 90, .05);
  transition: box-shadow .2s, transform .2s;
}

.kx-robot__card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #cbd5e1, #94a3b8);
}

.kx-robot__card:hover {
  box-shadow: 0 10px 26px rgba(15, 42, 90, .1);
  transform: translateY(-2px);
}

.kx-robot__card.is-online::before {
  background: linear-gradient(90deg, #34d399, #10b981, #0ea5e9);
}

.kx-robot__card.is-disabled {
  opacity: .82;
}

.kx-robot__card.is-skeleton {
  height: 210px;
  background: linear-gradient(100deg, #f4f7fc 30%, #eaf0fa 50%, #f4f7fc 70%);
  background-size: 200% 100%;
  animation: kx-robot-skeleton 1.2s ease-in-out infinite;
}

@keyframes kx-robot-skeleton {
  from { background-position: 150% 0; }
  to { background-position: -50% 0; }
}

.kx-robot__head {
  display: flex;
  align-items: center;
  gap: 11px;
}

.kx-robot__icon {
  width: 42px;
  height: 42px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  box-shadow: 0 6px 14px rgba(14, 165, 233, .28);
}

.kx-robot__card.is-online .kx-robot__icon {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 6px 14px rgba(16, 185, 129, .28);
}

.kx-robot__name {
  flex: 1;
  min-width: 0;
}

.kx-robot__name b {
  display: block;
  font-size: 15px;
  color: var(--kx-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kx-robot__no {
  margin-top: 2px;
  font-family: Consolas, monospace;
  font-size: 11.5px;
  color: var(--kx-text-3);
}

.kx-robot__chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
}

.kx-robot__chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.kx-robot__chip.is-on {
  color: var(--kx-success-text);
  background: var(--kx-success-soft);
}

.kx-robot__chip.is-on .dot {
  background: var(--kx-success);
  animation: kx-robot-pulse 1.8s infinite;
}

.kx-robot__chip.is-off {
  color: #64748b;
  background: #f1f5f9;
}

.kx-robot__chip.is-off .dot {
  background: #94a3b8;
}

.kx-robot__chip.is-stop {
  color: #94a3b8;
  background: #f8fafc;
  border: 1px dashed var(--kx-border);
}

.kx-robot__chip.is-stop .dot {
  background: #cbd5e1;
}

@keyframes kx-robot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .45); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.kx-robot__bid {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.5;
  color: #047857;
  background: linear-gradient(135deg, rgba(16, 185, 129, .09), rgba(5, 150, 105, .05));
  border: 1px solid rgba(16, 185, 129, .28);
  border-radius: 11px;
}

.kx-robot__bid b {
  font-family: Consolas, monospace;
  letter-spacing: 2px;
}

.kx-robot__bid span:last-child {
  color: #0f766e;
}

.kx-robot__note {
  display: flex;
  gap: 7px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--kx-text-3);
  background: #fbfcfe;
  border-radius: 10px;
  padding: 7px 10px;
}

.kx-robot__note .kx-icon {
  margin-top: 2px;
  flex: none;
  color: #94a3b8;
}

.kx-robot__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kx-robot__pill {
  flex: 1 1 auto;
  min-width: 82px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 8px;
  border: 0;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  white-space: nowrap;
  cursor: pointer;
  transition: filter .15s, transform .12s, box-shadow .15s;
}

.kx-robot__pill:hover {
  filter: brightness(1.08);
  box-shadow: 0 5px 12px rgba(15, 42, 90, .16);
}

.kx-robot__pill:active {
  transform: scale(.96);
}

.kx-robot__pill.is-copy {
  background: linear-gradient(135deg, #10b981, #059669);
}

.kx-robot__pill.is-edit {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
}

.kx-robot__pill.is-warn {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
}

.kx-robot__pill.is-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.kx-robot__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--kx-primary-border);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(14, 165, 233, .08), rgba(37, 99, 235, .04));
  color: var(--kx-info-text);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.kx-robot__toggle:hover {
  background: rgba(14, 165, 233, .16);
  border-color: rgba(14, 165, 233, .6);
}

.kx-robot__chevron {
  display: inline-flex;
  transition: transform .18s ease;
}

.kx-robot__toggle.is-open .kx-robot__chevron {
  transform: rotate(180deg);
}

.kx-robot__projects {
  border-top: 1px dashed var(--kx-border-soft);
  padding-top: 11px;
  animation: kx-robot-fade .18s ease;
}

@keyframes kx-robot-fade {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}

.kx-robot__hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--kx-text-3);
  background: #fbfcff;
  border: 1px dashed var(--kx-border-soft);
  border-radius: 10px;
  padding: 10px 12px;
}

.kx-robot__hint.is-error {
  color: var(--kx-danger-text);
  background: #fff7f7;
  border-color: var(--kx-danger-border);
}

.kx-robot__hint .is-spin {
  animation: kx-robot-spin 1s linear infinite;
  flex: none;
}

@keyframes kx-robot-spin {
  to { transform: rotate(360deg); }
}

.kx-robot__projects-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--kx-text-3);
  margin-bottom: 7px;
}

.kx-robot__projects-head > span {
  display: inline-flex;
  align-items: center;
  color: var(--kx-info-text);
  font-weight: 600;
}

.kx-robot__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--kx-info-text);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.kx-robot__project-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 238px;
  overflow-y: auto;
}

.kx-robot__project {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  background: #f8fbff;
  border: 1px solid var(--kx-border-soft);
  border-radius: 10px;
  font-size: 13px;
  color: var(--kx-text);
}

.kx-robot__project > .kx-icon {
  flex: none;
  color: #38bdf8;
}

.kx-robot__project-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kx-robot__project-meta {
  flex: none;
  font-size: 11px;
  font-family: Consolas, monospace;
  color: var(--kx-text-3);
}

/* 项目行可点击：打开机器人终端 */
.kx-robot__project.is-clickable {
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}

.kx-robot__project.is-clickable:hover {
  background: #eef7ff;
  border-color: rgba(14, 165, 233, .55);
  box-shadow: 0 4px 12px rgba(14, 165, 233, .12);
}

.kx-robot__project-go {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  color: #0284c7;
  background: rgba(14, 165, 233, .1);
  opacity: .75;
  transition: opacity .15s, background .15s;
}

.kx-robot__project.is-clickable:hover .kx-robot__project-go {
  opacity: 1;
  background: rgba(14, 165, 233, .2);
}

/* 机器人终端弹层：iframe 撑满，去掉内边距 */
.kx-robot__terminal-modal .kx-modal__body {
  padding: 0;
  background: #0f172a;
}

.kx-robot__terminal-modal .kx-modal__head {
  background: #0f172a;
  border-bottom-color: #334155;
}

.kx-robot__terminal-modal .kx-modal__title {
  color: #e2e8f0;
}

.kx-robot__terminal-frame {
  display: block;
  width: 100%;
  height: min(calc(84vh - 64px), 780px);
  border: 0;
  border-radius: 0 0 var(--kx-radius-xl) var(--kx-radius-xl);
  background: #0f172a;
}

/* 添加 / 编辑弹窗 */
.kx-robot__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kx-robot__form-hint {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12px;
  line-height: 1.8;
  color: var(--kx-text-2);
  background: #f6faff;
  border: 1px solid #e3eefc;
  border-radius: 10px;
  padding: 9px 12px;
}

.kx-robot__form-hint .kx-icon {
  flex: none;
  margin-top: 3px;
  color: var(--kx-info);
}

.kx-robot__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kx-robot__field label {
  font-size: 12px;
  color: var(--kx-text-3);
}

.kx-robot__field .kx-input {
  width: 100%;
  box-sizing: border-box;
}

.kx-robot__field textarea.kx-input {
  resize: vertical;
}
