﻿<template>
  <div class="new-product-value-page student-training-shell">
    <main class="training-core">
      <section class="task-header">
        <div class="task-badge">
          <el-icon><Operation /></el-icon>
          核心实训 · 产品开发基础
        </div>
        <h1 class="task-title">{{ taskTitle }}</h1>
      </section>

      <section class="goal-bg">
        <div class="subtitle-icon">
          <el-icon><Aim /></el-icon>
          任务目标
        </div>
        <p>{{ taskGoalText }}</p>
        <div class="subtitle-icon subtitle-icon--spaced">
          <el-icon><Clock /></el-icon>
          任务背景
        </div>
        <p>{{ taskBackground }}</p>
      
        <div class="subtitle-icon">
          <el-icon><DataAnalysis /></el-icon>
          任务分析
        </div>
        <p>{{ taskAnalysisText }}</p>
      </section>

      <section class="task-card">
        <div class="workbench-head">
          <div>
            <p class="section-eyebrow">Training Task</p>
            <h3>任务实训</h3>
          </div>
          <div class="workbench-actions">
            <TrainingMaterialButton :material-name="taskConfig?.materialName" :material-url="taskConfig?.materialUrl" />
            <button type="button" class="outline-action" @click="exportOutcome">
              <el-icon><Download /></el-icon>
              导出实训成果
            </button>
          </div>
        </div>

        <nav class="step-indicator" aria-label="新产品调查与分析步骤">
          <button
            v-for="step in steps"
            :key="step.no"
            type="button"
            :class="['step-tab', { active: currentStep === step.no }]"
            @click="currentStep = step.no"
          >
            <el-icon><component :is="step.icon" /></el-icon>
            <span>{{ step.name }}</span>
          </button>
        </nav>

        <section v-show="currentStep === 1" class="step-content active-step">
          <div class="step-card">
            <div class="step-title-row">
              <div>
                <p class="section-eyebrow">Step 01</p>
                <h3>{{ getStepName(1) }}</h3>
              </div>
              <span class="step-chip">案例信息提取</span>
            </div>
            <p class="step-desc">请根据实训要求中的案例一信息，分别从核心层、有形层、延伸层提取信息，并填写对应信息；</p>

            <label class="field-block">
              <span>该款智能产品平台类目是：</span>
              <input v-model="step1Form.category" class="input-field input-single" />
            </label>

            <label class="field-block">
              <span>核心层：从上图可以提炼出该款智能产品解决的用户痛点为：</span>
              <textarea v-model="step1Form.corePain" class="input-field" rows="4" />
            </label>

            <label class="field-block">
              <span>有形层：从产品主图可以看出，关于产品有形层的主要卖点为：</span>
              <textarea v-model="step1Form.tangibleSellingPoint" class="input-field" rows="4" />
            </label>

            <label class="field-block">
              <span>价格带为：</span>
              <div class="price-options">
                <button
                  v-for="option in priceOptions"
                  :key="option.value"
                  type="button"
                  :class="['price-option', { active: step1Form.priceBand === option.value }]"
                  @click="step1Form.priceBand = option.value"
                >
                  {{ step1Form.priceBand === option.value ? "√" : "" }}{{ option.label }}
                </button>
              </div>
            </label>

            <p class="step-desc">延伸层：从产品主图可以看出，关于产品品牌保证发货等延伸层相关描述为：</p>
            <div class="form-grid three">
              <label class="field-block">
                <span>店铺名称：</span>
                <input v-model="step1Form.storeName" class="input-field input-single" />
              </label>
              <label class="field-block">
                <span>店铺星级：</span>
                <input v-model="step1Form.storeRating" class="input-field input-single" />
              </label>
              <label class="field-block">
                <span>发货优势：</span>
                <input v-model="step1Form.shippingAdvantage" class="input-field input-single" />
              </label>
            </div>

            <label class="field-block">
              <span>根据该产品主图、详情、评价等信息，在产品介绍、外观设计和功能上您有何改进建议？</span>
              <textarea v-model="step1Form.improvement" class="input-field" rows="4" />
            </label>
          </div>
        </section>

        <section v-show="currentStep === 2" class="step-content active-step">
          <div class="step-card">
            <div class="step-title-row">
              <div>
                <p class="section-eyebrow">Step 02</p>
                <h3>{{ getStepName(2) }}</h3>
              </div>
              <span class="step-chip">平台与关键词</span>
            </div>
            <p class="step-desc">
              优先选择京东、天猫、抖音等主流电商平台，至少选择 3 个高流量使用场景，采用“核心词 + 属性词 + 场景词”的电商搜索热词逻辑记录产品。
            </p>

            <div class="training-table-wrap">
              <table class="training-data-table">
                <thead>
                  <tr>
                    <th>使用场景</th>
                    <th>搜索平台</th>
                    <th>搜索关键词（电商热词）</th>
                    <th>平台类目</th>
                    <th>销量参考（近30天）</th>
                  </tr>
                </thead>
                <tbody>
                  <tr v-for="(row, index) in step2Rows" :key="index">
                    <td><input v-model="row.scene" class="cell-input" placeholder="如：家庭学习" /></td>
                    <td><input v-model="row.platform" class="cell-input" placeholder="京东 / 天猫 / 抖音" /></td>
                    <td><input v-model="row.keyword" class="cell-input" placeholder="AI学习机 小学生 护眼" /></td>
                    <td><input v-model="row.category" class="cell-input" placeholder="学习机 / 智能硬件" /></td>
                    <td><input v-model="row.sales" class="cell-input" placeholder="如：月销 5000+" /></td>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
        </section>

        <section v-show="currentStep === 3" class="step-content active-step">
          <div class="step-card">
            <div class="step-title-row">
              <div>
                <p class="section-eyebrow">Step 03</p>
                <h3>{{ getStepName(3) }}</h3>
              </div>
              <span class="step-chip">产品1 / 产品2 / 产品3</span>
            </div>
            <p class="step-desc">
              根据查找的产品，从核心层、有形层、延伸层开展三层次分析，对比不同产品如何创造用户价值。
            </p>

            <div class="training-table-wrap">
              <table class="training-data-table layer-table">
                <thead>
                  <tr>
                    <th>分析维度</th>
                    <th>内容要求</th>
                    <th>实例：AI学习机</th>
                    <th>产品1</th>
                    <th>产品2</th>
                    <th>产品3</th>
                  </tr>
                </thead>
                <tbody>
                  <tr v-for="row in step3Rows" :key="row.dimension">
                    <td class="dimension-cell">{{ row.dimension }}</td>
                    <td class="requirement-cell">{{ row.requirement }}</td>
                    <td class="example-cell">{{ row.example }}</td>
                    <td><textarea v-model="row.product1" class="cell-textarea" /></td>
                    <td><textarea v-model="row.product2" class="cell-textarea" /></td>
                    <td><textarea v-model="row.product3" class="cell-textarea" /></td>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
        </section>

        <section v-show="currentStep === 4" class="step-content active-step">
          <div class="step-card">
            <div class="step-title-row">
              <div>
                <p class="section-eyebrow">Step 04</p>
                <h3>{{ getStepName(4) }}</h3>
              </div>
              <span class="step-chip">价值判断</span>
            </div>
            <p class="step-desc">根据上面分析，围绕核心层、有形层、延伸层回答以下问题，并形成产品开发启发。</p>

            <label class="field-block">
              <span>核心层价值：AI 技术解决了用户什么真实问题？</span>
              <textarea v-model="step4Form.coreValue" class="input-field" rows="5" />
            </label>
            <label class="field-block">
              <span>有形层价值：哪些功能、设计或参数最能体现差异化？</span>
              <textarea v-model="step4Form.tangibleValue" class="input-field" rows="5" />
            </label>
            <label class="field-block">
              <span>延伸层价值：哪些服务、内容、生态或售后能增强竞争优势？</span>
              <textarea v-model="step4Form.extendedValue" class="input-field" rows="5" />
            </label>
          </div>
        </section>

        <div class="step-navigation">
          <button type="button" class="btn-nav" :disabled="currentStep === 1" @click="prevStep">
            <el-icon><ArrowLeft /></el-icon>
            上一步
          </button>
          <button type="button" class="btn-nav btn-save" :disabled="saving" @click="saveCurrentProgress">
            <el-icon><CircleCheck /></el-icon>
            保存当前进度
          </button>
          <button type="button" class="btn-nav btn-primary" :disabled="currentStep === steps.length" @click="nextStep">
            下一步
            <el-icon><ArrowRight /></el-icon>
          </button>
        </div>

        <div class="task-actions">
          <button type="button" class="btn-nav btn-submit" :disabled="saving" @click="submitTask">
            <el-icon><CircleCheck /></el-icon>
            提交任务
          </button>
          <button type="button" class="btn-nav" :disabled="saving" @click="resetExample">
            <el-icon><RefreshLeft /></el-icon>
            清空填写
          </button>
          <button type="button" class="btn-nav" @click="exportOutcome">
            <el-icon><Download /></el-icon>
            导出实训成果
          </button>
        </div>
      </section>
    </main>

    <TrainingAiSidebar
      :study-tip="currentStudyTip"
      reference-title="产品三层次分析参考"
      reference-text="· 核心层：用户购买的根本利益与真实痛点<br />· 有形层：功能、外观、品牌、包装、参数等可感知内容<br />· 延伸层：售后、内容服务、会员权益、生态兼容、数据安全等附加价值"
      assist-text="建议先把电商页面中的主图、参数、详情页、评价和售后承诺分别归入三层次，再比较哪些层次能形成差异化。"
      :progress-items="progressItems"
    />
  </div>
