/* 
 * Excel 数据整理助手 - 主样式文件 (Bootstrap 5 版本)
 * 作者: AI Assistant
 * 描述: 补充 Bootstrap 5 没有的自定义样式
 */

/* CSS 变量定义 */
:root {
  /* 已有变量 */
  --form-label-min-height: 1.2rem;
  --form-small-font-size: 13px;
}

.dropdown-item,
.dropdown-item-text {
  font-size: var(--form-small-font-size);
}

.dropdown-item-text .form-check {
  min-height: 0;
}

.columns-dropdown .dropdown-item-text .form-check {
  display: flex !important;
  flex-direction: row !important;
  justify-content: flex-start !important;
  column-gap: 6px !important;
}

.input-group-sm .form-control-sm,
.input-group-sm .input-group-text {
  height: 28px;
  min-height: 28px;
}

.input-group-sm > .form-control {
  font-size: var(--form-small-font-size);
}

/* 拖拽上传区域样式 */
.drop-zone {
  border: 2px dashed var(--bs-primary) !important;
  background-color: var(--bs-primary-bg-subtle) !important;
  transition: all 0.2s ease;
}

/* 加载覆盖层样式 */
.loading-overlay-custom {
  backdrop-filter: blur(2px);
  z-index: 1050;
}

/* 初始化屏幕淡出动画 */
.fade-out {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* 表单字段组统一样式 */
.form-field-group {
  display: flex;
  flex-direction: column;
}

/* 表单水平组样式 */
.form-group-horizontal {
  display: flex;
  align-items: end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* 统一表单标签样式 */
.form-label.small {
  font-size: var(--form-small-font-size) !important;
  font-weight: 500;
  margin-bottom: 0.3rem;
  min-height: var(--form-label-min-height);
  display: flex;
  align-items: center;
  line-height: 1.2;
  word-wrap: break-word;
  hyphens: auto;
}

/* 统一表单控件样式 */
.form-control-sm,
.form-select-sm {
  font-size: var(--form-small-font-size);
  padding: 0.25rem 0.5rem;
  height: calc(1.5em + 0.5rem + 2px);
  line-height: 1.5;
}

.form-control::placeholder {
  color: #858585bf;
}

/* 统一按钮样式 */
.btn-sm {
  font-size: var(--form-small-font-size);
  padding: 0.25rem 0.5rem;
  line-height: 1.4;
}

/* 统一表单复选框样式 - 调整字体大小使其与input placeholder一致 */
.form-check.small {
  font-size: var(--form-small-font-size);
  margin-bottom: 0;
  min-height: 0;
  display: flex;
  column-gap: 4px;
  flex-shrink: 0;
}

.form-check-label.small {
  font-size: var(--form-small-font-size) !important;
  line-height: 1.5;
}

/* 网格行统一样式 */
.row.g-2 > [class*='col-'] .form-field-group,
.row.g-2 > [class*='col-'] .form-check {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.row.g-2 > [class*='col-'] .form-check {
  justify-content: end;
  padding-bottom: 0.125rem;
}

/* 动态项目样式 */
.dynamic-item {
  padding: 0.75rem !important;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  background-color: #f6f8fa;
}

.dynamic-item .card {
  padding: 0.5rem !important;
  border: 1px solid var(--bs-border-color-translucent);
}

/* 步骤控制按钮组 */
.step-controls {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.step-controls .btn {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  border-radius: var(--bs-border-radius-sm);
}

/* Bootstrap Tooltip 字体大小调整 */
.tooltip .tooltip-inner {
  font-size: var(--form-small-font-size) !important;
  line-height: 1.4;
  padding: 0.375rem 0.5rem;
  text-align: left;
}

.anchor-config + .manual-config,
.anchor-config + .border-top {
  border-top: 1px solid var(--bs-border-color) !important;
  padding-top: 1rem !important;
}

/* Nav Pills 轻量级样式 */
.nav-pills .nav-link {
  background-color: transparent !important;
  border: none !important;
  color: var(--bs-secondary) !important;
  border-radius: 0 !important;
  border-bottom: 2px solid transparent !important;
  transition: all 0.2s ease !important;
  font-weight: 500;
}

.nav-pills .nav-link:hover {
  background-color: var(--bs-light) !important;
  color: var(--bs-primary) !important;
  border-bottom-color: var(--bs-primary-bg-subtle) !important;
}

.nav-pills .nav-link.active {
  background-color: transparent !important;
  color: var(--bs-primary) !important;
  border-bottom-color: var(--bs-primary) !important;
  font-weight: 600;
}

/* 修复copy-json-btn图标显示 */
#copy-json-btn i {
  font-size: 0.875rem;
  line-height: 1;
}

#copy-json-btn .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Univer 集成样式 */
#excel-preview {
  position: relative;
}

/* excel 占位样式与交互 */
#excel-placeholder {
  cursor: default;
}

.excel-placeholder-card {
  appearance: none;
  border: 2px dashed var(--bs-primary);
  border-radius: 12px;
  background-color: var(--bs-primary-bg-subtle);
  color: var(--bs-primary);
  cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, transform 0.06s ease;
}

.excel-placeholder-card:hover {
  border-color: var(--bs-primary);
  background-color: rgba(13, 110, 253, 0.12);
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

.excel-placeholder-card:active {
  transform: scale(0.995);
}

/* 焦点可见状态，增强可访问性与显眼度 */
.excel-placeholder-card:focus-visible {
  outline: none;
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.3rem rgba(13, 110, 253, 0.2);
}

/* 处理中遮罩样式 */
#processing-overlay {
  background: rgba(248, 249, 250, 0.9);
  backdrop-filter: blur(5px);
}

/* 单元格选择器按钮样式 */
.cell-picker-btn {
  border-left: none;
}

.cell-picker-btn:first-child {
  border-left: 1px solid #dee2e6;
}

/* selection-cell-range 样式 */
.selection-cell-range {
  cursor: pointer;
  transition: all 0.2s ease;
}

.selection-cell-range:hover {
  background-color: var(--bs-primary-bg-subtle) !important;
  color: var(--bs-primary) !important;
  border-color: var(--bs-primary) !important;
}

.selection-cell-range.active {
  background-color: var(--bs-primary) !important;
  color: white !important;
  border-color: var(--bs-primary) !important;
}

/* 单元格选择模式提示样式 */
.cell-selection-alert {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  min-width: 320px;
  height: 44px;
  background: var(--bs-success-bg-subtle);
  color: var(--bs-success-text-emphasis) !important;
  padding: 0 20px;
  border-radius: 0 0 8px 8px;
  border: 1px solid var(--bs-success-border-subtle);
  border-top: none;
  font-size: 14px;
  animation: slideDown 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.cell-selection-alert .alert-icon {
  font-size: 16px;
  opacity: 0.9;
  flex-shrink: 0;
}

.cell-selection-alert .alert-text {
  flex: 1;
  line-height: 1.4;
}

.cell-selection-alert .alert-close {
  background: var(--bs-success-bg-subtle);
  border: 1px solid var(--bs-success-border-subtle);
  color: var(--bs-success-text-emphasis);
  font-size: 12px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 4px;
  transition: all 0.2s ease;
  opacity: 0.9;
  flex-shrink: 0;
  white-space: nowrap;
}

.cell-selection-alert .alert-close:hover {
  background: rgba(255, 255, 255, 0.2);
  opacity: 1;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-30px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

/* 输入框增强样式 */
.input-group input[data-cell-picker] {
  border-right: none;
}

.input-group .cell-picker-btn {
  border-left: none;
}

/* 工作表下拉菜单样式 */
.sheet-list-dropdown {
  max-height: 200px;
  overflow-y: auto;
}

.sheet-option {
  font-size: 0.875rem;
}

/* Univer 容器样式 */
.univer-container {
  width: 100% !important;
  height: 100% !important;
}

/* 优化 Univer 滚动体验 */
#excel-preview .univer-scrollbar-x,
#excel-preview .univer-scrollbar-y {
  scroll-behavior: smooth;
}

/* 减慢滚动速度 */
#excel-preview .univer-cell-main {
  scroll-behavior: smooth;
}

/* 自定义滚动条样式 */
#excel-preview ::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

#excel-preview ::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 6px;
}

