// ================================
// 进销存管理平台 v2 - 样式
// ================================

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

body {
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: #2c3e50;
    min-height: 100vh;
    display: flex;
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: 50px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: width 0.25s ease;
    overflow: hidden;
}
.sidebar:hover {
    width: 220px;
}

.sidebar-version {
    padding: 8px;
    font-size: 10px;
    color: #889;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.08);
    line-height: 1.4;
}
.sidebar:hover .sidebar-version .collapsed-hidden {
    display: inline;
}
.sidebar .sidebar-version .collapsed-hidden {
    display: none;
}

.sidebar .brand {
    padding: 24px 0 16px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    white-space: nowrap;
}
.sidebar .brand h1 { font-size: 18px; font-weight: 700; }
.sidebar .brand small { font-size: 12px; color: #889; display: block; margin-top: 2px; }

/* 品牌折叠时只显示第一个字符小图标 */
.sidebar .brand .brand-collapsed {
    display: inline;
    line-height: 40px;
    font-size: 22px;
}
.sidebar .brand .brand-expanded {
    display: none;
}
.sidebar:hover .brand .brand-collapsed {
    display: none;
}
.sidebar:hover .brand .brand-expanded {
    display: inline;
}

/* 分组标签折叠时隐藏，展开时显示 */
.sidebar .nav-group-label {
    font-size: 11px;
    color: #668;
    padding: 8px 20px 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.sidebar:hover .nav-group-label {
    opacity: 1;
}

/* 导航项固定图标始终可见，但折叠时居中 */
.sidebar .nav { flex: 1; padding: 12px 0; }
.sidebar .nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 0;
    margin: 0 auto;
    cursor: pointer;
    color: #aaa;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap;
}
.sidebar .nav-item .nav-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    font-size: 18px;
}
/* 折叠时标签要是完全隐藏（不占空间），折叠状态是默认状态 */
.sidebar .nav-item .nav-label {
    display: none;
}
/* 展开时标签出现，图标左对齐 */
.sidebar:hover .nav-item {
    justify-content: flex-start;
    padding: 12px 20px;
}
.sidebar:hover .nav-item .nav-label {
    display: inline;
}
.sidebar .nav-item:hover { color: #fff; background: rgba(255,255,255,0.05); }
.sidebar .nav-item.active {
    color: #fff;
    background: rgba(26,115,232,0.2);
    border-left-color: #1a73e8;
    font-weight: 600;
}

/* ===== 主内容 ===== */
.main {
    margin-left: 50px;
    flex: 1;
    padding: 24px 28px;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}
/* 展开时内容区不动（导航栏覆盖在内容上面） */
.sidebar:hover ~ .main {
    margin-left: 50px;
}
.page-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}
.page-subtitle {
    font-size: 13px;
    color: #999;
    margin-bottom: 20px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 5;
    background: #fff;
    padding: 12px 0;
}
.toolbar-left {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
    align-items: center;
}
.toolbar-right {
    display: flex;
    gap: 8px;
}

/* 操作按钮条：筛选栏下方，固定不滚动，左对齐 */
.action-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 0 12px 0;

    /* 白色背景统一在父级 .tab-content（或各模块容器）上设置 */
}