</template>

<script setup>
import {
  Aim,
  ArrowLeft,
  ArrowRight,
  CircleCheck,
  Clock,
  DataAnalysis,
  Download,
  Operation,
  Opportunity,
  RefreshLeft,
  Search,
  TrendCharts,
} from "@element-plus/icons-vue";
import { getTrainingTaskByKey } from "@/api/trainingTask";
import { getStudentTrainingAnswer, saveStudentTrainingAnswer } from "@/api/studentTrainingAnswer";
import useUserStore from "@/store/modules/user";
import TrainingAiSidebar from "@/views/components/TrainingAiSidebar.vue";
import TrainingMaterialButton from "@/views/components/TrainingMaterialButton.vue";

const TASK_KEY = "new-product-survey";
const { proxy } = getCurrentInstance();
const userStore = useUserStore();

const taskConfig = ref(null);
const saving = ref(false);
const draftReady = ref(false);
const currentStep = ref(1);

const defaultSteps = [
  { no: 1, name: "产品三层次理论应用", icon: Search },
  { no: 2, name: "选定调查平台与产品", icon: DataAnalysis },
  { no: 3, name: "AI新产品三层次分析", icon: TrendCharts },
  { no: 4, name: "AI技术价值分析", icon: Operation },
];

const defaultGoals = [
  "理解市场驱动、技术推动等不同类型产品开发的核心逻辑，培养市场意识，能分析新技术在互联网产品中的应用场景。",
  "掌握运用电商平台开展市场调查的方法，能结合产品三层次理论分析互联网新产品。",
  "能通过分析，理解企业如何通过不同产品层次创造差异化竞争优势。",
];

