/* ============================================================
 * 全局样式 + 布局 + 顶部导航 + 出题规则面板
 * （从 App.vue / ExamBuilder.vue / NavSteps.vue / RulePanel.vue 迁移）
 * ============================================================ */

/* ---------- 全局（原 App.vue） ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  width: 100%;
  height: 100%;
}

/* ---------- 页面布局（原 ExamBuilder.vue） ---------- */
.exam-builder {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #ebeef5;
}

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.left-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 2px solid #dcdfe6;
  background: #fff;
}

.panel-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #f5f7fa;
  border-bottom: 1px solid #e4e7ed;
}

.panel-toolbar h3 {
  margin: 0;
  font-size: 16px;
  color: #303133;
}

.panel-toolbar .toolbar-buttons {
  display: flex;
  gap: 10px;
}

.btn-print {
  padding: 8px 16px;
  background: #409eff;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.btn-print:hover:not(:disabled) {
  background: #66b1ff;
}

.btn-print:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.paper-container {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: flex;
  justify-content: center;
  background: #ebeef5;
}

.right-panel {
  width: 400px;
  flex-shrink: 0;
  background: #fff;
  /* 纵向弹性布局：约束内部容器高度，保证规则面板可滚动 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 规则面板容器：撑满右栏，使内部 .rule-panel 的百分比高度与滚动生效 */
#rule-panel-container {
  flex: 1;
  min-height: 0;
}

@media screen and (max-width: 1200px) {
  .main-content {
    flex-direction: column;
  }

  /* 左右面板平分剩余高度（减去导航栏），各自内部滚动，避免总高超出视口 */
  .left-panel {
    border-right: none;
    border-bottom: 2px solid #dcdfe6;
    min-height: 0;
  }

  .right-panel {
    width: 100%;
    height: auto;
    flex: 1;
    min-height: 0;
  }
}

/* ---------- 顶部导航（原 NavSteps.vue） ---------- */
.nav-bar {
  background: #fff;
  border-bottom: 1px solid #e4e7ed;
  padding: 15px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.logo .logo-icon {
  font-size: 28px;
}

.logo .logo-text {
  font-size: 22px;
  font-weight: bold;
  color: #303133;
}

.nav-steps {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
}

.step {
  display: flex;
  gap: 12px;
}

/* 注意顺序：current < active < disabled，与原版 SCSS 一致（后定义者优先级相同靠后者覆盖） */
.step-number {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #e4e7ed;
  color: #909399;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  flex-shrink: 0;
}

.step-number.current {
  background: #409eff;
  color: #fff;
}

.step-number.active {
  background: #67c23a;
  color: #fff;
}

.step-number.disabled {
  opacity: 0.5;
}

.step-content {
  flex: 1;
  min-width: 200px;
}

.step-title {
  display: block;
  font-size: 13px;
  color: #909399;
  margin-bottom: 8px;
}

.subject-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.subject-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: #606266;
  transition: all 0.3s;
}

.subject-btn:hover {
  border-color: #409eff;
  color: #409eff;
}

.subject-btn.active {
  background: #409eff;
  border-color: #409eff;
  color: #fff;
}

.subject-btn .subject-icon {
  font-size: 16px;
}

.stage-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-btn {
  padding: 5px 12px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: #606266;
  transition: all 0.3s;
}

.stage-btn:hover {
  border-color: #67c23a;
  color: #67c23a;
}

.stage-btn.active {
  background: #67c23a;
  border-color: #67c23a;
  color: #fff;
}

.selected-type {
  display: inline-block;
  padding: 4px 10px;
  background: #e6a23c;
  color: #fff;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
}

.placeholder {
  font-size: 12px;
  color: #c0c4cc;
}

/* ---------- 出题规则面板（原 RulePanel.vue） ---------- */
.rule-panel {
  padding: 20px;
  overflow-y: auto;
  height: 100%;
  background: #f5f7fa;
}

.panel-header {
  margin-bottom: 20px;
}

.panel-header h2 {
  font-size: 20px;
  color: #333;
  margin: 0 0 10px 0;
}

.current-selection {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 4px 12px;
  background: #e8f4fd;
  color: #409eff;
  border-radius: 4px;
  font-size: 13px;
}

.tag.stage-tag {
  background: #f0f9eb;
  color: #67c23a;
}

.tag.type-tag {
  background: #fdf6ec;
  color: #e6a23c;
}

.section {
  margin-bottom: 20px;
  background: #fff;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.section-title {
  font-size: 15px;
  color: #606266;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #ebeef5;
}

.type-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.3s;
}

.type-select:focus {
  outline: none;
  border-color: #409eff;
}

.count-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.count-btn {
  padding: 10px;
  border: 2px solid #dcdfe6;
  border-radius: 6px;
  background: #fff;
  color: #606266;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.3s;
}

.count-btn:hover {
  border-color: #409eff;
  color: #409eff;
}

.count-btn.active {
  border-color: #409eff;
  background: #409eff;
  color: #fff;
}

.rules-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.rule-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rule-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.rule-name {
  font-size: 14px;
  font-weight: bold;
  color: #303133;
}

.rule-desc {
  font-size: 12px;
  color: #909399;
}

.rule-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.3s;
}

.rule-input:focus {
  outline: none;
  border-color: #409eff;
}

.rule-input.small {
  width: 80px;
  text-align: center;
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.separator {
  color: #909399;
}

.rule-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  font-size: 14px;
  background: #fff;
}

.rule-select:focus {
  outline: none;
  border-color: #409eff;
}

.custom-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: #fff;
}

.custom-textarea:focus {
  outline: none;
  border-color: #409eff;
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
  background: #ccc;
  border-radius: 10px;
  transition: 0.3s;
}

.slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .slider {
  background: #409eff;
}

input:checked + .slider::before {
  transform: translateX(20px);
}

.actions {
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  padding: 10px 15px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.btn-primary {
  background: #409eff;
  color: #fff;
}

.btn.btn-primary:hover:not(:disabled) {
  background: #66b1ff;
}

.btn.btn-default {
  background: #fff;
  color: #606266;
  border: 1px solid #dcdfe6;
}

.btn.btn-default:hover:not(:disabled) {
  border-color: #409eff;
  color: #409eff;
}

/* ---------- 打印布局（原 ExamBuilder.vue 的 @media print） ---------- */
@media print {
  @page {
    size: A4;
    margin: 0;
  }

  /* 隐藏不需要的元素 */
  .nav-bar,
  .right-panel,
  .panel-toolbar {
    display: none !important;
  }

  /* 只显示试卷区域 */
  .exam-builder {
    height: auto;
    overflow: visible;
  }

  .main-content {
    display: block;
    overflow: visible;
  }

  .left-panel {
    border: none;
    overflow: visible;
  }

  .paper-container {
    overflow: visible;
    padding: 0;
    background: none;
  }
}
