/* 全局样式 */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: #f5f7fa;
  color: #2c3e50;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* 应用容器 - 两栏布局 */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* 侧边栏 */
.sidebar {
  width: 320px;
  background: #fff;
  border-right: 1px solid #e4e7ed;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #e4e7ed;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.sidebar-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sidebar-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.sidebar form {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

/* 控制区块 */
.control-section {
  margin-bottom: 16px;
}

.control-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #606266;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.control-label-sm {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: #909399;
  margin-bottom: 4px;
}

/* 拖放区域 */
.drop-zone {
  border: 2px dashed #dcdfe6;
  border-radius: 8px;
  padding: 24px 16px;
  text-align: center;
  background: #fafbfc;
  transition: all 0.2s ease;
  cursor: pointer;
  margin-bottom: 12px;
}

.drop-zone:hover {
  border-color: #667eea;
  background: #f5f7ff;
}

.drop-zone.active {
  border-color: #667eea;
  background: #f0f3ff;
  transform: scale(1.01);
}

.drop-zone-icon {
  width: 40px;
  height: 40px;
  color: #909399;
  margin: 0 auto 8px;
}

.drop-zone-text {
  font-size: 12px;
  color: #606266;
  margin: 0 0 12px;
}

/* 文件输入列表 */
.file-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-input-wrapper {
  position: relative;
}

.file-item {
  display: grid;
  grid-template-columns: 8px 1fr;
  grid-template-rows: auto auto;
  gap: 8px 4px;
  padding: 10px 12px;
  background: #f5f7fa;
  border: 1px solid #e4e7ed;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.file-item:hover {
  border-color: #c0c4cc;
  background: #eceff5;
}

.file-item.has-file {
  background: #f0f3ff;
  border-color: #b3c0f7;
}

.file-item.has-file:hover {
  border-color: #8c9ff5;
}

.file-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.file-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.file-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.file-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.file-details {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 12px;
  color: #606266;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.file-item.has-file .file-name {
  color: #303133;
  font-weight: 500;
}

.label-color-container {
  display: flex;
  gap: 6px;
  align-items: center;
}

.file-label-input {
  flex: 1;
  font-size: 12px;
  height: 26px;
  padding: 2px 8px;
  background: white;
}

.offset-input {
  width: 50px;
  font-size: 12px;
  height: 26px;
  padding: 2px 6px;
  background: white;
  text-align: center;
}

/* 隐藏数字输入框的上下箭头 */
.offset-input::-webkit-outer-spin-button,
.offset-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.offset-input[type="number"] {
  -moz-appearance: textfield;
}

.color-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.color-picker-trigger {
  width: 28px;
  height: 26px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.color-picker-trigger:hover {
  border-color: #667eea;
  transform: scale(1.05);
}

.color-picker-trigger:active {
  transform: scale(0.98);
}

.color-panel {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  padding: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: none;
  grid-template-columns: repeat(6, 28px);
  grid-template-rows: auto;
  gap: 8px;
  width: fit-content;
}

.color-panel[style*="display: block"] {
  display: grid !important;
}

.color-option {
  width: 28px;
  height: 28px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.color-option:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.color-option.selected {
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
  transform: scale(1.1);
}

.file-item:not(.has-file) .label-color-container {
  display: none;
}

.file-remove-btn {
  font-size: 24px;
  line-height: 1;
  padding: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.file-item:hover .file-remove-btn {
  opacity: 1;
}

.file-remove-btn:hover {
  background: rgba(220, 53, 69, 0.1);
}

/* 高级选项 */
.btn-link.toggle-icon {
  font-size: 12px;
  color: #606266;
  font-weight: 500;
}

.toggle-icon {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.2s ease;
  margin-right: 4px;
}

.advanced-content {
  margin-top: 12px;
  padding: 12px;
  background: #fafbfc;
  border-radius: 6px;
  border: 1px solid #e4e7ed;
}

/* 提交按钮 */
.submit-btn {
  margin-top: auto;
  padding: 10px 20px;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  transition: all 0.2s ease;
}

.submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* 主内容区域 */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f5f7fa;
}

/* 错误提示 */
.alert-sm {
  font-size: 13px;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.alert-sm strong {
  font-weight: 600;
}

.alert-sm ul {
  margin-top: 8px;
  padding-left: 20px;
}

.alert-sm li {
  margin-bottom: 4px;
}

/* 图表结果 */
.plot-result {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.plot-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
  gap: 8px;
}

.plot-actions .btn {
  display: inline-flex;
  align-items: center;
  font-weight: 500;
  transition: all 0.2s ease;
}

.plot-actions .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.plot-actions .btn svg {
  flex-shrink: 0;
}

.plot-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
  padding: 40px 20px;
}

.empty-icon {
  width: 80px;
  height: 80px;
  color: #c0c4cc;
  margin-bottom: 20px;
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  color: #606266;
  margin: 0 0 8px;
}

.empty-text {
  font-size: 14px;
  color: #909399;
  margin: 0;
}

/* 表单控件优化 */
.form-control-sm,
.form-select-sm {
  font-size: 13px;
  height: 32px;
  padding: 4px 10px;
  border-color: #dcdfe6;
  transition: all 0.2s ease;
}

.form-control-sm:focus,
.form-select-sm:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-sm {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    max-height: 60vh;
    border-right: none;
    border-bottom: 1px solid #e4e7ed;
  }

  .main-content {
    flex: 1;
  }
}

/* 滚动条样式 */
.sidebar::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb {
  background: #dcdfe6;
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover {
  background: #c0c4cc;
}

/* 动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.plot-result,
.empty-state {
  animation: fadeIn 0.3s ease;
}

/* 拖拽排序样式 */
.file-item.dragging {
  opacity: 0.5;
}

.file-input-wrapper.drag-over {
  transform: translateY(-2px);
}

/* 拖拽手柄 */
.drag-handle {
  grid-row: 1 / 3;
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: move;
  color: #c0c4cc;
  font-size: 10px;
  line-height: 0.8;
  letter-spacing: -1.5px;
  opacity: 0;
  transition: opacity 0.2s ease;
  user-select: none;
  width: 100%;
  padding: 0 4px;
  margin-left: -4px;
}

.file-item:hover .drag-handle {
  opacity: 1;
}

.drag-handle:hover {
  color: #909399;
}

.file-content {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