const taskTitle = computed(() => taskConfig.value?.taskName || "新产品调查与分析");
const taskAnalysisText = computed(
  () =>
    taskConfig.value?.knowledge ||
    "产品三层次理论能帮助企业有效定义及分析产品。实训通过电商平台收集真实信息，利用关键词搜索找到相关产品，并通过主图、详情页、产品参数、图文、视频、用户评价等资料提取三层次要素。"
);
const taskGoalText = computed(() => parseArray(taskConfig.value?.objectives, defaultGoals).join("；"));
const taskBackground = computed(
  () =>
    taskConfig.value?.background ||
    "2024年，生成式AI技术爆发式发展，催生大量消费端新产品，如AI智能音箱、AI学习机、AI玩具等。DeepSeek的出现降低了国内企业使用AI技术开发产品的成本，企业希望借助电商平台数据，为未来产品开发提供思路。"
);

const steps = computed(() => {
  const configured = parseArray(taskConfig.value?.steps, defaultSteps.map((item) => item.name)).slice(0, 4);
  return defaultSteps.map((step, index) => ({
    ...step,
    name: configured[index] || step.name,
  }));
});

const priceOptions = [
  { label: "1000元以下的基础款", value: "basic" },
  { label: "1000-3000元的进阶全能款", value: "advanced" },
  { label: "3000元以上的旗舰高端款", value: "flagship" },
];

