/* ============================================
   恒光科技一体化 ERP V5.0 — 全局样式
   ============================================ */

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --success: #0d904f;
  --warning: #f29900;
  --danger: #d93025;
  --bg: #f5f6fa;
  --bg-white: #ffffff;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-light: #80868b;
  --border: #dadce0;
  --border-light: #e8eaed;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 6px;
  --radius-lg: 10px;
  --sidebar-width: 220px;
  --header-height: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-width);
  background: #1e2a3a;
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}

.sidebar-logo h2 {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.sidebar-logo small {
  color: rgba(255,255,255,0.5);
  font-size: 11px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.nav-section {
  margin-bottom: 16px;
}

.nav-section-title {
  padding: 8px 16px;
  font-size: 11px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  letter-spacing: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  font-size: 14px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.nav-item.active {
  background: rgba(26,115,232,0.3);
  color: #fff;
  border-left-color: var(--primary);
}

.nav-item .icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.user-name { color: #fff; }
.user-role { color: rgba(255,255,255,0.5); font-size: 11px; }

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

/* 顶部栏 */
.topbar {
  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;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* 内容区 */
.page-content {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
}

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

/* 卡片 */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  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;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-white);
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { background: var(--bg); }

.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 { background: #0b7a43; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #c5221f; }

.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 15px; }

/* 表单 */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-white);
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.form-textarea { resize: vertical; min-height: 60px; }

.form-input-sm { padding: 5px 8px; font-size: 13px; }

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-row .form-group { flex: 1; min-width: 150px; }

/* 表格 */
.table-container { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table th {
  background: var(--bg);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}

table tbody tr:hover { background: var(--primary-light); }

.table-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.table-center { text-align: center; }

/* 弹窗/模态框 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
}

.modal-lg { max-width: 1000px; }

/* combobox 下拉面板 */
.picker-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 320px;
  overflow-y: auto;
  z-index: 1100;
  min-width: 360px;
}
.picker-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.picker-item:last-child { border-bottom: none; }
.picker-item:hover, .picker-item.active {
  background: var(--primary-light);
}
.picker-item .picker-code {
  font-weight: 600;
  color: var(--primary);
  margin-right: 6px;
}
.picker-item .picker-extra {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}
.picker-search {
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--bg-white);
}

/* 通用弹窗内容（与 .modal 相同，兼容 modal-content 类名） */
.modal-content {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 16px; font-weight: 600; }

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--bg); }

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* 标签/徽章 */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.badge-draft { background: #e8eaed; color: #5f6368; }
.badge-pending { background: #fef7e0; color: #e37400; }
.badge-valid { background: #e6f4ea; color: #137333; }
.badge-won { background: #ceead6; color: #0d652d; }
.badge-cancelled { background: #fce8e6; color: #c5221f; }
.badge-constructing { background: #e8f0fe; color: #1967d2; }
.badge-completed { background: #e6f4ea; color: #137333; }
.badge-terminated { background: #fce8e6; color: #c5221f; }

/* 提示消息 */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }

/* 加载 */
.loading { text-align: center; padding: 40px; color: var(--text-light); }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* 动画 */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .nav-item span:not(.icon) { display: none; }
  .sidebar .nav-section-title { display: none; }
  .sidebar-logo h2 { font-size: 14px; }
  .main-content { margin-left: 60px; }
  .form-row { flex-direction: column; }
}

/* ===== 报价模块样式 (对标baijia.lzhgkj.cn) ===== */
.tabs { display:flex; gap:10px; margin-bottom:16px; justify-content:center; flex-wrap:wrap; }
.tabs .tab { padding:10px 24px; background:#fff; border-radius:8px; cursor:pointer; border:1px solid #e5e6eb; font-size:14px; transition:all 0.2s; }
.tabs .tab.active { background:#165DFF; color:#fff; border-color:#165DFF; }
.page { display:none; }
.page.active { display:flex; }
.param-panel h3 { margin-bottom:12px; font-size:16px; }
.param-panel .form-item { margin-bottom:12px; }
.param-panel .form-item label { display:block; font-size:12px; margin-bottom:4px; color:#555; }
.param-panel .form-item input,.param-panel .form-item select { width:100%; padding:7px 8px; border:1px solid #e5e6eb; border-radius:6px; font-size:12px; }
.param-panel .btn { width:100%; margin-top:4px; }
.quote-table { border:none !important; border-radius:0 !important; overflow:visible !important; }
.quote-table td,.quote-table th { border:none !important; }
.quote-table .qt-inp:hover,.quote-table .qt-inp:focus { border-color:#165DFF !important; background:#f0f5ff !important; border-radius:4px; }
.saved-quote-item:hover { box-shadow:0 2px 8px rgba(0,0,0,0.1); }
@media print { .param-panel, .tabs, .btn, body>div:not(#quotePreview) { display:none !important; } }
