/* ============================================
   AI制造车间调度系统 - 组件样式
   ============================================ */

/* === 插单面板 === */
.insertion-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.insertion-card__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.insertion-card__textarea {
  width: 100%;
  min-height: 120px;
  padding: var(--space-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  resize: vertical;
  transition: all var(--transition-fast);
  line-height: 1.6;
}

.insertion-card__textarea::placeholder {
  color: var(--text-muted);
}

.insertion-card__textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.1);
}

.insertion-card__actions {
  display: flex;
  gap: var(--space-sm);
}

.insertion-card__submit {
  flex: 1;
  padding: 10px 20px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.insertion-card__voice {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.insertion-card__voice.is-listening {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  animation: voice-pulse 1.5s ease-in-out infinite;
}

@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(91, 141, 239, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(91, 141, 239, 0); }
}

/* === 进度条 === */
.progress-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.progress-bar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-bar__status {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.progress-bar__percent {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.progress-bar__track {
  width: 100%;
  height: 3px;
  background: var(--divider);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-muted));
  border-radius: 2px;
  transition: width 300ms ease-out;
}

.progress-bar__fill.is-complete {
  background: var(--success);
}

.progress-bar__fill.is-error {
  background: var(--error);
}

.progress-bar__message {
  font-size: var(--text-xs);
  color: var(--text-muted);
  min-height: 16px;
}

.progress-bar.is-idle {
  opacity: 0;
  pointer-events: none;
}

.progress-bar.is-active {
  opacity: 1;
}

/* === 数据表格 === */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table thead th {
  position: sticky;
  top: 0;
  padding: 10px var(--space-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table thead th:hover {
  color: var(--text-secondary);
}

.data-table thead th .sort-arrow {
  margin-left: 4px;
  opacity: 0.4;
  font-size: 10px;
}

.data-table thead th.is-sorted .sort-arrow {
  opacity: 1;
  color: var(--primary);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--divider);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--surface-hover);
}

.data-table tbody tr.is-selected {
  background: var(--primary-soft);
}

.data-table tbody td {
  padding: 10px var(--space-sm);
  color: var(--text-primary);
  white-space: nowrap;
}

.data-table tbody td.mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

/* === 紧凑订单表格 === */
.data-table--compact tbody td {
  padding: 8px var(--space-sm);
}

.order-progress {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.order-progress__label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.order-detail-btn {
  padding: 2px 8px;
  font-size: 11px;
}

.order-detail-row {
  background: var(--bg);
}

.order-detail-row:hover {
  background: var(--bg) !important;
}

.order-detail {
  padding: var(--space-sm) var(--space-md);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
}

.order-detail__row {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.order-detail__row span:last-child {
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}

/* === 状态标签 === */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: 100px;
  line-height: 1.6;
}

.status-tag--done {
  background: #e5f0e8;
  color: #4a8a5e;
}

.status-tag--running {
  background: #e8eefb;
  color: #5b8def;
}

.status-tag--planned {
  background: #f0ece4;
  color: #9a8a6a;
}

.status-tag--delayed {
  background: var(--kpi-soft);
  color: var(--kpi);
}

.status-tag--waiting {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-tag--urgent {
  background: var(--kpi-soft);
  color: var(--kpi);
  font-weight: var(--weight-semibold);
}

.status-tag--success {
  background: var(--success-soft);
  color: var(--success);
}

.status-tag--error {
  background: var(--error-soft);
  color: var(--error);
}

/* === 圆环进度 === */
.ring-progress {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.ring-progress__svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-progress__bg {
  fill: none;
  stroke: var(--divider);
  stroke-width: 3;
}

.ring-progress__fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 500ms ease-out;
}

.ring-progress__text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* === 产线负载卡片 === */
.load-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: box-shadow var(--transition-fast);
}

.load-card:hover {
  box-shadow: var(--shadow-md);
}

.load-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.load-card__name {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
}

.load-card__value {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
}

.load-card__track {
  width: 100%;
  height: 6px;
  background: var(--divider);
  border-radius: 3px;
  overflow: hidden;
}

.load-card__fill {
  height: 100%;
  border-radius: 3px;
  transition: width 500ms ease-out;
}

/* === 时间线 === */
.timeline {
  position: relative;
  padding-left: var(--space-lg);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: var(--border);
}

.timeline__item {
  position: relative;
  padding-bottom: var(--space-md);
}

.timeline__item:last-child {
  padding-bottom: 0;
}

.timeline__dot {
  position: absolute;
  left: calc(-1 * var(--space-lg) + 2px);
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  background: var(--primary-muted);
}

.timeline__dot.is-success {
  background: var(--success);
  box-shadow: 0 0 0 1px var(--success);
}

.timeline__dot.is-error {
  background: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.timeline__time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 2px;
}

.timeline__content {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.timeline__detail {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
  display: none;
}

.timeline__item.is-expanded .timeline__detail {
  display: block;
}

/* === 空状态 === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-muted);
  text-align: center;
}

.empty-state__icon {
  margin-bottom: var(--space-sm);
  opacity: 0.4;
}

.empty-state__text {
  font-size: var(--text-sm);
}

/* === Toast 通知 === */
.toast-container {
  position: fixed;
  top: 72px;
  right: var(--space-lg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.toast {
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
  animation: toast-in 300ms ease-out;
}

.toast--success { border-left: 3px solid var(--success); }
.toast--error { border-left: 3px solid var(--error); }
.toast--info { border-left: 3px solid var(--info); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === 聊天对话 === */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--space-lg);
  gap: var(--space-md);
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-right: var(--space-xs);
  min-height: 0;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 90%;
  animation: msg-in 200ms ease-out;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg--user {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg--system {
  align-self: flex-start;
  align-items: flex-start;
  flex-direction: row;
  gap: var(--space-sm);
}

.chat-msg--error {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-msg__icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-msg__content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.chat-msg__bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: var(--text-sm);
  line-height: 1.6;
  word-break: break-word;
}

.chat-msg--user .chat-msg__bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg--system .chat-msg__bubble {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-msg--error .chat-msg__bubble {
  background: var(--error-soft);
  color: var(--error);
  border-bottom-left-radius: 4px;
}

.chat-msg__time {
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 4px;
}

.chat-msg__progress {
  width: 100%;
  height: 3px;
  background: var(--divider);
  border-radius: 2px;
  overflow: hidden;
}

.chat-msg__progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 300ms ease-out;
}

/* === 底部固定输入框（大模型风格） === */
.chat-input-wrapper {
  flex-shrink: 0;
  padding-top: var(--space-sm);
  background: var(--surface);
  border-top: 1px solid var(--divider);
}

.chat-input-box {
  display: flex;
  align-items: flex-end;
  gap: var(--space-xs);
  padding: var(--space-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-input-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.08);
}

.chat-textarea {
  flex: 1;
  padding: 6px 4px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: transparent;
  border: none;
  resize: none;
  line-height: 1.5;
  max-height: 120px;
  min-height: 24px;
}

.chat-textarea:focus {
  outline: none;
}

.chat-textarea::placeholder {
  color: var(--text-muted);
}

.chat-input-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding-bottom: 2px;
}

.chat-toolbar-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chat-toolbar-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.chat-toolbar-btn.is-listening {
  color: var(--primary);
  animation: voice-pulse 1.5s ease-in-out infinite;
}

.chat-send-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chat-send-btn:hover {
  background: var(--accent);
}

.chat-send-btn:active {
  transform: scale(0.92);
}

.chat-input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 0;
}

/* === 可折叠面板 === */
.section-card.is-collapsed .section-card__body {
  max-height: 100px;
  overflow-y: auto;
}

.section-card.is-collapsed .section-card__title::after {
  content: ' ▼';
  font-size: 10px;
  color: var(--text-muted);
}

.section-card__title {
  cursor: pointer;
  user-select: none;
}

.section-card__title::after {
  content: ' ▲';
  font-size: 10px;
  color: var(--text-muted);
}

/* === 甘特图控制栏 === */
.gantt-controls {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
  padding: var(--space-xs) 0;
}

.gantt-controls__btn {
  padding: 4px 10px;
  font-size: var(--text-xs);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.gantt-controls__btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.gantt-controls__btn svg {
  vertical-align: middle;
}

/* === 甘特图底部独立滑动条 === */
.gantt-scrollbar {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border-top: 1px solid var(--divider);
  background: var(--surface);
}

.gantt-scrollbar__btn {
  padding: 2px 8px;
  font-size: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.gantt-scrollbar__btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.gantt-scrollbar__track {
  flex: 1;
  height: 16px;
  background: var(--border);
  border-radius: 8px;
  position: relative;
  cursor: pointer;
}

.gantt-scrollbar__thumb {
  position: absolute;
  top: 2px;
  left: 0%;
  width: 60px;
  height: 12px;
  background: var(--text-muted);
  border-radius: 6px;
  cursor: grab;
  transition: background var(--transition-fast);
  transform: translateX(-50%);
}

.gantt-scrollbar__thumb:hover {
  background: var(--text-secondary);
}

.gantt-scrollbar__thumb:active {
  cursor: grabbing;
  background: var(--text-primary);
}

/* === 面板切换按钮（移动端） === */
.panel-toggle {
  display: none;
}

@media (max-width: 1279px) {
  .panel-toggle {
    display: inline-flex;
  }
}