const createStep1Form = () => ({
  category: "",
  corePain: "",
  tangibleSellingPoint: "",
  priceBand: "basic",
  storeName: "",
  storeRating: "",
  shippingAdvantage: "",
  improvement: "",
});

const createStep2Rows = () => [
  { scene: "", platform: "", keyword: "", category: "", sales: "" },
  { scene: "", platform: "", keyword: "", category: "", sales: "" },
  { scene: "", platform: "", keyword: "", category: "", sales: "" },
];

const createStep3Rows = () => [
  {
    dimension: "核心层",
    requirement: "说明产品解决的核心痛点、用户需求和核心利益。",
    example: "解决学生学习效率低、家长辅导时间不足等痛点，提供个性化学习支持。",
    product1: "",
    product2: "",
    product3: "",
  },
  {
    dimension: "有形层",
    requirement: "记录功能、设计、品牌、参数、包装、价格等可见要素。",
    example: "护眼屏、AI语音互动、拍照搜题、错题本、课程资源、学习报告。",
    product1: "",
    product2: "",
    product3: "",
  },
  {
    dimension: "延伸层",
    requirement: "分析售后、会员、内容更新、物流、生态兼容和数据安全等附加服务。",
    example: "课程持续更新、家长端管理、云端错题同步、售后保修、会员内容权益。",
    product1: "",
    product2: "",
    product3: "",
  },
];

const createStep4Form = () => ({
  coreValue: "",
  tangibleValue: "",
  extendedValue: "",
});

const step1Form = ref(createStep1Form());
const step2Rows = ref(createStep2Rows());
const step3Rows = ref(createStep3Rows());
const step4Form = ref(createStep4Form());

const getLocalDraftKey = () => {
  const userInfo = userStore.userInfo || {};
  const userKey = userInfo.userId || userInfo.user_id || userInfo.username || userInfo.userName || "anonymous";
  return `${TASK_KEY}:draft:${userKey}`;
};

const currentStudyTip = computed(() => {
  const tips = {
    1: "当前步骤建议：先从案例或电商详情页中拆出核心层、有形层、延伸层，不要把功能和用户利益混在一起。",
    2: "当前步骤建议：选择主流电商平台，并用“核心词 + 属性词 + 场景词”的组合记录关键词和销量参考。",
    3: "当前步骤建议：同一维度横向比较 3 个产品，重点找出 AI 技术在哪一层创造了差异化。",
    4: "当前步骤建议：把前面三步的发现收束为产品开发启发，说明哪些价值值得继续强化。",
  };
  return tips[currentStep.value];
});

const progressItems = computed(() =>
  steps.value.map((step) => ({
    text: `${currentStep.value > step.no ? "已完成" : currentStep.value === step.no ? "进行中" : "待完成"}：${step.name}`,
    status: currentStep.value > step.no ? "done" : currentStep.value === step.no ? "doing" : "",
  }))
);

onMounted(async () => {
  loadDraft();
  await loadTaskConfig();
  await loadSavedAnswer();
  draftReady.value = true;
});

