/* ============================================================
   鼎设计ERP - 全站按钮版式统一
   目标：页头/工具栏按钮同一高度、宽度随文字自适应、横向排列，
         各页面之间大小一致，不再一页大一页小。
   ============================================================ */

:root {
  --btn-height: 32px;
  --btn-pad-x: 14px;
  --btn-gap: 8px;
}

/* ---------- 1. 按钮统一高度，宽度随文字自适应 ---------- */
.btn,
.btn-sm {
  min-height: var(--btn-height);
  height: var(--btn-height);
  padding: 0 var(--btn-pad-x);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  line-height: 1;
  vertical-align: middle;
  white-space: nowrap;
  text-decoration: none;
}
.btn-sm {
  padding: 0 10px;
  font-size: 12px;
}
.btn-lg {
  min-height: 40px;
  height: 40px;
  padding: 0 20px;
  font-size: 14px;
}
.btn-xl {
  min-height: 46px;
  height: 46px;
  padding: 0 24px;
  font-size: 15px;
}

/* 同一行按钮组：横向排列、等间距 */
.btn-group,
.button-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-group .btn,
.button-group .btn {
  white-space: nowrap;
}

/* ---------- 2. 页头 / 工具栏：按钮横排、统一间距 ---------- */
.tpl-card-header,
.page-header,
.card-header,
.le-toolbar,
.toolbar,
.filter-bar,
.sub-header,
.dash-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--btn-gap);
}

/* 页头/工具栏内所有按钮统一高度（无论 btn/btn-sm/btn-primary） */
.tpl-card-header .btn,
.page-header .btn,
.card-header .btn,
.le-toolbar .btn,
.toolbar .btn,
.filter-bar .btn,
.sub-header .btn,
.dash-toolbar .btn {
  min-height: var(--btn-height);
  height: var(--btn-height);
  white-space: nowrap;
}

/* 页头右侧操作组靠右（仅当页头有多个子元素时） */
.tpl-card-header > div:not(:only-child):last-child,
.page-header > div:not(:only-child):last-child,
.card-header > div:not(:only-child):last-child {
  margin-left: auto;
}

/* 搜索按钮 / 搜索框 与普通按钮同款（统一高度、圆角、字号） */
.tpl-search-btn {
  min-height: var(--btn-height);
  height: var(--btn-height);
  padding: 0 var(--btn-pad-x);
  border-radius: 6px;
  font-size: 13px;
  gap: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex-shrink: 0;
}
.tpl-search-input {
  min-height: var(--btn-height);
  height: var(--btn-height);
  border-radius: 6px;
  font-size: 13px;
}
.tpl-add-btn {
  width: var(--btn-height);
  height: var(--btn-height);
  min-height: var(--btn-height);
}

/* ---------- 3. 表格行操作按钮：强制并排 ---------- */
td.actions,
.dt-actions,
.le-card-actions,
.row-actions,
.table-actions,
.op-btns,
td .btn,
td .le-action-btn {
  white-space: nowrap;
}
td.actions,
.dt-actions,
.le-card-actions,
.row-actions,
.table-actions,
.op-btns {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}
td .le-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: 6px;
  white-space: nowrap;
  vertical-align: middle;
}
td .le-action-btn.le-delete {
  margin-right: 0;
}
td.actions .le-action-btn,
.dt-actions .le-action-btn,
.le-card-actions .le-action-btn {
  margin-right: 0;
}

/* ---------- 4. 焦点与禁用统一 ---------- */
a.btn,
button.btn {
  cursor: pointer;
  user-select: none;
}
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn:disabled,
.btn.disabled {
  cursor: not-allowed;
  opacity: 1;
  background: #e5e7eb !important;
  background-image: none !important;
  color: #9ca3af !important;
  border-color: #e5e7eb !important;
  box-shadow: none !important;
}

/* ---------- 5. 移动端收紧 ---------- */
@media (max-width: 768px) {
  :root {
    --btn-height: 30px;
    --btn-pad-x: 11px;
    --btn-gap: 6px;
  }
  .btn-lg { height: 36px; min-height: 36px; }
}

