/**
 * AI Copilot+ v1.5 样式
 */

/* 基础浮动图标 */
.floating-copilot {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 9999;
}

.floating-copilot-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
  position: relative;
}

.floating-copilot-icon:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

.voice-indicator {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  background: #4CAF50;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 2px solid white;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* 聊天窗口 */
.floating-copilot-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 450px;
  height: 600px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s ease, height 0.3s ease, bottom 0.3s ease, transform 0.3s ease;
}

.floating-copilot.expanded .floating-copilot-window {
  display: flex;
}

/* 头部 */
.floating-copilot-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-left h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.version-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.voice-toggle-btn,
.mode-toggle-btn,
.floating-copilot-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 18px;
  padding: 5px;
  transition: all 0.2s;
}

.voice-toggle-btn:hover,
.mode-toggle-btn:hover {
  transform: scale(1.1);
}

.mode-toggle-btn.active {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.floating-copilot-close {
  font-size: 24px;
}

.floating-copilot-close:hover {
  transform: rotate(90deg);
}

/* 内容区域 */
.floating-copilot-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.floating-copilot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
}

/* 欢迎消息 */
.welcome-message {
  text-align: center;
  padding: 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.welcome-message p {
  margin: 5px 0;
  color: #333;
}

.feature-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 15px;
}

.feature-badges .badge {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 5px 12px;
  border-radius: 15px;
  font-size: 12px;
}

/* 消息样式 */
.message {
  margin-bottom: 15px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-message {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.user-message .message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 10px 15px;
  border-radius: 18px 18px 0 18px;
  max-width: 70%;
  word-wrap: break-word;
}

.assistant-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.assistant-message .message-content {
  background: white;
  color: #333;
  padding: 10px 15px;
  border-radius: 18px 18px 18px 0;
  max-width: 70%;
  word-wrap: break-word;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.voice-badge {
  background: #4CAF50;
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 12px;
}

.message-time {
  font-size: 11px;
  color: #999;
  margin-top: 3px;
}

.speak-btn {
  background: #f0f0f0;
  border: none;
  padding: 5px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 12px;
  color: #666;
  transition: all 0.2s;
}

.speak-btn:hover {
  background: #e0e0e0;
  color: #333;
}

/* 操作结果卡片 */
.operation-result {
  margin-bottom: 15px;
  animation: slideIn 0.3s ease;
}

.result-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.result-header {
  background: #f5f5f5;
  padding: 10px 15px;
  font-weight: 600;
  border-bottom: 1px solid #e0e0e0;
}

.result-body {
  padding: 15px;
}

.result-body p {
  margin: 8px 0;
  font-size: 14px;
}

.result-body strong {
  color: #667eea;
}

.alert-item {
  padding: 8px;
  margin: 5px 0;
  background: #f9f9f9;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-level {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.level-high {
  background: #ffebee;
  color: #c62828;
}

.level-medium {
  background: #fff3e0;
  color: #ef6c00;
}

.level-low {
  background: #e8f5e9;
  color: #2e7d32;
}

/* 快捷操作 */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 15px;
  background: white;
  border-top: 1px solid #e0e0e0;
}

.quick-action-btn {
  padding: 6px 12px;
  border: 1px solid #667eea;
  background: white;
  color: #667eea;
  border-radius: 15px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.quick-action-btn:hover {
  background: #667eea;
  color: white;
}

/* 输入区域 */
.floating-copilot-input-area {
  border-top: 1px solid #e0e0e0;
  background: white;
}

.input-wrapper {
  display: flex;
  gap: 10px;
  padding: 15px;
}

#floatingQuestionInput {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  resize: none;
  font-family: inherit;
}

#floatingQuestionInput:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#floatingSendBtn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

#floatingSendBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#floatingSendBtn:active {
  transform: translateY(0);
}

/* 处理指示器 */
.processing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  background: #f5f5f5;
  border-radius: 8px;
  margin-bottom: 15px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 错误消息 */
.error-message {
  background: #ffebee;
  color: #c62828;
  padding: 10px 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
}