watch(
  [step1Form, step2Rows, step3Rows, step4Form, currentStep],
  () => persistDraft(),
  { deep: true }
);

function parseArray(value, fallback) {
  if (Array.isArray(value)) {
    return value.length ? value : fallback;
  }
  if (!value) {
    return fallback;
  }
  try {
    const parsed = JSON.parse(value);
    return Array.isArray(parsed) && parsed.length ? parsed : fallback;
  } catch (error) {
    const list = String(value)
      .split(/[；;|]/)
      .map((item) => item.trim())
      .filter(Boolean);
    return list.length ? list : fallback;
  }
}

function getStepName(no) {
  return steps.value.find((item) => item.no === no)?.name || defaultSteps[no - 1]?.name || "";
}

async function loadTaskConfig() {
  try {
    const res = await getTrainingTaskByKey(TASK_KEY);
    taskConfig.value = res?.data || null;
  } catch (error) {
    taskConfig.value = null;
  }
}

async function loadSavedAnswer() {
  try {
    const res = await getStudentTrainingAnswer(TASK_KEY);
    const answer = res?.data;
    if (answer && applySavedAnswer(answer)) {
      clearDraft();
    }
  } catch (error) {
    // 后端不可用时，页面仍允许学生直接填写。
  }
}

function safeParse(value) {
  if (!value) return null;
  if (typeof value === "object") return value;
  try {
    return JSON.parse(value);
  } catch (error) {
    return null;
  }
}

function applySavedAnswer(value) {
  const parsed = safeParse(value);
  if (!parsed || typeof parsed !== "object") return false;

  if (parsed.step1Answer || parsed.step2Answer || parsed.step3Answer || parsed.step4Answer) {
    let loaded = false;
    const step1Parsed = safeParse(parsed.step1Answer);
    if (step1Parsed?.step1Form || step1Parsed?.step2Rows || step1Parsed?.step3Rows || step1Parsed?.step4Form) {
      loaded = applySavedAnswer(step1Parsed) || loaded;
    } else {
      loaded = applyStep1Answer(step1Parsed || parsed.step1Answer) || loaded;
    }
    loaded = applyStep2Answer(parsed.step2Answer) || loaded;
    loaded = applyStep3Answer(parsed.step3Answer) || loaded;
    loaded = applyStep4Answer(parsed.step4Answer) || loaded;
    currentStep.value = Math.min(Math.max(Number(parsed.currentStep || currentStep.value || 1), 1), 4);
    return loaded;
  }

  let loaded = false;
  loaded = applyStep1Answer(parsed.step1Form || parsed) || loaded;
  loaded = applyStep2Answer(parsed.step2Rows || parsed.rows2 || parsed.platformRows) || loaded;
  loaded = applyStep3Answer(parsed.step3Rows || parsed.rows3 || parsed.layerRows) || loaded;
  loaded = applyStep4Answer(parsed.step4Form || parsed.aiValue || parsed.valueAnalysis) || loaded;
  currentStep.value = Math.min(Math.max(Number(parsed.currentStep || 1), 1), 4);
  return loaded;
}

function applyStep1Answer(value) {
  const parsed = safeParse(value);
  if (!parsed || typeof parsed !== "object") return false;
  const source = parsed.step1Form || parsed;
  const fields = Object.keys(createStep1Form());
  const hasValue = fields.some((key) => source[key] !== undefined && source[key] !== null && source[key] !== "");
  if (!hasValue) return false;
  step1Form.value = { ...createStep1Form(), ...pickFields(source, fields) };
  return true;
}

function applyStep2Answer(value) {
  const parsed = safeParse(value);
  const rows = Array.isArray(parsed) ? parsed : parsed?.step2Rows || parsed?.rows || parsed?.platformRows;
  if (!Array.isArray(rows) || !rows.length) return false;
  step2Rows.value = normalizeRows(rows, createStep2Rows());
  return true;
}

