/* =====================================================
 * Opilot — 前端样式
 * 下拉面板 + 命令面板 + Toast + 预填横幅
 * ===================================================== */

/* ============ 下拉面板（双列）============ */
.opilot-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(20, 20, 30, 0.96);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  max-height: 60vh;
  overflow: hidden;
  color: #e2e8f0;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.opilot-dropdown.open {
  display: flex;
}
.opilot-col {
  flex: 1;
  min-width: 0;
  padding: 12px;
  overflow-y: auto;
  max-height: 60vh;
}
.opilot-col + .opilot-col {
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}
.opilot-col-full {
  flex: 1 1 100%;
}
.opilot-col h4 {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 8px;
}
.opilot-col-keyword h4::before {
  content: "🔍 ";
}
.opilot-col-ai h4 {
  color: #a78bfa;
}
.opilot-col-ai h4::before {
  content: "✨ ";
}

/* ============ 工具卡片 ============ */
.opilot-tool-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.opilot-tool-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.opilot-tool-card:hover {
  background: rgba(99, 102, 241, 0.15);
}
.opilot-tool-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.opilot-tool-info {
  flex: 1;
  min-width: 0;
}
.opilot-tool-name {
  font-size: 14px;
  font-weight: 500;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 6px;
}
.opilot-tool-conf {
  font-size: 10px;
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.opilot-tool-reason {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.opilot-tool-arrow {
  color: #64748b;
  font-size: 16px;
}

/* ============ Opilot 区内容 ============ */
.opilot-ai-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.opilot-section-label {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 4px;
}
.opilot-reply {
  font-size: 13px;
  color: #cbd5e1;
  padding: 8px 10px;
  background: rgba(99, 102, 241, 0.08);
  border-left: 2px solid #a78bfa;
  border-radius: 4px;
  line-height: 1.5;
}
.opilot-launch-btn,
.opilot-chat-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.opilot-launch-btn:hover,
.opilot-chat-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}
.opilot-launch-btn:active,
.opilot-chat-btn:active {
  transform: translateY(0);
}
.opilot-chat-btn {
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.opilot-loading {
  text-align: center;
  padding: 20px;
  color: #a78bfa;
  font-size: 13px;
  animation: opilot-pulse 1.4s ease-in-out infinite;
}
@keyframes opilot-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
.opilot-degraded {
  font-size: 12px;
  color: #fbbf24;
  padding: 8px 10px;
  background: rgba(251, 191, 36, 0.1);
  border-radius: 6px;
  text-align: center;
}
.opilot-empty {
  text-align: center;
  color: #64748b;
  padding: 30px;
  font-size: 13px;
}
.opilot-empty-mini {
  text-align: center;
  color: #64748b;
  padding: 12px;
  font-size: 12px;
}

/* ============ 历史记录 ============ */
.opilot-history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.opilot-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #cbd5e1;
  transition: background 0.15s;
}
.opilot-history-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.opilot-history-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.opilot-history-q {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.opilot-history-time {
  font-size: 11px;
  color: #64748b;
  flex-shrink: 0;
}

/* ============ Toast（B2 降级提示）============ */
.opilot-toast-host {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.opilot-toast {
  background: rgba(20, 20, 30, 0.95);
  color: #fbbf24;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  font: 14px/1.4 system-ui, -apple-system, sans-serif;
  max-width: 360px;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
}
.opilot-toast.show {
  opacity: 1;
  transform: translateX(0);
}
.opilot-toast.hide {
  opacity: 0;
  transform: translateX(20px);
}
.opilot-toast-error {
  border-color: rgba(248, 81, 73, 0.3);
  color: #f87171;
}
.opilot-toast-info {
  border-color: rgba(96, 165, 250, 0.3);
  color: #60a5fa;
}

/* ============ 命令面板（主站）============ */
.opilot-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  animation: opilot-fade-in 0.2s ease;
}
.opilot-palette-overlay.hide {
  animation: opilot-fade-out 0.2s ease;
}
@keyframes opilot-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes opilot-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
.opilot-palette {
  width: 640px;
  max-width: 90vw;
  background: rgba(30, 30, 40, 0.98);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  color: #e2e8f0;
  font: 14px/1.4 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.opilot-palette-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(99, 102, 241, 0.04);
}
.opilot-palette-input {
  width: 100%;
  padding: 18px 20px;
  background: transparent;
  border: none;
  color: white;
  font-size: 16px;
  outline: none;
}
.opilot-palette-input::placeholder {
  color: #64748b;
}
.opilot-palette-hint {
  display: flex;
  gap: 16px;
  padding: 8px 20px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 11px;
  color: #64748b;
}
.opilot-palette-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 8px 0;
}
.opilot-palette-section {
  padding: 6px 0;
}
.opilot-palette-eyebrow {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 20px 4px;
  font-weight: 600;
}
.opilot-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.1s;
}
.opilot-palette-item:hover,
.opilot-palette-item.active {
  background: rgba(99, 102, 241, 0.2);
}
.opilot-palette-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.opilot-palette-item-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.opilot-palette-site {
  margin-left: auto;
  font-size: 11px;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}
