/* ===================================================================
   Component styles – ERP app
   Extracted from index.html <style> block. Pairs with utilities.css.
   =================================================================== */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #f0f9ff 0%, #fdf4ff 100%);
  font-size: 14px;
  min-height: 100vh;
}

.app { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: 230px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(24px);
  border-right: 1px solid rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo i {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 26px;
}

.sidebar-logo span {
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav {
  flex: 1;
  padding: 4px 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 9.5px 12px;
  cursor: pointer;
  gap: 10px;
  color: #2f3a4a;
  border-radius: 10px;
  margin-bottom: 2px;
  transition: all .2s;
  font-size: 13.5px;
}

.nav-item:hover {
  background: rgba(99,102,241,.08);
  color: #6366f1;
}

.nav-item.active {
  background: linear-gradient(135deg, #7a7dff, #ee8cff);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99,102,241,.3);
}

.nav-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-section {
  padding: 12px 14px 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #767676;
  font-weight: 600;
}

.nav-item .badge-dot {
  margin-left: auto;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
}

.nav-item .badge-num {
  margin-left: auto;
  background: rgba(255,255,255,.2);
  color: #fff;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 10px;
}

/* ===== Main layout ===== */
.main {
  margin-left: 230px;
  flex: 1;
  padding: 0;
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  padding: 16px 28px;
  background: rgba(255,255,255,.6);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,.04);
  position: sticky;
  top: 0;
  z-index: 99;
}

.header .page-title {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header .page-title .sub {
  font-size: 13px;
  color: #94a3b8;
  font-weight: 400;
}

.header .user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(99,102,241,.25);
}

.content {
  padding: 12px 15px;
}

/* ===== Cards ===== */
.card {
  background: #fff;
  border: none;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,.04);
  transition: box-shadow .2s;
}

.card-body { padding: 20px; }

.stat-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,.04);
  transition: all .2s;
  cursor: default;
}