function applyStep3Answer(value) {
  const parsed = safeParse(value);
  const rows = Array.isArray(parsed) ? parsed : parsed?.step3Rows || parsed?.rows || parsed?.layerRows;
  if (!Array.isArray(rows) || !rows.length) return false;
  step3Rows.value = normalizeRows(rows, createStep3Rows(), "dimension");
  return true;
}

function applyStep4Answer(value) {
  const parsed = safeParse(value);
  if (!parsed || typeof parsed !== "object") return false;
  const source = parsed.step4Form || parsed;
  const fields = Object.keys(createStep4Form());
  const hasValue = fields.some((key) => source[key] !== undefined && source[key] !== null && source[key] !== "");
  if (!hasValue) return false;
  step4Form.value = { ...createStep4Form(), ...pickFields(source, fields) };
  return true;
}

function pickFields(source, fields) {
  return fields.reduce((target, key) => {
    if (source[key] !== undefined && source[key] !== null) {
      target[key] = source[key];
    }
    return target;
  }, {});
}

function normalizeRows(rows, fallback, matchKey = "") {
  if (!Array.isArray(rows) || !rows.length) return fallback;
  if (matchKey) {
    const rowMap = rows.reduce((map, row) => {
      if (row?.[matchKey]) {
        map[row[matchKey]] = row;
      }
      return map;
    }, {});
    return fallback.map((row, index) => ({
      ...row,
      ...(rowMap[row[matchKey]] || rows[index] || {}),
    }));
  }
  return fallback.map((row, index) => ({
    ...row,
    ...(rows[index] || {}),
  }));
}

function buildAnswerPayload(status) {
  const saveAction = status === "SUBMITTED" ? "SUBMIT" : status === "RESET" ? "RESET" : "SAVE";
  return {
    saveAction,
    currentStep: currentStep.value,
    step1Answer: JSON.stringify(step1Form.value),
    step2Answer: JSON.stringify(step2Rows.value),
    step3Answer: JSON.stringify(step3Rows.value),
    step4Answer: JSON.stringify(step4Form.value),
  };
}

async function saveAnswer(status = "IN_PROGRESS", silent = false) {
  saving.value = true;
  try {
    await saveStudentTrainingAnswer(TASK_KEY, buildAnswerPayload(status));
    if (!silent) {
      proxy?.$modal?.msgSuccess(status === "SUBMITTED" ? "提交成功" : "保存成功");
    }
  } finally {
    saving.value = false;
  }
}

function saveCurrentProgress() {
  return saveAnswer("IN_PROGRESS");
}

function submitTask() {
  return saveAnswer("SUBMITTED");
}

function nextStep() {
  if (currentStep.value < steps.value.length) {
    currentStep.value += 1;
  }
}

function prevStep() {
  if (currentStep.value > 1) {
    currentStep.value -= 1;
  }
}

function resetExample() {
  step1Form.value = createStep1Form();
  step2Rows.value = createStep2Rows();
  step3Rows.value = createStep3Rows();
  step4Form.value = createStep4Form();
  currentStep.value = 1;
  clearDraft();
}

function buildOutcome() {
  return {
    taskKey: TASK_KEY,
    taskName: taskTitle.value,
    taskId: taskConfig.value?.id || "",
    currentStep: currentStep.value,
    steps: steps.value.map((item) => item.name),
    step1Form: step1Form.value,
    step2Rows: step2Rows.value,
    step3Rows: step3Rows.value,
    step4Form: step4Form.value,
  };
}

function persistDraft() {
  if (!draftReady.value) return;
  try {
    localStorage.setItem(getLocalDraftKey(), JSON.stringify(buildOutcome()));
  } catch (error) {
    // 本地草稿只是兜底，后端保存仍是主来源。
  }
}

function loadDraft() {
  try {
    const raw = localStorage.getItem(getLocalDraftKey());
    if (raw) {
      applySavedAnswer(raw);
    }
  } catch (error) {
    clearDraft();
  }
}

function clearDraft() {
  try {
    localStorage.removeItem(getLocalDraftKey());
  } catch (error) {
    // 忽略浏览器存储异常。
  }
}

