/* 答题系统样式 */
.quiz-container {
  margin: 2em 0;
  padding: 1.5em;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background-color: #f8f5f0; /* 与主题背景色一致 */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.quiz-question {
  margin-bottom: 1.5em;
}

.quiz-title {
  margin: 0 0 1em 0;
  font-size: 1.2em;
  font-weight: 600;
  color: #333;
  line-height: 1.6;
}

/* 确保题目中的代码块正确显示 */
.quiz-title pre {
  margin: 0.8em 0;
  padding: 1em;
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.9em;
}

.quiz-title code {
  background-color: #f5f5f5;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

.quiz-title pre code {
  background-color: transparent;
  padding: 0;
}

.quiz-options {
  margin-bottom: 1.5em;
}

.quiz-option {
  margin: 0.8em 0;
  padding: 0.8em;
  border: 2px solid #ddd;
  border-radius: 6px;
  background-color: #f8f5f0; /* 与主题背景色一致 */
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: flex-start;
}

/* 隐藏 radio 按钮的圆圈 */
.quiz-option input[type="radio"] {
  display: none;
}

.quiz-option:hover {
  border-color: #3498db;
  background-color: #f5f2ed; /* 与主题背景色相近，稍深一点以提供悬停反馈 */
  transform: translateX(5px);
}

.quiz-option-label {
  font-weight: 600;
  color: #3498db;
  margin-right: 0.5em;
  min-width: 2em;
}

.quiz-option-text {
  flex: 1;
  line-height: 1.6;
}

/* 选中状态（通过 JS 添加 .selected 类） */
.quiz-option.selected {
  border-color: #3498db;
  background-color: #e8f4f8;
}

/* 正确状态 */
.quiz-option.correct {
  border-color: #27ae60;
  background-color: #d5f4e6;
}

.quiz-option.correct .quiz-option-label {
  color: #27ae60;
}

/* 错误状态 */
.quiz-option.incorrect {
  border-color: #e74c3c;
  background-color: #fadbd8;
}

.quiz-option.incorrect .quiz-option-label {
  color: #e74c3c;
}

/* 按钮样式 */
.quiz-actions {
  display: flex;
  gap: 0.8em;
  margin-bottom: 1em;
  flex-wrap: wrap;
}

.quiz-btn {
  padding: 0.6em 1.2em;
  border: none;
  border-radius: 4px;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.quiz-submit {
  background-color: #3498db;
  color: white;
}

.quiz-submit:hover {
  background-color: #2980b9;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.quiz-show-answer {
  background-color: #9b59b6;
  color: white;
}

.quiz-show-answer:hover {
  background-color: #8e44ad;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(155, 89, 182, 0.3);
}

.quiz-reset {
  background-color: #95a5a6;
  color: white;
}

.quiz-reset:hover {
  background-color: #7f8c8d;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(149, 165, 166, 0.3);
}

.quiz-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* 结果显示 */
.quiz-result {
  margin-top: 1em;
  padding: 1em;
  border-radius: 6px;
  font-weight: 500;
  display: none;
}

.quiz-result.show {
  display: block;
}

.quiz-result.correct {
  background-color: #d5f4e6;
  color: #27ae60;
  border: 2px solid #27ae60;
}

.quiz-result.incorrect {
  background-color: #fadbd8;
  color: #e74c3c;
  border: 2px solid #e74c3c;
}

.quiz-result-icon {
  margin-right: 0.5em;
  font-size: 1.2em;
}

/* 解释说明 */
.quiz-explanation {
  margin-top: 1em;
  padding: 1em;
  background-color: #fff3cd;
  border-left: 4px solid #ffc107;
  border-radius: 4px;
  display: none;
}

.quiz-explanation.show {
  display: block;
}

.quiz-explanation-title {
  font-weight: 600;
  color: #856404;
  margin-bottom: 0.5em;
}

.quiz-explanation-content {
  color: #856404;
  line-height: 1.6;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .quiz-container {
    padding: 1em;
  }
  
  .quiz-actions {
    flex-direction: column;
  }
  
  .quiz-btn {
    width: 100%;
  }

  .ai-quiz-controls {
    flex-direction: column;
    gap: 1em;
    padding: 1.2em;
  }

  .ai-quiz-control-group {
    min-width: 100%;
  }

  .ai-quiz-select {
    width: 100%;
  }
}

/* AI Quiz section */
.ai-quiz-section {
  margin: 2em 0;
  padding: 1.5em;
  border: 2px dashed #dcdcdc;
  border-radius: 10px;
  background-color: #fdfefe;
}

.ai-quiz-title {
  margin-top: 0;
  font-size: 1.4em;
  color: #2c3e50;
}

.ai-quiz-desc {
  margin: 0.5em 0 1em 0;
  color: #555;
}

.ai-quiz-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5em;
  margin: 1.5em 0;
  padding: 1.5em;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 12px;
  border: 2px solid #e9ecef;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.ai-quiz-controls::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #8e44ad, #3498db, #2ecc71);
  opacity: 0.8;
}

.ai-quiz-control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  flex: 1;
  min-width: 150px;
}

