/**
 * 数控报价计算器样式
 * 
 * 设计原则：
 * - 与 cf-calculators 统一风格
 * - 清晰的信息层次
 * - 响应式布局
 * - 无障碍友好
 */

/* ═══════════════════════════════════════
   主容器
   ═══════════════════════════════════════ */

.mach-calculator {
  max-width: 800px;
  margin: 0 auto 2rem;
  padding: 0;
}

/* ═══════════════════════════════════════
   输入区域
   ═══════════════════════════════════════ */

.calc-inputs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-bottom: 1rem;
}

/* 非 sections 模式的字段间距 */
.calc-inputs > .calc-field {
  margin-bottom: 0.75rem;
}
.calc-inputs > .calc-field:last-child {
  margin-bottom: 0;
}

/* sections 模式：子元素 calc-section 完全脱离 grid 流，不受 gap 影响 */
.calc-inputs > .calc-section {
  grid-column: 1 / -1 !important;
  display: block !important;
  width: 100%;
  margin-bottom: 0.25rem !important;
}

/* sections 内的字段不受全局 2 列规则影响 */
.calc-inputs > .calc-section .calc-field {
  grid-column: auto !important;
}

/* 响应式：宽屏两列 */
@media (min-width: 640px) {
  .calc-inputs {
    grid-template-columns: 1fr 1fr;
  }
  .calc-inputs .calc-field:nth-child(odd) {
    grid-column: 1;
  }
  .calc-inputs .calc-field:nth-child(even) {
    grid-column: 2;
  }
  /* 跨两列的字段 */
  .calc-field.calc-full-width {
    grid-column: 1 / -1;
  }
}

/* ═══════════════════════════════════════
   字段样式
   ═══════════════════════════════════════ */

.calc-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.calc-field-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #1a1a2e;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.calc-field-unit {
  font-weight: 400;
  font-size: 0.8rem;
  color: #6b7280;
  margin-left: 0.25rem;
}

.calc-required {
  color: #dc2626;
  margin-left: 2px;
}

.calc-field-help {
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.4;
}

/* 输入框统一样式 */
.calc-input,
.calc-input[type="text"],
.calc-input[type="number"],
.calc-input[type="email"],
.calc-input[type="date"],
.calc-input[type="tel"] {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1.5px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: #1a1a2e;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.calc-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.calc-input::placeholder {
  color: #9ca3af;
}

/* Select 样式 */
.calc-field select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1.5px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: #1a1a2e;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.calc-field select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ═══════════════════════════════════════
   Radio 和 Checkbox 组
   ═══════════════════════════════════════ */

.calc-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.25rem;
}

.calc-radio-option {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  font-weight: 400;
  font-size: 0.95rem;
  padding: 0.375rem 0.75rem;
  border: 1.5px solid #d1d5db;
  border-radius: 0.5rem;
  transition: all 0.15s ease;
}

.calc-radio-option:hover {
  border-color: #3b82f6;
  background: #f0f7ff;
}

.calc-radio-option input[type="radio"]:checked + * {
  /* 样式由 label 自身处理 */
}

.calc-radio-option:has(input:checked) {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
}

.calc-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.calc-checkbox input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
}

/* ═══════════════════════════════════════
   计算按钮
   ═══════════════════════════════════════ */

.calc-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.calc-button-primary {
  background: #3b82f6;
  color: #fff;
  width: 100%;
}

.calc-button-primary:hover {
  background: #2563eb;
}

.calc-button-primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* ═══════════════════════════════════════
   结果区域
   ═══════════════════════════════════════ */

.calc-results {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f0f7ff 0%, #e8f4fd 100%);
  border: 1.5px solid #93c5fd;
  border-radius: 0.75rem;
}

/* 单个输出字段 */
.calc-output {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.75rem 0;
  border-bottom: 1px solid #bfdbfe;
  gap: 1rem;
}

.calc-output:last-child {
  border-bottom: none;
}

.calc-output-label {
  font-weight: 500;
  font-size: 0.9rem;
  color: #1e40af;
  flex-shrink: 0;
}

.calc-output-value {
  font-weight: 700;
  font-size: 1.1rem;
  color: #1a1a2e;
  text-align: right;
  white-space: nowrap;
}

.calc-output-unit {
  font-weight: 400;
  font-size: 0.85rem;
  color: #6b7280;
  margin-left: 0.25rem;
}

.calc-output-help {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

/* 高亮输出 */
.calc-output.calc-highlight {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin: 0 -0.25rem;
}

.calc-output.calc-highlight .calc-output-value {
  font-size: 1.3rem;
  color: #2563eb;
}

/* ═══════════════════════════════════════
   错误状态
   ═══════════════════════════════════════ */

.calc-error {
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1.5px solid #fecaca;
  border-radius: 0.5rem;
  color: #dc2626;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ═══════════════════════════════════════
   摘要输出
   ═══════════════════════════════════════ */

.calc-output-summary {
  font-size: 1rem;
  line-height: 1.6;
  color: #1a1a2e;
}

/* ═══════════════════════════════════════
   Sections 分组样式（每个 section 一行填满，自然堆叠）
   ═══════════════════════════════════════ */

.calc-section {
  display: block !important;
  width: 100%;
  margin-bottom: 0.3rem !important;
}

.calc-section:last-child {
  margin-bottom: 0;
}

/* Section Header（线分割标题） */
.calc-section-header {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0;
}

.calc-section-title {
  font-weight: 600;
  font-size: 0.9rem;
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  padding-right: 0.75rem;
  line-height: 1;
}

.calc-section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

/* 折叠图标（隐藏） */
.calc-section-toggle {
  display: none;
}

/* Section Body（字段 grid，按屏幕宽度自适应列数） */
.calc-section-body {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 0.3rem !important;
  margin-bottom: 0 !important;
}

@media (min-width: 480px) {
  .calc-section-body {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (min-width: 768px) {
  .calc-section-body {
    grid-template-columns: 1fr 1fr 1fr !important;
  }
}

@media (min-width: 1024px) {
  .calc-section-body {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

/* 行业估算边界提示 */
.calc-industry-note {
  margin: 1rem 0 1.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid #fde68a;
  border-radius: 10px;
  background: #fffbeb;
  color: #78350f;
  font-size: 0.92rem;
  line-height: 1.7;
}

.calc-industry-note strong {
  color: #92400e;
}

.calc-applicability {
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.calc-applicability h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.calc-applicability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.calc-applicability h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
}

.calc-applicability ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text2);
  line-height: 1.7;
}

.calc-result-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.calc-action-button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}

.calc-action-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media print {
  body * {
    visibility: hidden;
  }

  .mach-calculator,
  .mach-calculator * {
    visibility: visible;
  }

  .mach-calculator {
    position: absolute;
    inset: 0;
    background: white;
    color: black;
  }

  .calc-inputs,
  .calc-result-actions,
  .calc-price-config-btn {
    display: none !important;
  }
}
