/**
 * 模态框、操作抽屉与浮窗样式
 */

/* 遮罩背景 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 模态框主体 */
.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: scaleUp 0.22s ease-out;
}

#workout-modal .modal-container {
  max-width: 760px;
  width: 95vw;
}

@keyframes scaleUp {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* 模态框顶部 */
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
}

.close-btn:hover {
  color: var(--text-primary);
}

/* 模态框可滚动内容区 */
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* 模态框底部操作栏 */
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* 按钮规范 */
.btn {
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-secondary {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.btn-primary {
  background: var(--brand-red);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-red-dark);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

/* === 动作录入专属布局 === */

/* 动作筛选标签栏 */
.filter-chips-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
  scrollbar-width: thin;
}

.filter-chip {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
}

.filter-chip.active {
  background: var(--brand-red);
  color: #fff;
  border-color: var(--brand-red);
}

/* 搜索与动作选择 */
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.search-input-wrap .form-input {
  flex: 1;
  min-width: 0;
}

#open-custom-ex-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
}

.form-input {
  width: 100%;
  padding: 9px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  border-color: var(--brand-red);
}

/* 动作列表选择栅格 */
.exercise-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px;
  background: var(--bg-tertiary);
  margin-bottom: 16px;
}

.exercise-option-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.exercise-option-btn:hover {
  border-color: var(--brand-red);
}

.exercise-option-btn.selected {
  border-color: var(--brand-red);
  background: var(--brand-red-light);
  box-shadow: 0 0 0 1px var(--brand-red);
}

.ex-opt-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.ex-opt-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 选定动作后的即时联动受力预览栏 (正反双联全景大图) */
.selected-exercise-preview-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

@media (max-width: 680px) {
  .selected-exercise-preview-box {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
}

.mini-preview-svg-wrap {
  width: 290px;
  min-height: 250px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 680px) {
  .mini-preview-svg-wrap {
    width: 100%;
    min-height: 220px;
  }
}

.modal-preview-bodies-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
}

.modal-preview-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 135px;
}

.modal-preview-card svg {
  width: 100%;
  height: auto;
  max-height: 240px;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.06));
}

.modal-preview-card .svg-label {
  display: none !important;
}

.preview-card-caption {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-top: 4px;
  letter-spacing: 1px;
}

.preview-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.preview-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.preview-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2px;
}

.badge-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.badge-primary-target {
  background: var(--brand-red);
  color: #fff;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.35);
}

.badge-secondary-target {
  background: rgba(239, 68, 68, 0.15);
  color: var(--brand-red);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-bw {
  background: #3b82f6;
  color: #fff;
}

.preview-tip {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  background: var(--bg-card);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.preview-interactive-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

/* 组数表格 */
.sets-table-wrap {
  margin-top: 10px;
}

.sets-table-header {
  display: grid;
  grid-template-columns: 48px 1fr 1fr 40px;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 4px;
  text-align: center;
}

.sets-row-item {
  display: grid;
  grid-template-columns: 48px 1fr 1fr 40px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.set-index-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-muted);
}

.number-input-field {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  outline: none;
}

.number-input-field:focus {
  border-color: var(--brand-red);
}

.del-set-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  height: 36px;
}

.del-set-btn:hover {
  color: var(--brand-red);
  background: var(--border-color);
}

.add-set-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

.calc-vol-summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.calc-vol-summary strong {
  color: var(--brand-red);
  font-size: 1.05rem;
}

/* === 悬停/点击肌群浮窗 (Muscle Popover) === */
.muscle-popover {
  position: absolute;
  z-index: 999;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
  width: 260px;
  max-width: calc(100vw - 24px);
  pointer-events: auto;
  animation: popIn 0.16s ease-out;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.popover-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.popover-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.popover-close-btn:hover {
  color: var(--brand-red);
  background: var(--bg-tertiary);
}

.popover-muscle-name {
  font-size: 0.95rem;
  font-weight: 700;
}

.popover-percent {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--brand-red);
}

.popover-progress-track {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 8px;
}

.popover-progress-fill {
  height: 100%;
  background: var(--brand-red);
  border-radius: var(--radius-full);
}

.popover-detail-item {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.popover-detail-item span.val {
  color: var(--text-primary);
  font-weight: 600;
}

/* === 设置面板样式 === */
.settings-section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 16px;
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.setting-label {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.setting-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.target-field-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.target-field-name {
  font-size: 0.8rem;
  font-weight: 600;
}

.target-field-input {
  width: 70px;
  padding: 4px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.theme-toggle-group {
  display: inline-flex;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.theme-btn {
  background: transparent;
  border: none;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.theme-btn.active {
  background: var(--bg-card);
  color: var(--brand-red);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