.opilot-palette-conf {
  font-size: 10px;
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  flex-shrink: 0;
}
.opilot-palette-history {
  color: #94a3b8;
}
.opilot-palette-empty {
  text-align: center;
  padding: 30px 20px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.6;
}
.opilot-palette-empty kbd {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  font: 11px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  color: #cbd5e1;
  margin: 0 2px;
}
.opilot-palette-loading {
  text-align: center;
  padding: 30px;
  color: #a78bfa;
  font-size: 13px;
  animation: opilot-pulse 1.4s ease-in-out infinite;
}
.opilot-palette-reply {
  margin: 8px 20px 4px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  color: #cbd5e1;
  background: rgba(99, 102, 241, 0.08);
  border-left: 2px solid #a78bfa;
  border-radius: 4px;
}
.opilot-palette-degraded {
  margin: 8px 20px 4px;
  padding: 8px 12px;
  font-size: 12px;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border-radius: 6px;
  text-align: center;
}
.opilot-palette-launch-btn {
  display: block;
  width: calc(100% - 40px);
  margin: 8px 20px 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
}
.opilot-palette-launch-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}
.opilot-palette-launch-btn:active {
  transform: translateY(0);
}

/* ============ 预填横幅 + 输入高亮 ============ */
.opilot-prefill-banner {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.95), rgba(236, 72, 153, 0.95));
  color: white;
  padding: 10px 20px;
  border-radius: 100px;
  font: 13px/1.4 system-ui, -apple-system, "PingFang SC", sans-serif;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.opilot-prefill-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.opilot-prefill-banner code {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  margin-left: 6px;
}
.opilot-prefilled {
  animation: opilot-prefill-pulse 1s ease;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3) !important;
}
@keyframes opilot-prefill-pulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5) !important; }
  100% { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0) !important; }
}

/* ============ 主站 Opilot 触发按钮 ============ */
.opilot-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.2));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 100px;
  color: #cbd5e1;
  font: 13px/1 system-ui, -apple-system, "PingFang SC", sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}
.opilot-trigger:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(236, 72, 153, 0.3));
  border-color: rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}
.opilot-trigger-icon {
  font-size: 14px;
}
.opilot-trigger kbd {
  font: 10px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  color: #94a3b8;
  margin-left: 4px;
}

/* ============ 子站头部 Opilot 按钮 ============ */
.opilot-panel-btn-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.2));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 100px;
  color: inherit;
  font: 13px/1 inherit;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.opilot-panel-btn-header:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(236, 72, 153, 0.3));
  border-color: rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}
.opilot-panel-btn-header kbd {
  font: 10px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 5px;
  border-radius: 3px;
  color: #94a3b8;
  margin-left: 2px;
}
@media (max-width: 768px) {
  .opilot-panel-btn-header .opilot-trigger-text,
  .opilot-panel-btn-header kbd {
    display: none;
  }
}

/* ============ 移动端适配 ============ */
@media (max-width: 640px) {
  .opilot-dropdown {
    max-height: 70vh;
  }
  .opilot-dropdown.open {
    flex-direction: column;
  }
  .opilot-col + .opilot-col {
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .opilot-palette {
    max-width: 95vw;
  }
  .opilot-toast-host {
    top: 16px;
    right: 16px;
    left: 16px;
  }
  .opilot-toast {
    max-width: none;
  }
  .opilot-prefill-banner {
    top: 60px;
    font-size: 12px;
    padding: 8px 14px;
  }
}
