/* ========================================
   calculator.css - 智能测算工具页面样式
   ======================================== */

/* ---------- 工具导航 tabs ---------- */
.calc-tabs {
  position: sticky;
  top: var(--header-height);
  z-index: 50;
  background: white;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.calc-tabs-inner {
  max-width: 98vw;
  margin: 0 auto;
  padding: 0 1vw;
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.calc-tabs-inner::-webkit-scrollbar { display: none; }

.calc-tab {
  padding: 18px 32px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: var(--transition);
  flex-shrink: 0;
}

.calc-tab:hover,
.calc-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---------- 测算区块 ---------- */
.calc-section {
  display: none;
  padding: 80px 0;
  background: var(--bg-light);
  min-height: 80vh;
}

.calc-section.active {
  display: block;
}

.calc-header {
  text-align: center;
  margin-bottom: 50px;
}

.calc-header h2 {
  font-size: 34px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.calc-header p {
  font-size: 16px;
  color: var(--text-secondary);
}

/* ---------- 测算布局 ---------- */
.calc-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
  min-width: 0;
}

/* ---------- 表单区域 ---------- */
.calc-form {
  background: white;
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
  min-width: 0;
}

.calc-form-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border-color);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
  min-width: 0;
  overflow: hidden;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: normal;
  word-break: break-all;
}

.form-group .form-control {
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-light);
  transition: var(--transition);
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}

.form-group .form-control:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(126,182,59,0.1);
  outline: none;
}

/* 面积输入组合 */
.area-input-group {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.area-input-group .form-control {
  flex: 1;
  min-width: 0;
}

.area-unlimited-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.area-unlimited-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.area-input-group.disabled .form-control {
  background: #f0f0f0;
  color: #999;
  pointer-events: none;
}

.btn-block {
  width: 100%;
}

/* ---------- 结果区域 ---------- */
.calc-result {
  background: white;
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  position: sticky;
  top: calc(var(--header-height) + 60px);
  overflow: hidden;
  min-width: 0;
}

/* 投资收益结果卡片 */
.result-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.result-card {
  background: var(--bg-light);
  border-radius: var(--radius-md);
  padding: 18px 14px;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.result-card.highlight {
  background: linear-gradient(135deg, var(--primary), #003D7A);
  border-color: transparent;
}

.result-card.highlight .result-value { color: white; }
.result-card.highlight .result-label { color: rgba(255,255,255,0.8); }

.result-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  font-family: var(--font-en);
  line-height: 1;
  margin-bottom: 8px;
}

.result-label {
  font-size: 13px;
  color: var(--text-light);
}

/* 线条图表预览 */
.result-chart {
  margin-bottom: 18px;
  padding: 18px;
  background: var(--bg-light);
  border-radius: var(--radius-md);
  position: relative;
}

.result-chart h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.chart-placeholder {
  position: relative;
  width: 100%;
}

.line-chart-svg {
  width: 100%;
  height: 110px;
  display: block;
}

.chart-x-labels {
  position: relative;
  height: 18px;
  width: 100%;
}

.x-label {
  font-size: 11px;
  color: var(--text-light);
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}
/* 首个标签不允许超出左侧 */
.x-label:first-child {
  transform: translateX(0);
}
/* 末个标签不允许超出右侧 */
.x-label:last-child {
  transform: translateX(-100%);
}

.chart-point {
  cursor: pointer;
  transition: all 0.2s ease;
}

.chart-pulse {
  animation: pulseAnimation 2s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
  pointer-events: none;
}

@keyframes pulseAnimation {
  0%, 100% { r: 5; opacity: 0.4; }
  50% { r: 12; opacity: 0.15; }
}

.chart-hit-area {
  cursor: pointer;
}

/* 图表悬停弹窗 */
.chart-tooltip {
  position: absolute;
  background: rgba(10, 22, 40, 0.95);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  min-width: 140px;
  text-align: center;
  transform: translate(-50%, 0);
}

.chart-tooltip .tooltip-year {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--secondary);
}

.chart-tooltip .tooltip-income {
  font-size: 12px;
  color: rgba(255,255,255,0.9);
}

/* 提示框 */
.result-tips {
  background: rgba(126,182,59,0.06);
  border-left: 3px solid var(--primary);
  padding: 12px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 16px;
}

.result-tips p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* 操作按钮 */
.result-actions {
  display: flex;
  gap: 12px;
}

.result-actions .btn {
  flex: 1;
  text-align: center;
}

/* ---------- 充放电策略切换 ---------- */
.cycle-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.cycle-mode-tab {
  flex: 1;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-light);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.cycle-mode-tab:hover {
  background: white;
  border-color: var(--primary);
}

.cycle-mode-tab.active {
  background: linear-gradient(135deg, var(--primary), #5a9a2a);
  color: white;
  border-color: transparent;
}

/* ---------- 容量推荐卡片 ---------- */
.recommend-card {
  background: linear-gradient(135deg, #0a1628, #1a2a4a);
  border-radius: var(--radius-md);
  padding: 15px;
  margin-bottom: 2px;
  position: relative;
  overflow: hidden;
  display: flex;
  gap: 24px;
}

.recommend-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--secondary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 50px;
}

.recommend-main {
  text-align: center;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.recommend-capacity {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.capacity-value {
  font-size: 56px;
  font-weight: 900;
  color: var(--secondary);
  font-family: var(--font-en);
  line-height: 1;
}

.capacity-unit {
  font-size: 24px;
  color: rgba(255,255,255,0.7);
  font-weight: 600;
}

.recommend-power {
  font-size: 16px;
  color: rgba(255,255,255,0.6);
  margin-top: 8px;
}

.recommend-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
  gap: 4px;
}

.detail-label {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--secondary);
  flex-shrink: 0;
  white-space: nowrap;
}

/* 备选方案 */
.alternative-plans { margin-bottom: 18px; }
.alternative-plans h4 { font-size: 14px; font-weight: 700; color: var(--text-secondary); margin-bottom: 12px; }

/* 容量限制分析 */
.capacity-limits {
  background: var(--bg-light);
  border-radius: var(--radius-md);
  padding: 5px;
  margin-bottom: 18px;
}

.capacity-limits h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.limits-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.limit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.limit-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), #5a9a2a);
  border-radius: 50%;
  font-size: 16px;
}