#excel-preview ::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 6px;
  transition: background-color 0.2s;
}

#excel-preview ::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 动画效果 */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

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

/* 表单验证错误样式 */
.form-error {
  border-color: var(--bs-danger) !important;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

.error-message {
  color: var(--bs-danger);
  font-size: var(--form-small-font-size);
  margin-top: 0.25rem;
  display: block;
  line-height: 1.4;
  animation: fadeIn 0.2s ease-in;
}

/* Excel 加载状态样式优化 */
#excel-preview .spinner-border {
  border-width: 0.25em;
}

#excel-preview .progress {
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}

#excel-preview .progress-bar {
  background: linear-gradient(45deg, #0d6efd, #0056b3);
}

/* Univer 批注功能样式修复 */
/* 修复批注 textarea 的宽度和高度问题 - 使用更通用的选择器 */
.univer-fixed textarea {
  min-width: 200px !important;
  min-height: 80px !important;
  width: 100% !important;
  height: auto !important;
  resize: both !important;
  box-sizing: border-box !important;
  padding: 8px !important;
  font-size: 14px !important;
  line-height: 1.4 !important;
  border: 1px solid #d0d7de !important;
  border-radius: 4px !important;
  background-color: #ffffff !important;
  resize: none !important;
}

/* Univer 头部样式 */
header.univer-relative {
  padding-right: 40px;
  border-bottom: 1px solid var(--univer-gray-200);
}