function exportOutcome() {
  const content = buildOutcome();
  const blob = new Blob([JSON.stringify(content, null, 2)], { type: "application/json;charset=utf-8" });
  const url = URL.createObjectURL(blob);
  const link = document.createElement("a");
  link.href = url;
  link.download = "新产品调查与分析-实训成果.json";
  link.click();
  URL.revokeObjectURL(url);
}
</script>

<style lang="scss" scoped>
.new-product-value-page {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(720px, 1fr) 340px;
  gap: 24px;
  width: 100%;
  min-height: calc(100vh - 106px);
  padding: 0 0 32px;
  color: #eef5ff;
  background: transparent;
}

.training-core {
  padding: 28px;
  border: 1px solid rgba(0, 180, 255, 0.25);
  border-radius: 36px;
  background: rgba(8, 18, 28, 0.6);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(169, 229, 255, 0.08);
  backdrop-filter: blur(8px);
}

.task-header {
  margin-bottom: 24px;
}

.task-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
  padding: 4px 14px;
  border: 1px solid rgba(0, 170, 255, 0.5);
  border-radius: 30px;
  color: #d6f6ff;
  background: rgba(0, 170, 255, 0.2);
  font-size: 12px;
  font-weight: 700;
}

.task-title {
  margin: 0;
  color: transparent;
  background: linear-gradient(135deg, #ffffff, #8bcbff);
  -webkit-background-clip: text;
  background-clip: text;
  font-size: 30px;
  line-height: 1.3;
  font-weight: 900;
}

.goal-bg,
.task-card,
.step-card {
  margin-bottom: 28px;
  padding: 18px 22px;
  border: 1px solid rgba(82, 174, 226, 0.42);
  border-radius: 26px;
  background: rgba(0, 25, 42, 0.64);
}

.goal-bg {
  p {
    margin: 0;
    color: #d7ecff;
    font-size: 14px;
    line-height: 1.8;
  }
}

.subtitle-icon {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: #b9e2ff;
  font-weight: 800;
}

.subtitle-icon--spaced {
  margin-top: 12px;
}

.workbench-head,
.step-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.workbench-head {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(0, 180, 255, 0.2);

  h3 {
    margin: 4px 0 0;
    color: #ffffff;
    font-size: 26px;
    font-weight: 800;
  }
}

.workbench-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.section-eyebrow {
  margin: 0;
  color: #71dfff;
  font-size: 12px;
  font-weight: 800;
}

.outline-action,
.btn-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid rgba(99, 217, 255, 0.55);
  border-radius: 999px;
  color: #e9fbff;
  background: rgba(17, 126, 178, 0.36);
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;

  &:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(116, 235, 255, 0.85);
    background: rgba(18, 146, 204, 0.5);
  }

  &:disabled {
    cursor: not-allowed;
    opacity: 0.45;
  }
}

.step-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 32px;
  padding: 6px;
  border: 1px solid rgba(0, 180, 255, 0.3);
  border-radius: 60px;
  background: rgba(0, 0, 0, 0.3);
}

