/* =====================================================
   电脑维修店进销存系统 - PC端全局样式
   技术栈：Bootstrap 5 + jQuery + Chart.js
   ===================================================== */

:root {
    --primary: #2563eb;
    --primary-light: #dbeafe;
    --primary-dark: #1d4ed8;
    --success: #059669;
    --success-light: #d1fae5;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;
    --dark: #1e293b;
    --muted: #64748b;
    --muted-light: #94a3b8;
    --border: #e2e8f0;
    --bg: #ffffff;
    --bg2: #f8fafc;
    --bg3: #f1f5f9;
    --sidebar-w: 220px;
    --topbar-h: 56px;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    font-size: 14px;
    color: var(--dark);
    background: var(--bg2);
    margin: 0;
}

/* === 登录页 === */
.login-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    width: 400px;
    padding: 40px;
}
.login-logo {
    text-align: center;
    margin-bottom: 30px;
}
.login-logo .icon {
    width: 64px; height: 64px;
    background: var(--primary);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 28px;
    margin-bottom: 12px;
}
.login-logo h3 { margin: 0; font-size: 20px; font-weight: 700; }
.login-logo p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

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

/* 顶部栏 */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 1030;
}
.topbar .shop-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
    white-space: nowrap;
}
.topbar .global-search {
    flex: 1;
    max-width: 400px;
    margin: 0 24px;
    position: relative;
}
.topbar .global-search input {
    width: 100%;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 12px 0 36px;
    font-size: 13px;
    background: var(--bg2);
}
.topbar .global-search .search-icon {
    position: absolute;
    left: 10px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted-light);
}
.topbar .topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}
.topbar .user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 8px;
    transition: background .15s;
}
.topbar .user-menu:hover { background: var(--bg2); }
.topbar .user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: #1e293b;
    overflow-y: auto;
    z-index: 1020;
    transition: width .2s;
}
.sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.sidebar .nav-item:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
}
.sidebar .nav-item.active {
    color: #fff;
    background: rgba(37,99,235,0.15);
    border-left-color: var(--primary);
}
.sidebar .nav-item .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}
.sidebar .nav-section {
    padding: 16px 20px 6px;
    font-size: 11px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* 内容区 */
.content-area {
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    padding: 20px;
    flex: 1;
}

/* 面包屑 */
.breadcrumb-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.breadcrumb-bar .page-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}
.breadcrumb-bar .breadcrumb {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

/* === 卡片 === */
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 12px;
}
.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

/* === 数据表格 === */
.data-table {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.data-table table {
    margin: 0;
}
.data-table thead th {
    background: var(--bg2);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    padding: 12px 16px;
}
.data-table tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg2); }