.ai-quiz-control-group label {
  font-weight: 600;
  color: #2c3e50;
  white-space: nowrap;
  font-size: 0.9em;
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.ai-quiz-control-group label::before {
  content: '⚙️';
  font-size: 1em;
}

.ai-quiz-control-group:first-child label::before {
  content: '📊';
}

.ai-quiz-control-group:last-child label::before {
  content: '🔢';
}

.ai-quiz-select {
  padding: 0.75em 1.25em;
  border: 2px solid #e1e8ed;
  border-radius: 8px;
  background: linear-gradient(to bottom, #ffffff, #f8f9fa);
  font-size: 1em;
  font-weight: 500;
  color: #2c3e50;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%233498db' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1em center;
  background-size: 12px;
  padding-right: 2.5em;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ai-quiz-select:hover {
  border-color: #3498db;
  background: linear-gradient(to bottom, #ffffff, #f0f8ff);
  box-shadow: 0 4px 8px rgba(52, 152, 219, 0.15);
  transform: translateY(-1px);
}

.ai-quiz-select:focus {
  outline: none;
  border-color: #3498db;
  background: linear-gradient(to bottom, #ffffff, #f0f8ff);
  box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15), 0 4px 12px rgba(52, 152, 219, 0.2);
  transform: translateY(-1px);
}

.ai-quiz-select option {
  padding: 0.5em;
  background-color: #ffffff;
  color: #2c3e50;
  font-weight: 500;
}

.ai-quiz-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1em;
}

.ai-quiz-button {
  padding: 0.8em 1.6em;
  border: none;
  border-radius: 6px;
  background: linear-gradient(135deg, #8e44ad, #3498db);
  color: #fff;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-quiz-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(52, 152, 219, 0.25);
}

.ai-quiz-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-quiz-status {
  font-size: 0.95em;
  color: #555;
}

.ai-quiz-results {
  margin-top: 1.5em;
  display: flex;
  flex-direction: column;
  gap: 1.5em;
}

/* 悬浮的 AI 考题按钮（默认固定在视口右侧中间） */
/* 只在非主页的页面显示浮动按钮 */
body:not(.home) .ai-quiz-floating-button,
.ai-quiz-floating-button {
  position: fixed;
  top: 50%;
  right: 1.5rem;
  transform: translateY(-50%);
  z-index: 999;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  cursor: grab;
}

/* 确保主页不显示浮动按钮 */
body.home .ai-quiz-floating-button {
  display: none !important;
}

.ai-quiz-floating-button.is-dragging {
  cursor: grabbing;
  transition: none;
}

.ai-quiz-item {
  padding: 1.2em;
  border-radius: 8px;
  background-color: #f8f5f0; /* 与主题背景色一致 */
  border: 1px solid #e1e4e8;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.ai-quiz-item h2,
.ai-quiz-item h3 {
  margin-top: 0;
}

/* 主页 JAVA在线测试 按钮样式 */
.ai-quiz-link-section {
  margin: 1.5em 0;
  padding: 0;
  text-align: center;
  background: transparent;
  border: none;
  box-shadow: none;
  position: relative;
}

.ai-quiz-link-section::before {
  display: none;
}

.ai-quiz-home-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.7em 1.5em;
  background: linear-gradient(135deg, #8e44ad 0%, #3498db 50%, #2ecc71 100%);
  background-size: 200% 200%;
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.95em;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.25);
  position: relative;
  overflow: hidden;
  animation: gradient-animate 3s ease infinite;
}

@keyframes gradient-animate {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.ai-quiz-home-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s;
}

.ai-quiz-home-button:hover::before {
  left: 100%;
}

.ai-quiz-home-button:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 30px rgba(52, 152, 219, 0.4);
}

.ai-quiz-home-button:active {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 8px 25px rgba(52, 152, 219, 0.35);
}

.ai-quiz-button-icon {
  font-size: 1.2em;
  line-height: 1;
  animation: icon-bounce 2s ease-in-out infinite;
}

@keyframes icon-bounce {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-5px) rotate(10deg);
  }
}

.ai-quiz-button-text {
  letter-spacing: 0.05em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.ai-quiz-button-arrow {
  font-size: 1.1em;
  transition: transform 0.3s ease;
  display: inline-block;
}

.ai-quiz-home-button:hover .ai-quiz-button-arrow {
  transform: translateX(5px);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .ai-quiz-link-section {
    margin: 1em 0;
    padding: 0;
  }

  .ai-quiz-home-button {
    padding: 0.6em 1.2em;
    font-size: 0.9em;
    flex-direction: column;
    gap: 0.3em;
  }

  .ai-quiz-button-arrow {
    transform: rotate(90deg);
  }

  .ai-quiz-home-button:hover .ai-quiz-button-arrow {
    transform: rotate(90deg) translateX(5px);
  }
}