.tab-content {
    background: #fff;
    border-radius: 10px;
    padding: 20px 24px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
/* 用得比较多的 * 标记 */
.required::after {
    content: '*';
    color: #ea4335;
    margin-left: 2px;
}

/* ===== 通用按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-primary { background: #1a73e8; color: #fff; }
.btn-primary:hover { background: #1557b0; }
.btn-success { background: #34a853; color: #fff; }
.btn-success:hover { background: #2d8f47; }
.btn-danger { background: #ea4335; color: #fff; }
.btn-danger:hover { background: #c62828; }
.btn-outline { background: #fff; color: #555; border: 1px solid #d9d9d9; }
.btn-outline:hover { border-color: #1a73e8; color: #1a73e8; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== 数据表格 ===== */
.table-wrap {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}
thead th {
    background: #f8f9fa;
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #eee;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
thead th:hover { color: #1a73e8; }
tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f5f5f5;
    vertical-align: middle;
}
tbody tr:hover { background: #f8faff; }
tbody tr:last-child td { border-bottom: none; }

/* ===== 弹窗 ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1600;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 12px;
    max-width: 780px;
    width: 92%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.2s ease;
}
.modal-box .form-grid {
    gap: 14px 20px;
    display: block;
}

/* 弹窗顶部固定区域 — flex 自然固定，不上浮 */
.modal-box .modal-top-fixed {
    flex-shrink: 0;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px 12px;
    border-bottom: 1px solid #e8eaed;
}
.modal-box .modal-top-fixed h2 {
    font-size: 18px;
    margin: 0;
}
.modal-box .modal-top-fixed .modal-close {
    font-size: 24px;
    cursor: pointer;
    color: #999;
    border: none;
    background: none;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
}
.modal-box .modal-top-fixed .modal-close:hover { color: #333; background: #f5f5f5; }

/* 弹窗底部固定区域 — flex 自然固定，不浮在文本上 */
.modal-box .modal-bottom-fixed {
    flex-shrink: 0;
    background: #fff;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 32px 20px;
    border-top: 1px solid #e8eaed;
}

/* 弹窗内容滚动区域 */
.modal-box .modal-scroll-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}

/* 编辑弹窗表单 — 包裹 scroll-content + bottom-fixed */
.modal-form-flex {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* 兼容旧直排结构（详情弹窗无 modal-top-fixed 的备用） */
.modal-box.modal-legacy {
    padding: 24px 32px;
    overflow-y: auto;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== 表单 ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-group label {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #444;
    margin-bottom: 5px;
    font-weight: 600;
}
.form-group label .label-en {
    margin-left: 4px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #333;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.4;
    box-sizing: border-box;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26,115,232,0.1);
}
.form-group textarea {
    min-height: 60px;
    resize: vertical;
}
select {
    background: #fff;
    cursor: pointer;
}

/* ===== 图片预览 ===== */
.img-preview {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #eee;
    cursor: pointer;
}
.img-upload-area {
    border: 2px dashed #d9d9d9;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    color: #999;
    cursor: pointer;
    transition: all 0.2s;
}
.img-upload-area:hover { border-color: #1a73e8; color: #1a73e8; }

/* ===== 树形组件 ===== */
.cat-tree { padding: 8px 0; }
.cat-node { margin: 2px 0; }
.cat-node-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.cat-node-header:hover { background: #f0f4ff; }
.cat-node-children { padding-left: 22px; }
.cat-leaf {
    padding: 4px 10px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    border-radius: 4px;
}
.cat-leaf:hover { background: #f0f4ff; color: #1a73e8; }
.tree-toggle { font-size: 10px; color: #aaa; width: 16px; }

/* ===== 统计卡片 ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
.stat-card .num { font-size: 26px; font-weight: 700; color: #1a73e8; margin-top: 4px; }
.stat-card .label { font-size: 13px; color: #888; }

/* ===== 小标签 ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 500;
}
.badge-green { background: #e6f4ea; color: #1e7e34; }
.badge-red { background: #fce8e6; color: #c62828; }
.badge-blue { background: #e8f0fe; color: #1a73e8; }
.badge-yellow { background: #fef7e0; color: #f9ab00; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .sidebar { width: 50px; }
    .sidebar .brand .brand-expanded, .sidebar .nav-item .nav-label { display: none; }
    .sidebar .nav-item { justify-content: center; padding: 14px; font-size: 18px; }
    .main { margin-left: 50px; padding: 16px; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}

/* ===== ERP官网管理 ===== */
.wm-root {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    min-height: 500px;
}
.wm-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.wm-header h2 {
    font-size: 22px;
    font-weight: 700;
}
.wm-body {
    flex: 1;
    display: flex;
    gap: 20px;
    overflow: hidden;
}
.wm-config-panel {
    width: 360px;
    min-width: 240px;
    max-width: 800px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
    overflow-y: auto;
    position: relative;
}
.wm-preview-panel {
    flex: 1;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.wm-preview-header {
    padding: 10px 16px;
    font-size: 13px;
    color: #555;
    background: #f8f9fa;
    border-bottom: 1px solid #e8eaed;
    flex-shrink: 0;
}
.wm-preview-frame {
    flex: 1;
    overflow: auto;
    background: #f0f2f5;
}
.wm-preview-frame > * {
    max-width: 100%;
}
.wm-config-sections {
    padding: 8px;
}
.wm-section {
    border: 1px solid #e8eaed;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}
.wm-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    background: #f8f9fa;
}
.wm-section-header:hover {
    background: #eef0f4;
}
.wm-section-arrow {
    font-size: 10px;
    color: #aaa;
}
.wm-section-body {
    padding: 10px 14px;
}
.wm-field {
    margin-bottom: 10px;
}
.wm-label {
    display: block;
    font-size: 12px;
    color: #333;
    margin-bottom: 3px;
    font-weight: 600;
}
.wm-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}
.wm-input:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26,115,232,0.1);
}
.wm-textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    min-height: 60px;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
}
.wm-textarea:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26,115,232,0.1);
}
.wm-color-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.wm-color-input {
    width: 36px;
    height: 32px;
    padding: 2px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    cursor: pointer;
}
.wm-readonly-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}
.wm-color-swatch {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #d0d5dd;
    flex-shrink: 0;
}
.wm-readonly-label {
    display: block;
    font-size: 12px;
    color: #333;
    font-weight: 700;
    margin-bottom: 2px;
}
.wm-readonly-val {
    font-size: 13px;
    color: #888;
    line-height: 1.5;
    margin-bottom: 4px;
    display: block;
}
.wm-readonly-multiline {
    white-space: pre-wrap;
    font-size: 12px;
    color: #999;
}

/* 图片上传 */
.wm-img-upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.wm-img-preview {
    position: relative;
    display: inline-block;
}
.wm-img-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
}

/* ===== 登录页 ===== */
.login-page {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: 9999;
}
.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px 28px;
    width: 380px;
    max-width: 92%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}
.login-header {
    margin-bottom: 28px;
}
.login-logo {
    font-size: 48px;
    margin-bottom: 12px;
}
.login-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 4px;
}
.login-header p {
    font-size: 13px;
    color: #999;
}
.login-form {
    text-align: left;
}
.login-form .form-group {
    margin-bottom: 20px;
}
.login-form input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #d0d5dd;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.login-form input[type="password"]:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.1);
}
.login-btn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    justify-content: center;
    margin-bottom: 8px;
}
.login-error {
    font-size: 13px;
    color: #ea4335;
    text-align: center;
    min-height: 20px;
    margin-top: 4px;
}
.login-footer {
    margin-top: 24px;
    display: flex;
    justify-content: center;
    gap: 16px;
    font-size: 12px;
    color: #aaa;
}

/* ===== 登出按钮 ===== */
.logout-btn {
    font-size: 11px;
    color: #889;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    display: inline-block;
    margin-top: 4px;
}
.logout-btn:hover {
    color: #ea4335;
    background: rgba(234,67,53,0.1);
}

/* ===== 设置模块 ===== */
.settings-root {
    padding: 0;
}
.settings-section {
    background: #fff;
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
.settings-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e8eaed;
}
.settings-section .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
}
.settings-section .form-grid .full {
    grid-column: 1 / -1;
}