header.univer-relative .univer-box-border {
  border: none;
}

/* 数据检查按钮样式 */
.data-check-button {
  position: absolute;
  top: 7px;
  right: 10px;
  z-index: 1000;
}

/* 新版多步骤样式 */
.steps-container {
  padding: 4px;
  background-color: #f8f9fa;
  border-bottom: 1px solid var(--bs-border-color);
  display: flex;
  align-items: center;
}

.steps-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  column-gap: 8px;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.375rem; /* 6px */
  transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
  background-color: transparent;
  border: 1px solid transparent;
  flex: 1;
}

.step-item .step-number {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  color: #fff;
  background-color: #adb5bd; /* Default/inactive */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem; /* 12px */
  font-weight: 600;
  margin-bottom: 0.15rem; /* 4px */
  transition: background-color 0.2s ease-in-out;
  flex-shrink: 0;
}

.step-item .step-content {
  display: flex;
  flex-direction: column;
}

.step-item .step-title {
  font-size: 14px;
  font-weight: bold;
  line-height: 1.2;
  color: #495057; /* Default text */
  margin-bottom: 0.125rem;
}

.step-item .step-description {
  font-size: 12px;
  color: #6c757d;
  line-height: 1.2;
}

/* States */
.step-item:not(.active):hover {
  background-color: var(--bs-light);
}

.step-item.completed .step-number {
  background-color: var(--bs-success); /* Green */
}
.step-item.completed .step-title {
  color: var(--bs-success);
}

.step-item.active {
  background-color: #e7f1ff; /* Light blue background as per image */
  border-color: rgba(13, 110, 253, 0.2);
}
.step-item.active .step-number {
  background-color: var(--bs-primary); /* Blue */
}
.step-item.active .step-title {
  color: var(--bs-primary);
}

.step-connector {
  width: 20px;
  height: 1px;
  background-color: #dee2e6;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .steps-container {
    padding: 0.75rem 0.5rem;
  }
  .steps-wrapper {
    justify-content: space-around;
  }
  .step-item {
    width: 90px;
  }
  .step-description {
    display: none;
  }
  .step-connector {
    width: 15px;
    margin: 12px 0.25rem 0 0.25rem;
  }
}

/* 保持原有的nav-pills样式兼容性 */
.nav-pills {
  display: none;
}

/* 历史记录相关样式 */
.history-dropdown {
  min-width: 320px;
  max-width: 400px;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.history-list-container {
  max-height: 480px;
  overflow-y: auto;
}

.history-item {
  padding: 0.75rem !important;
  cursor: pointer;
  border: none;
  background: transparent;
  transition: background-color 0.2s ease;
}

.history-item:hover {
  background-color: var(--bs-light) !important;
}

.history-item:focus {
  background-color: var(--bs-light) !important;
  outline: none;
}

.history-filename {
  font-size: 0.875rem;
  line-height: 1.3;
  max-width: 240px;
  color: var(--bs-dark);
}

.history-type {
  font-size: 0.75rem !important;
  padding: 0.2rem 0.4rem !important;
  border-radius: 0.25rem !important;
  border: 1px solid var(--bs-border-color) !important;
}

.history-time {
  font-size: 0.75rem;
  white-space: nowrap;
}

.dropdown-header {
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  color: var(--bs-dark);
}

#clear-history-btn {
  font-size: 0.875rem;
  text-decoration: none !important;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

#clear-history-btn:hover {
  opacity: 1;
}

/* 历史记录下拉菜单滚动条样式 */
.history-list-container::-webkit-scrollbar {
  width: 6px;
}

.history-list-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.history-list-container::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
  transition: background-color 0.2s;
}

.history-list-container::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.validator-alert {
  font-size: var(--form-small-font-size);
  padding: 8px;
}

.validator-errors {
  font-size: var(--form-small-font-size);
}

.form-text.small {
  font-size: var(--form-small-font-size);
}

.selected-columns-tags .badge {
  font-weight: normal;
}

.remove-aggregation {
  height: 28px;
}

/* 列下拉菜单按钮文本样式 */
.columns-dropdown-button-text {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  display: inline-block;
  max-width: calc(100% - 20px);
  line-height: 15px;
  vertical-align: -2px;
}

.config-panel .nav-tabs .nav-link {
  font-size: 14px;
  padding: 6px 12px;
}

.config-panel .validator-errors .form-check-input[type='checkbox'],
.config-panel .validator-alert .form-check-input[type='checkbox'] {
  margin-top: 0;
}

.dropdown-toggle {
  border: var(--bs-border-width) solid var(--bs-border-color);
  color: var(--bs-body-color);
}

/* 移动端优化 */
@media (max-width: 768px) {
  .history-dropdown {
    min-width: 280px;
    max-width: 95vw;
  }

  .history-filename {
    max-width: 180px;
  }
}