/* 滚动条样式 */
.floating-copilot-messages::-webkit-scrollbar {
  width: 6px;
}

.floating-copilot-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.floating-copilot-messages::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.floating-copilot-messages::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* 响应式设计 */
@media (max-width: 768px) {
  /* 调整浮动图标的位置和大小 */
  .floating-copilot {
    bottom: 20px;
    right: 20px;
  }

  .floating-copilot-icon {
    width: 50px;
    height: 50px;
  }

  /* 聊天窗口适配手机屏幕 */
  .floating-copilot-window {
    width: calc(100vw - 40px); /* 宽度为屏幕宽度减去40px，左右各20px边距 */
    height: calc(100vh - 120px); /* 保持较高高度以显示更多内容 */
    bottom: 70px; /* 距离底部70px */
    right: 20px; /* 距离右侧20px */
  }

  /* 消息气泡占据更大宽度 */
  .user-message .message-content,
  .assistant-message .message-content {
    max-width: 85%;
  }

  /* 调整头部按钮大小 */
  .voice-toggle-btn,
  .mode-toggle-btn,
  .floating-copilot-close {
    font-size: 18px;
    padding: 8px;
  }

  /* 欢迎消息调整 */
  .welcome-message {
    padding: 15px;
  }

  .feature-badges {
    gap: 6px;
  }

  .feature-badges .badge {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* 调整快捷操作按钮 */
  .quick-actions {
    gap: 6px;
    padding: 10px 15px;
  }

  .quick-action-btn {
    padding: 8px 12px;
    font-size: 12px;
  }

  /* 输入区域适配 */
  .input-wrapper {
    gap: 8px;
    padding: 12px;
  }

  #floatingQuestionInput {
    padding: 12px;
    font-size: 15px;
    min-height: 44px;
  }

  #floatingSendBtn {
    padding: 10px 18px;
    font-size: 14px;
  }
}

/* 小屏手机额外调整 */
@media (max-width: 480px) {
  .floating-copilot {
    bottom: 15px;
    right: 15px;
  }

  .floating-copilot-window {
    width: calc(100vw - 40px); /* 保持与768px以下一致的宽度 */
    height: calc(100vh - 100px); /* 略低一点的高度 */
    bottom: 60px;
    right: 20px; /* 保持与768px以下一致的右侧边距 */
  }

  /* 快捷操作按钮在小屏上改为两行显示 */
  .quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .quick-action-btn {
    flex: none;
    text-align: center;
  }

  /* 调整消息样式 */
  .message-time {
    font-size: 10px;
  }
}

/* 横屏模式适配 */
@media (max-height: 500px) and (orientation: landscape) {
  .floating-copilot-window {
    height: calc(100vh - 80px);
    /* 保持原有宽度，不修改定位 */
  }

  .floating-copilot-messages {
    max-height: calc(100vh - 200px);
  }
}

/* 深色模式 */
@media (prefers-color-scheme: dark) {
  .floating-copilot-window {
    background: #2d2d2d;
  }

  .floating-copilot-messages {
    background: #1e1e1e;
  }

  .welcome-message {
    background: #3a3a3a;
    color: #e0e0e0;
  }

  .assistant-message .message-content {
    background: #3a3a3a;
    color: #e0e0e0;
  }

  .result-card {
    background: #3a3a3a;
  }

  .result-header {
    background: #4a4a4a;
    border-bottom-color: #5a5a5a;
    color: #e0e0e0;
  }

  .result-body {
    color: #e0e0e0;
  }

  .floating-copilot-input-area,
  .quick-actions {
    background: #2d2d2d;
    border-top-color: #4a4a4a;
  }

  #floatingQuestionInput {
    background: #3a3a3a;
    color: #e0e0e0;
    border-color: #5a5a5a;
  }

  .quick-action-btn {
    background: #3a3a3a;
    color: #667eea;
    border-color: #667eea;
  }

  .quick-action-btn:hover {
    background: #667eea;
    color: white;
  }
}
