/* ===== 报价管理系统 - 主样式 ===== */
:root {
  --primary: #667eea;
  --primary-dark: #5a6fd6;
  --primary-light: #eef0ff;
  --danger: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
  --info: #3498db;
  --text-primary: #1a1a2e;
  --text-secondary: #666;
  --text-hint: #999;
  --border: #e8e8e8;
  --bg-page: #f5f6fa;
  --bg-white: #fff;
  --bg-hover: #f8f9ff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --sidebar-width: 220px;
  --header-height: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== 布局 ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.sidebar-brand .brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand .brand-icon svg { width: 18px; height: 18px; }
.sidebar-brand .brand-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-menu {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.menu-item {
  display: flex;
  align-items: center;
  padding: 11px 20px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
  gap: 10px;
  font-size: 14px;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.menu-item:hover {
  background: var(--bg-hover);
  color: var(--primary);
}
.menu-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 500;
}
.menu-item svg { width: 18px; height: 18px; flex-shrink: 0; }

/* 主内容区 */
.main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 顶部导航 */
.header {
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-left .page-title {
  font-size: 16px;
  font-weight: 600;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.user-role {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary);
}
.btn-logout {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-logout:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* 内容区 */
.content {
  flex: 1;
  padding: 24px;
}

/* ===== 通用组件 ===== */

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-text {
  border: none;
  background: transparent;
  color: var(--primary);
  padding: 4px 8px;
}
.btn-text:hover { background: var(--primary-light); }

/* 卡片 */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
}

/* 表格 */
.table-wrapper {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table th, table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table th {
  background: #fafbfc;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
}
table tr:hover td { background: var(--bg-hover); }

/* 搜索栏 */
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-input {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 13px;
  outline: none;
  min-width: 200px;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--primary); }
.search-select {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: 13px;
  outline: none;
  background: var(--bg-white);
  cursor: pointer;
}

/* 弹窗 */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 560px;
  max-width: 90vw;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.2s;
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-lg { width: 800px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-hint);
  font-size: 18px;
  transition: all 0.15s;
}
.modal-close:hover { background: #f0f0f0; color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
}

/* 表单 */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.form-group label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(102,126,234,0.1); }
textarea.form-control { height: auto; padding: 8px 12px; resize: vertical; min-height: 60px; }
.form-control:disabled { background: #f5f5f5; color: var(--text-hint); cursor: not-allowed; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* 状态标签 */
.status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.status-draft { background: #fff3cd; color: #856404; }
.status-sent { background: #cce5ff; color: #004085; }
.status-confirmed { background: #d4edda; color: #155724; }
.status-expired { background: #f8d7da; color: #721c24; }

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-hint);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* 分页 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}
.pagination-btns {
  display: flex;
  gap: 4px;
}
.pagination-btns button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.pagination-btns button:hover { border-color: var(--primary); color: var(--primary); }
.pagination-btns button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-btns button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Toast 提示 */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  max-width: 360px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }
@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* 金额 */
.price { font-family: 'Helvetica Neue', Arial, sans-serif; }
.price-large { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.price-small { font-size: 13px; color: var(--text-secondary); }

/* 确认对话框 */
.confirm-dialog {
  text-align: center;
  padding: 20px 0;
}
.confirm-dialog .confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff3cd;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.confirm-dialog .confirm-icon svg { width: 24px; height: 24px; color: var(--warning); }
.confirm-dialog .confirm-msg {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 8px;
}
.confirm-dialog .confirm-sub { font-size: 13px; color: var(--text-secondary); }

/* 隐藏 */
.hidden { display: none !important; }

/* ===== 配件图片样式 ===== */

/* 配件列表中的缩略图 (40×40) */
.part-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.part-thumb:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-md);
}

/* 配件列表中的无图占位 (40×40) */
.part-thumb-empty {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafbfc;
}

/* 内联小缩略图 (28×28) - 用于报价单配件行 */
.part-thumb-sm {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* 内联小缩略图无图占位 (28×28) */
.part-thumb-empty-sm {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafbfc;
}

/* 图片上传区域 */
.part-image-upload {
  width: 120px;
  height: 120px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.15s;
  background: #fafbfc;
}
.part-image-upload:hover {
  border-color: var(--primary);
}

/* 图片上传预览 */
.part-image-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 图片上传占位符 */
.part-image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-hint);
  font-size: 12px;
}
.part-image-placeholder svg {
  opacity: 0.4;
}


/* 创建报价单：选择客户弹窗 */
.modal-customer-select {
  width: min(1180px, calc(100vw - 48px));
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
}

.modal-customer-select .modal-body {
  padding: 20px 24px 24px;
  overflow-y: auto;
  overflow-x: hidden;
}

.modal-customer-select table {
  width: 100%;
  table-layout: fixed;
}

.modal-customer-select th,
.modal-customer-select td {
  white-space: normal;
  word-break: break-word;
  vertical-align: middle;
}

.modal-customer-select th:nth-child(1),
.modal-customer-select td:nth-child(1) {
  width: 100px;
}

.modal-customer-select th:nth-child(2),
.modal-customer-select td:nth-child(2) {
  width: 42%;
}

.modal-customer-select th:nth-child(3),
.modal-customer-select td:nth-child(3) {
  width: 150px;
}

.modal-customer-select th:nth-child(4),
.modal-customer-select td:nth-child(4) {
  width: 190px;
}

.modal-customer-select th:nth-child(5),
.modal-customer-select td:nth-child(5) {
  width: 90px;
  text-align: center;
}

.modal-customer-select .btn {
  justify-content: center;
}

@media (max-width: 900px) {
  .modal-customer-select {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
  }

  .modal-customer-select .modal-body {
    padding: 16px;
  }
}