/* ============================================================
   6. 全站按钮强制统一（单一配色 + 同一尺寸/形状）
   不再分主色/次色/文字/描边等多元样式，全部同一外观。
   ============================================================ */
.btn, .btn-primary, .btn-secondary, .btn-success, .btn-warning,
.btn-info, .btn-danger, .btn-text, .btn-icon, .tpl-search-btn,
.le-action-btn, .tpl-add-btn {
  min-height: var(--btn-height);
  height: var(--btn-height);
  padding: 0 var(--btn-pad-x);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  box-shadow: none;
  gap: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
}
.btn:hover, .btn-primary:hover, .btn-secondary:hover, .btn-success:hover,
.btn-warning:hover, .btn-info:hover, .btn-danger:hover, .btn-text:hover,
.btn-icon:hover, .tpl-search-btn:hover, .le-action-btn:hover, .tpl-add-btn:hover {
  background: var(--primary-dark);
  color: #fff;
  border-color: transparent;
  transform: none;
  box-shadow: none;
}
.btn:active, .btn-primary:active, .btn-danger:active, .tpl-search-btn:active {
  transform: none;
}
.btn-sm { padding: 0 10px; }
.btn-lg { height: 40px; min-height: 40px; padding: 0 20px; }
.btn-xl { height: 46px; min-height: 46px; padding: 0 24px; }
.btn-icon { width: var(--btn-height); min-width: var(--btn-height); padding: 0; }
.le-action-btn { padding: 0 8px; font-size: 12px; border-radius: 5px; }
.tpl-add-btn { width: auto; padding: 0 10px; border-radius: 6px; }
.btn.loading::before { color: #fff; }

/* ============================================================
   7. 强制按钮横排（兜底，不改页面结构）
   - 操作区/按钮组/弹窗脚：一律横排
   - td/span 内含 ≥2 个同级按钮：也横排（带 display:none 守卫，避免弹出隐藏弹层）
   ============================================================ */
td.actions,
.dt-actions,
.le-card-actions,
.row-actions,
.table-actions,
.op-btns,
.btn-group,
.button-group,
.modal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
td:not([style*="display:none"]):not([style*="display: none"]):has(> :is(.btn, button) + :is(.btn, button)),
span:not([style*="display:none"]):not([style*="display: none"]):has(> :is(.btn, button) + :is(.btn, button)),
footer:not([style*="display:none"]):not([style*="display: none"]):has(> :is(.btn, button) + :is(.btn, button)) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   8. 操作列“编辑/删除”等文字链接 → 统一红底按钮（和工具栏按钮一致）
   ============================================================ */
td.actions a, .dt-actions a, .le-card-actions a, .row-actions a,
.table-actions a, .op-btns a, td .op a, td .actions a {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: var(--btn-height) !important;
  height: var(--btn-height) !important;
  padding: 0 10px !important;
  border-radius: 6px !important;
  font-size: 12px !important;
  line-height: 1 !important;
  background: var(--primary) !important;
  color: #fff !important;
  border: 1px solid transparent !important;
  text-decoration: none !important;
  white-space: nowrap !important;
  gap: 4px !important;
  margin-right: 6px !important;
  vertical-align: middle !important;
  cursor: pointer !important;
}
td.actions a:last-child, .dt-actions a:last-child, .le-card-actions a:last-child,
.row-actions a:last-child, .table-actions a:last-child, .op-btns a:last-child,
td .op a:last-child, td .actions a:last-child {
  margin-right: 0 !important;
}
td.actions a:hover, .dt-actions a:hover, .le-card-actions a:hover,
.row-actions a:hover, .table-actions a:hover, .op-btns a:hover {
  background: var(--primary-dark) !important;
  color: #fff !important;
  text-decoration: none !important;
}


/* ============================================================
   v612-btn-row-fix 操作区按钮强制一排（不再上下堆叠）
   同一操作区内的按钮永远横向一排；窄屏排不下时整条横向滚动，
   而不是把按钮逐个挤到下一行。
   ============================================================ */
/* 1. 各类行内操作组：横向、不换行、可横向滑动 */
.le-actions, .le-card-actions, .le-toolbar-actions, .tpl-search-actions,
.btn-group, .button-group, .row-actions, .table-actions, .op-btns,
.dt-actions, td.actions, .modal-footer, .form-footer {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 6px;
  white-space: nowrap;
}
.le-actions, .le-card-actions, .row-actions, .table-actions, .op-btns,
.dt-actions, .tpl-search-actions, .le-toolbar-actions {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 2px;
}
/* 操作组内的按钮不被压缩、不独占整行 */
.le-actions > *, .le-card-actions > *, .le-toolbar-actions > *,
.tpl-search-actions > *, .btn-group > *, .button-group > *,
.row-actions > *, .table-actions > *, .op-btns > *, .dt-actions > *,
.modal-footer > *, .form-footer > * {
  flex: 0 0 auto !important;
  white-space: nowrap;
}
/* 列表引擎卡片按钮：内容自适应，不再 flex:1 平分挤压 */
.le-card-btn { flex: 0 0 auto !important; padding: 6px 12px !important; }

/* 2. 搜索栏 / 工具栏：整条一排，窄屏横向滚动 */
.tpl-search-bar, .search-bar, .filter-bar, .toolbar, .le-toolbar {
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch;
}
.tpl-search-bar > input, .search-bar > input,
.filter-bar > input, .toolbar > input, .le-toolbar .le-search-input {
  flex: 1 1 160px !important;
  min-width: 140px !important;
}
.tpl-search-bar > button, .tpl-search-bar > .btn,
.search-bar > button, .search-bar > .btn,
.filter-bar > button, .filter-bar > .btn,
.toolbar > button, .toolbar > .btn,
.le-toolbar-actions > button, .le-toolbar-actions .le-btn {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}
/* 工具栏内的筛选标签区允许整体换行，但标签彼此一排 */
.le-filters { flex-wrap: wrap; }

/* 3. PC 表格操作列：不固定窄宽度，按钮一排不折行 */
.le-actions { gap: 4px; }
th.le-actions-th { width: auto !important; min-width: 1%; white-space: nowrap; }

/* 4. 弹窗底部按钮一排、右对齐 */
.modal-footer { justify-content: flex-end; }

/* 5. 极窄屏（手机竖屏）：搜索框保持可用宽度，整条横滑，不竖排 */
@media (max-width: 480px) {
  .tpl-search-bar > input, .search-bar > input { min-width: 150px !important; }
  .le-card-actions { gap: 6px; }
}


/* ============================================================
   v612-btn-row-fix2 兜底：裸 td 与内联 flex 操作条也强制一排
   responsive.css / responsive-enhanced.css 用
   [style*="display:flex"]{flex-wrap:wrap} 误伤了行内按钮容器，
   这里以更高特异性把“装了≥2个按钮的操作区”改回横向一排。
   ============================================================ */
/* A. 表格单元格内直接放多个按钮 / 内联flex按钮盒：一排 */
td:has(> :is(button, a.btn) + :is(button, a.btn)),
td > div[style*="display:flex"]:has(> :is(button, a.btn)),
td > div[style*="display: flex"]:has(> :is(button, a.btn)) {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 6px !important;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
}
td:has(> :is(button, a.btn) + :is(button, a.btn)) > :is(button, a.btn) {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}
/* B. 页面中的内联 flex 批量操作条（≥2 直接按钮）一排，平分或自适应 */
div[style*="display:flex"]:has(> button + button),
div[style*="display: flex"]:has(> button + button),
div[style*="display:flex"]:has(> a.btn + a.btn),
div[style*="display: flex"]:has(> a.btn + a.btn) {
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  white-space: nowrap;
}
/* C. 覆盖响应式里对 .le-actions/.btn-group/.action-bar 的 wrap */
.le-actions, .action-bar, .btn-group, .button-group {
  flex-wrap: nowrap !important;
}
/* D. 表格最右操作列允许按内容撑开，不被固定窄宽挤换行 */
table { table-layout: auto; }