.limit-info {
  flex: 1;
}

.limit-name {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 2px;
}

.limit-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-en);
}

.limit-item.bottleneck {
  border-color: #ef4444;
  background: #fef2f2;
}

.limit-item.bottleneck .limit-value {
  color: #ef4444;
}

.alt-plans-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.alt-plan {
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  font-family: inherit;
  width: 100%;
}

.alt-plan:hover {
  border-color: var(--primary);
  background: white;
  transform: translateY(-2px);
}

.alt-plan.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(126,182,59,0.1), rgba(126,182,59,0.05));
  box-shadow: 0 4px 12px rgba(126,182,59,0.15);
}

.alt-plan-capacity {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
  font-family: var(--font-en);
}

.alt-plan-desc {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 4px;
}

.alt-plan-details {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
  line-height: 1.3;
}

/* ---------- 碳减排结果 ---------- */
.carbon-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.carbon-stat-main {
  background: linear-gradient(135deg, #0a3d1e, #1a5e2f);
  border-radius: var(--radius-md);
  padding: 22px 16px;
  text-align: center;
}

.carbon-icon { font-size: 36px; margin-bottom: 8px; }

.carbon-value {
  font-size: 36px;
  font-weight: 900;
  color: #4ade80;
  font-family: var(--font-en);
  line-height: 1;
}

.carbon-label {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  margin-top: 6px;
}

.carbon-equivalent {
  background: var(--bg-light);
  border-radius: var(--radius-md);
  padding: 16px;
}

.carbon-equivalent h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.equivalent-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.equiv-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.equiv-icon { font-size: 20px; }

.equiv-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
  font-family: var(--font-en);
  min-width: 50px;
}

.equiv-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.carbon-value-card {
  background: var(--bg-light);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.carbon-value-card h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
}

.carbon-value-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cv-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.cv-item:last-child { border-bottom: none; }

.cv-label { font-size: 14px; color: var(--text-secondary); }
.cv-value { font-size: 15px; font-weight: 700; color: #16a34a; }

/* ---------- 响应式 ---------- */
@media (max-width: 1200px) {
  .calc-wrapper { grid-template-columns: 1fr; }
  .calc-result { position: static; }
}

@media (max-width: 768px) {
  .calc-section { padding: 40px 0; }
  .calc-form { padding: 16px; }
  .calc-result { padding: 16px; overflow: hidden; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .form-group label { font-size: 12px; }
  .form-group .form-control { padding: 8px 10px; font-size: 13px; width: 100%; box-sizing: border-box; }
  .result-cards { grid-template-columns: 1fr 1fr; }
  .carbon-stats { grid-template-columns: 1fr; }
  .recommend-details { grid-template-columns: 1fr; }
  .recommend-card { display: flex; flex-direction: column; gap: 0; overflow: hidden; }
  .capacity-value { font-size: 40px; }
  .calc-header h2 { font-size: 26px; }
  .result-actions { flex-direction: column; }
  .calc-tab { padding: 14px 20px; font-size: 14px; }
  .alt-plans-grid { grid-template-columns: 1fr; gap: 8px; }
  .alt-plan { padding: 10px; display: flex; align-items: center; justify-content: space-between; text-align: left; }
  .alt-plan-capacity { font-size: 15px; }
  .alt-plan-desc { margin-top: 0; font-size: 12px; }
  .alt-plan-details { display: none; }
  .cycle-mode-tabs { flex-direction: column; gap: 6px; }
  .cycle-mode-tab { padding: 8px 12px; font-size: 13px; }
  .recommend-main { text-align: left; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 12px; margin-bottom: 12px; }
  .recommend-capacity { display: flex; }
  .limits-grid { grid-template-columns: 1fr 1fr; }
  .limit-item { padding: 10px 8px; gap: 8px; }
  .limit-icon { width: 30px; height: 30px; font-size: 13px; flex-shrink: 0; }
  .limit-name { font-size: 11px; }
  .limit-value { font-size: 13px; }
  .cv-label { font-size: 13px; }
  .cv-value { font-size: 13px; }
}

@media (max-width: 480px) {
  .calc-wrapper { gap: 16px; }
  .calc-form { padding: 12px; }
  .calc-result { padding: 12px; overflow: hidden; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .form-group label { font-size: 11px; }
  .form-group .form-control { padding: 7px 8px; font-size: 12px; }
  .result-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .result-value { font-size: 22px; }
  .result-label { font-size: 11px; }
  .capacity-value { font-size: 32px; }
  .capacity-unit { font-size: 18px; }
  .recommend-power { font-size: 13px; }
  .recommend-badge { font-size: 10px; padding: 3px 7px; }
  .limits-grid { grid-template-columns: 1fr; }
  .alt-plans-grid { grid-template-columns: 1fr; }
  .detail-label { font-size: 12px; }
  .detail-value { font-size: 13px; }
  .cv-label { font-size: 12px; }
  .cv-value { font-size: 12px; white-space: nowrap; }
}