.stat-card:hover {
  box-shadow: 0 8px 30px rgba(0,0,0,.08);
  transform: translateY(-2px);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-label {
  color: #94a3b8;
  font-size: 12px;
  margin-bottom: 2px;
  font-weight: 500;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -1px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Tables ===== */
.table-wrap {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,.04);
  overflow: hidden;
}

.table-toolbar {
  padding: 10px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.table-toolbar .left {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.table-toolbar .right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.table { margin: 0; }

.table th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.table th:hover { color: #6366f1; }

.table td {
  font-size: 13px;
  vertical-align: middle;
  padding: 5px 16px;
  border-color: #e0e0e0;
}

/* 隔行变色：偶数行淡蓝（限定 .table-wrap 下的表格）。暂时停用，保留备用。
   注意：Bootstrap 把背景画在单元格 td/th 上，所以要覆盖 --bs-table-bg，直接给 tr 设背景会被盖住。 */
/* .table-wrap .table tbody tr:nth-child(even) { --bs-table-bg: #f0f6ff; } */

/* hover：滑过任一行淡蓝（离开恢复），已选中行不受影响。
   .table-hover 用的是 --bs-table-bg-state（state 层，优先级最高），必须覆盖它，覆盖 --bs-table-bg 会被盖住。 */
.table-wrap .table tbody tr:hover > * { --bs-table-bg-state: #f2f8ff; }
/* 选中行：点击后固定高亮，始终只有一行；hover 时也保持不变，故同样写在 state 层 */
.table-wrap .table tbody tr.row-selected > *,
.table-wrap .table tbody tr.row-selected:hover > * { --bs-table-bg-state: #ebf3ff; }

.table-footer {
  padding: 8px 20px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: #94a3b8;
  font-size: 13px;
}

/* ===== Badges ===== */
.badge {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* 库存预警页统计按钮（复制 .badge，独立命名，供 alertCount0/1/2 使用） */
.stat-badge {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.gradient-blue   { background: linear-gradient(135deg, #dbeafe, #ede9fe); color: #6366f1; }
.gradient-green  { background: linear-gradient(135deg, #dcfce7, #ccfbf1); color: #10b981; }
.gradient-red    { background: linear-gradient(135deg, #fee2e2, #fce7f3); color: #ef4444; }
.gradient-yellow { background: linear-gradient(135deg, #fef3c7, #ffedd5); color: #f59e0b; }
.gradient-purple { background: linear-gradient(135deg, #ede9fe, #fce7f3); color: #8b5cf6; }
.gradient-gray   { background: #f1f5f9; color: #64748b; }

/* ===== Form controls ===== */
input.search, select.filter {
  border: 1px solid #cfcfcf;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  background: #ffffff;
  transition: all .2s;
  outline: none;
}

input.search:focus, select.filter:focus {
  border-color: #6366f1;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(99,102,241,.1);
}

/* ===== Buttons ===== */
.btn {
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.25);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(99,102,241,.35);
  transform: translateY(-1px);
}

.btn-outline {
  background: #fff;
  color: #64748b;
  border: 1.5px solid #e2e8f0;
}

.btn-outline:hover {
  border-color: #6366f1;
  color: #6366f1;
}

.btn-outline-info {
  color: #0891b2;
  border-color: #06b6d4;
  background-color: transparent;
}
.btn-outline-info:hover {
  color: #fff;
  background-color: #0891b2;
  border-color: #0891b2;
}

.btn-outline-warning {
  color: #d97706;
  border-color: #f59e0b;
  background-color: transparent;
}
.btn-outline-warning:hover {
  color: #fff;
  background-color: #d97706;
  border-color: #d97706;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: #94a3b8;
}

.empty-state i {
  font-size: 40px;
  margin-bottom: 12px;
  color: #cbd5e1;
}

.empty-state h6 { color: #64748b; }

/* ===== Modals ===== */
/* 强制确保未激活的Modal完全隐藏 */
.modal:not(.show) {
  display: none !important;
}

/* 强制所有 Modal 弹窗在页面正中央水平+垂直居中 */
.modal-dialog {
  display: flex !important;
  align-items: center !important;
  min-height: calc(100% - 3.5rem) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
@media (max-width: 575.98px) {
  .modal-dialog {
    min-height: calc(100% - 1rem) !important;
  }
}

.modal-content {
  border: none;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}

.modal-header {
  border-bottom: 1px solid #f1f5f9;
  padding: 18px 24px;
}

.modal-body { padding: 24px; }

.modal-footer {
  border-top: 1px solid #f1f5f9;
  padding: 14px 24px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 4px;
}

.form-control, .form-select {
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  padding: 8px 12px;
  font-size: 13px;
  transition: all .2s;
}

.form-control:focus, .form-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(99,102,241,.1);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: 12px;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  animation: slideIn .3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { background: linear-gradient(135deg, #10b981, #059669); }
.toast.error   { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.toast.info    { background: linear-gradient(135deg, #6366f1, #8b5cf6); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ===== Page sections ===== */
.page-section { display: none; }
.page-section.active { display: block; }

/* ===== Product image ===== */
.product-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: #f1f5f9;
  display: inline-block;
  vertical-align: middle;
  cursor: pointer;
}

/* ===== Product Image Hover Popover ===== */
.img-hover-popover {
  position: fixed;
  z-index: 99999;
  display: none;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 5px;
  pointer-events: none;
  box-sizing: border-box;
  transition: opacity .15s ease;
}

.img-hover-popover .img-hover-arrow {
  position: absolute;
  left: -7px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-right: 8px solid #ffffff;
  transform: translateY(-50%);
  filter: drop-shadow(-1px 0 0.5px rgba(0, 0, 0, 0.12));
}

.img-hover-popover .img-hover-preview {
  display: block;
  max-width: 280px;
  max-height: 280px;
  min-width: 140px;
  min-height: 140px;
  width: auto;
  height: auto;
  border-radius: 6px;
  background: #f8fafc;
  object-fit: contain;
}

/* ===== Price Inline Edit Button ===== */
.price-edit-btn {
  color: #64748b;
  opacity: 0;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  text-decoration: none;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 1px 2px;
  border-radius: 4px;
  margin-left: 1px;
  transition: opacity .15s ease, color .15s ease, background-color .15s ease;
}

tr:hover .price-edit-btn {
  opacity: 0.7;
  pointer-events: auto;
}

.price-edit-btn:hover {
  color: #4f46e5 !important;
  opacity: 1 !important;
  background-color: rgba(79, 70, 229, 0.08);
}

/* ===== Product Purchase URL Tag & Image Container ===== */
.product-img-wrap {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
}

.buy-link-tag {
  position: absolute;
  left: 100%;
  bottom: 1px;
  margin-left: 3px;
  color: #2563eb !important;
  text-decoration: none !important;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  z-index: 1;
  transition: opacity .15s ease, transform .15s ease;
}

.buy-link-tag:hover {
  text-decoration: none !important;
  opacity: 0.75;
  transform: scale(1.1);
}

/* ===== SKU Copy Button & Container ===== */
.sku-cell-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  vertical-align: middle;
  line-height: 1.2;
}

.sku-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sku-copy-btn {
  margin-left: 4px;
  color: #94a3b8 !important;
  opacity: 0;
  pointer-events: none;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  vertical-align: middle;
  text-decoration: none !important;
  transition: color .15s ease, opacity .15s ease;
}

tr:hover .sku-copy-btn {
  opacity: 0.85;
  pointer-events: auto;
}

.sku-copy-btn:hover {
  text-decoration: none !important;
  color: #2563eb !important;
  opacity: 1 !important;
}

.sku-copy-btn .icon-e3d9 {
  display: inline-block;
  vertical-align: middle;
  pointer-events: none;
}


.product-img-placeholder {
  width: 36px;
  height: 36px;
  background: #f1f5f9;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 11px;
  border-radius: 8px;
  margin: 0 auto;
  vertical-align: middle;
}

/* ===== Table loading ===== */
.table-loading {
  text-align: center;
  padding: 40px;
  color: #94a3b8;
}

/* ===== Stock states ===== */
.stock-low     { color: #ef4444 !important; font-weight: 700; }
.stock-warning { color: #f59e0b !important; font-weight: 600; }
.stock-normal  { color: #10b981; }

/* ===== PO item card ===== */
.po-item-card {
  background: #f8fafc;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid #f1f5f9;
}

/* ===== Timeline ===== */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: #e2e8f0;
}

.timeline-item {
  position: relative;
  margin-bottom: 18px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #cbd5e1;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px #e2e8f0;
}

.timeline-item.done::before {
  background: #10b981;
  box-shadow: 0 0 0 1px #10b981;
}

.timeline-item .time {
  font-size: 12px;
  color: #94a3b8;
}

.timeline-item .text {
  color: #334155;
  font-weight: 500;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
  .content {
    padding: 16px;
  }
}

/* ===== Column Selector Drag & Drop ===== */
#columnSelectorModal .modal-body,
#alertColumnSelectorModal .modal-body {
  padding: 0 !important;
}
#columnSelectorModal .modal-footer,
#alertColumnSelectorModal .modal-footer {
  padding: 8px 20px !important;
}
.py-1 {
  padding-top: .16rem !important;
  padding-bottom: .16rem !important;
}

.column-item {
  transition: background-color 0.15s ease, border-color 0.15s ease;
  user-select: none;
}
.column-item-draggable {
  background-color: #fff;
  border-color: #f1f5f9 !important;
  cursor: grab;
}
.column-item-draggable:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1 !important;
}
/* 被点击、抓取、拖拽时背景色改为 #ededed，拖拽完成或取消后恢复 */
.column-item-draggable:active,
.column-item-draggable.active-drag,
.column-item-draggable.dragging {
  background-color: #ededed !important;
  border-color: #d1d5db !important;
  cursor: grabbing;
}
.column-item .drag-handle {
  color: #94a3b8;
  cursor: grab;
}
.column-item-draggable:active .drag-handle,
.column-item-draggable.active-drag .drag-handle {
  cursor: grabbing;
}