/* === 筛选栏 === */
.filter-bar {
    background: #fff;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.filter-bar .form-control,
.filter-bar .form-select {
    height: 34px;
    font-size: 13px;
}
.filter-bar .btn {
    height: 34px;
    font-size: 13px;
    padding: 0 14px;
    white-space: nowrap;
}
.filter-bar .btn-group {
    white-space: nowrap;
}

/* 商品管理 - 左侧分类树 */
.goods-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.category-sidebar {
    width: 200px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}
.category-sidebar h6 {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: 600;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.cat-sidebar-title {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 6px 8px 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
    color: var(--text);
}
.cat-tree {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 12px;
}
.cat-tree ul {
    list-style: none;
    padding-left: 14px;
    margin: 0;
}
.cat-tree li {
    margin: 1px 0;
}
.cat-tree .cat-node {
    display: flex;
    align-items: center;
    padding: 4px 6px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
    gap: 4px;
    position: relative;
}
.cat-tree .cat-node:hover {
    background: var(--bg2);
    transform: translateX(2px);
}
.cat-tree .cat-node.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}
.cat-tree .cat-node.active:hover {
    transform: translateX(0);
}
.cat-tree .cat-toggle {
    width: 14px;
    text-align: center;
    color: var(--muted);
    font-size: 10px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
.cat-tree .cat-node:hover .cat-toggle {
    color: var(--primary);
}
.cat-tree .cat-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cat-tree .cat-count {
    color: var(--muted);
    font-size: 10px;
    flex-shrink: 0;
    background: var(--bg2);
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}
.cat-tree .cat-node.active .cat-count {
    color: var(--primary);
    background: rgba(13, 110, 253, 0.1);
}
.goods-main {
    flex: 1;
    min-width: 0;
}

/* 快捷筛选按钮组 */
.quick-filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.quick-filter-bar .btn {
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 12px;
}
.quick-filter-bar .btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* 新增商品高亮闪烁 */
@keyframes highlightPulse {
    0%, 100% { background-color: rgba(255, 193, 7, 0.3); }
    50% { background-color: rgba(255, 193, 7, 0.6); }
}
.new-goods-highlight {
    animation: highlightPulse 1s ease-in-out 3;
}

/* 待结客户/供应商板块 */
.debt-section {
    background: #fff;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.debt-section-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.debt-count {
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    padding: 1px 8px;
    border-radius: 10px;
    font-weight: 500;
}
.debt-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.debt-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #fff8e6;
    border: 1px solid #ffe69c;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 200px;
    gap: 12px;
}
.debt-item:hover {
    background: #fff3cd;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.debt-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}
.debt-item-amount {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.debt-item-amount i {
    color: var(--muted);
    font-size: 12px;
}

/* 表格操作列不换行 */
.data-table tbody td:last-child {
    white-space: nowrap;
}
.data-table tbody td .btn-group-sm > .btn {
    padding: 2px 8px;
    font-size: 12px;
}

/* === 状态标签 === */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.status-badge.pending { background: var(--muted-light); color: #fff; }
.status-badge.checking { background: var(--info); color: #fff; }
.status-badge.repairing { background: var(--warning); color: #fff; }
.status-badge.done { background: var(--success); color: #fff; }
.status-badge.picked { background: var(--primary); color: #fff; }
.status-badge.normal { background: var(--success-light); color: var(--success); }
.status-badge.returned { background: var(--danger-light); color: var(--danger); }
.status-badge.warn { background: var(--danger-light); color: var(--danger); }
.status-badge.ok { background: var(--success-light); color: var(--success); }

/* === 步骤条 === */
.step-bar {
    display: flex;
    align-items: center;
    margin-bottom: 24px;
    padding: 20px 0;
}
.step-bar .step {
    display: flex;
    align-items: center;
    flex: 1;
    position: relative;
}
.step-bar .step-circle {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--border);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    z-index: 1;
    flex-shrink: 0;
}
.step-bar .step.active .step-circle {
    background: var(--primary);
    color: #fff;
}
.step-bar .step.done .step-circle {
    background: var(--success);
    color: #fff;
}
.step-bar .step-label {
    margin-left: 8px;
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}
.step-bar .step.active .step-label { color: var(--dark); font-weight: 600; }
.step-bar .step::after {
    content: '';
    position: absolute;
    top: 16px;
    left: 32px;
    right: -8px;
    height: 2px;
    background: var(--border);
}
.step-bar .step:last-child::after { display: none; }
.step-bar .step.done::after { background: var(--success); }

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

/* === 分页 === */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid var(--border);
}
.pagination-bar .page-info { font-size: 12px; color: var(--muted); }
.pagination-bar .pagination { margin: 0; }
.pagination-bar .page-link {
    font-size: 13px;
    color: var(--primary);
    border: 1px solid var(--border);
    padding: 4px 10px;
}
.pagination-bar .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* === 加载遮罩 === */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* === Toast 提示 === */
.toast-container {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 9999;
}
.toast-msg {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 12px 20px;
    margin-bottom: 8px;
    font-size: 14px;
    border-left: 4px solid var(--primary);
    min-width: 280px;
    animation: slideIn .3s ease;
}
.toast-msg.success { border-left-color: var(--success); color: var(--success); }
.toast-msg.error { border-left-color: var(--danger); color: var(--danger); }
.toast-msg.warning { border-left-color: var(--warning); color: var(--warning); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === 模态框增强 === */
.modal-content { border-radius: 12px; border: none; }
.modal-header { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--border); padding: 12px 20px; }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }

/* === 表单增强 === */
.form-label { font-size: 13px; font-weight: 600; color: var(--dark); margin-bottom: 4px; }
.form-control, .form-select { font-size: 13px; border-color: var(--border); }
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* 日期选择器：点击文本框任意位置即可弹出日历（通过JS控制，避免CSS覆盖其他输入框） */
input[type="date"] {
    cursor: pointer;
}

/* === 按钮 === */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-sm { font-size: 12px; padding: 2px 10px; }

/* === 图表容器 === */
.chart-container {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.chart-container .chart-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 16px;
}
.chart-wrapper { position: relative; height: 280px; }

/* === 图片缩略图 === */
.img-thumb {
    width: 40px; height: 40px;
    border-radius: 6px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid var(--border);
}
.img-preview-list { display: flex; gap: 8px; flex-wrap: wrap; }
.img-preview-list img {
    width: 80px; height: 80px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid var(--border);
}

/* === 上传区域 === */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s;
}
.upload-area:hover { border-color: var(--primary); }
.upload-area .upload-icon { font-size: 28px; color: var(--muted-light); }

/* === 快捷入口 === */
.quick-entry {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.quick-entry .quick-card {
    flex: 1;
    min-width: 140px;
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all .2s;
}
.quick-entry .quick-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37,99,235,0.1);
}
.quick-entry .quick-card .q-icon {
    font-size: 24px;
    margin-bottom: 6px;
}
.quick-entry .quick-card .q-label {
    font-size: 13px;
    font-weight: 600;
}

/* === 明细表格（弹窗内） === */
.detail-table {
    width: 100%;
    font-size: 13px;
}
.detail-table th { background: var(--bg2); padding: 8px 12px; font-weight: 600; }
.detail-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }

/* === 待办列表 === */
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-list .todo-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.todo-list .todo-item:last-child { border-bottom: none; }
.todo-list .todo-item:hover { background: var(--bg2); }
.todo-list .todo-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
}
.todo-list .todo-dot.urgent { background: var(--danger); }
.todo-list .todo-dot.normal { background: var(--warning); }
.todo-list .todo-dot.info { background: var(--info); }
.todo-list .todo-text { flex: 1; font-size: 13px; }
.todo-list .todo-time { font-size: 11px; color: var(--muted); }

/* === 滚动条 === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--muted-light); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* === 响应式 === */
@media (max-width: 1024px) {
    .sidebar { width: 60px; }
    .sidebar .nav-item span:not(.nav-icon) { display: none; }
    .sidebar .nav-section { display: none; }
    .content-area { margin-left: 60px; }
}