.step-tab {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 40px;
  color: #9ab3d0;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;

  &.active {
    border-color: rgba(0, 170, 255, 0.55);
    color: #ffffff;
    background: linear-gradient(95deg, #0a6b9e, #0a5c86);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

.step-content {
  animation: fade 0.2s ease;
}

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

.step-card {
  margin-bottom: 0;
}

.step-title-row {
  margin-bottom: 14px;

  h3 {
    margin: 4px 0 0;
    color: #ffffff;
    font-size: 22px;
    font-weight: 900;
  }
}

.step-chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid rgba(106, 226, 255, 0.45);
  border-radius: 999px;
  color: #c8f4ff;
  background: rgba(0, 127, 184, 0.25);
  font-size: 12px;
  font-weight: 800;
}

.step-desc {
  margin: 0 0 20px;
  color: #d7ecff;
  font-size: 15px;
  line-height: 1.8;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;

  &.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.field-block {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: #dff5ff;
  font-size: 14px;
  font-weight: 800;

  > span {
    line-height: 1.6;
  }
}

.input-field,
.input-single,
.cell-input,
.cell-textarea {
  width: 100%;
  border: 1px solid rgba(45, 95, 126, 0.95);
  border-radius: 14px;
  color: #eef5ff;
  background: #0f1a24;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;

  &::placeholder {
    color: #8299aa;
  }

  &:focus {
    border-color: rgba(92, 224, 255, 0.7);
    box-shadow: 0 0 0 3px rgba(0, 174, 255, 0.13);
  }
}

.input-field {
  min-height: 110px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.65;
}

.input-single {
  min-height: 42px;
  padding: 0 14px;
}

.price-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.price-option {
  min-height: 42px;
  border: 1px solid rgba(45, 95, 126, 0.95);
  border-radius: 14px;
  color: #b9d6e8;
  background: rgba(15, 26, 36, 0.86);
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;

  &.active {
    color: #ffffff;
    border-color: rgba(92, 224, 255, 0.75);
    background: linear-gradient(95deg, #0a6b9e, #0a5c86);
  }
}

.training-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(0, 180, 255, 0.22);
  border-radius: 22px;
  background: rgba(1, 14, 26, 0.72);
}

.training-data-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;

  th,
  td {
    border: 1px solid rgba(77, 167, 220, 0.2);
    padding: 12px;
    vertical-align: top;
  }

  th {
    color: #eaffff;
    background: rgba(8, 55, 82, 0.98);
    font-size: 14px;
    font-weight: 900;
    text-align: center;
  }

  td {
    color: #d7f1ff;
    background: rgba(1, 14, 26, 0.48);
  }
}

.cell-input {
  min-height: 38px;
  padding: 0 10px;
}

.cell-textarea {
  min-height: 118px;
  padding: 10px;
  resize: vertical;
  line-height: 1.6;
}

.dimension-cell {
  color: #eafaff;
  font-weight: 900;
  text-align: center;
}

.requirement-cell,
.example-cell {
  min-width: 170px;
  color: #cfe8f8;
  line-height: 1.65;
}

.example-cell {
  color: #f5d99d;
}

.example-hint {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(250, 204, 21, 0.28);
  border-radius: 16px;
  color: #f6e5a7;
  background: rgba(120, 92, 8, 0.16);
  font-size: 13px;
  line-height: 1.6;
}

.step-navigation,
.task-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 22px;
}

.task-actions {
  gap: 52px;
  margin-top: 36px;
}

.task-actions .btn-nav {
  min-width: 172px;
  min-height: 64px;
  padding: 0 28px;
  border: 1px solid #2c83aa;
  border-radius: 6px;
  color: #dff7ff;
  background: rgba(13, 64, 88, 0.62);
  box-shadow: none;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: none;
}

.task-actions .btn-nav .el-icon {
  display: none;
}

.task-actions .btn-nav:hover:not(:disabled) {
  border-color: #46b5e7;
  color: #ffffff;
  background: rgba(18, 85, 116, 0.78);
}

.btn-primary,
.btn-submit,
.btn-save {
  border-color: rgba(92, 224, 255, 0.7);
  color: #ffffff;
  background: linear-gradient(95deg, #0b84bd, #096491);
}

.task-actions .btn-submit,
.task-actions .btn-save {
  border-color: #2c83aa;
  color: #dff7ff;
  background: rgba(13, 64, 88, 0.62);
}

@media (max-width: 1100px) {
  .new-product-value-page {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .training-core {
    padding: 18px;
    border-radius: 24px;
  }

  .step-indicator,
  .step-navigation,
  .task-actions,
  .workbench-actions,
  .workbench-head,
  .step-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .step-tab,
  .outline-action,
  .btn-nav {
    width: 100%;
  }

  .form-grid,
  .form-grid.three,
  .price-options {
    grid-template-columns: 1fr;
  }
}
</style>


