/* ERP管理系统样式 */
:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --text-secondary: #64748b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
}

.erp-container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: auto;
    min-width: 60px;
    max-width: 600px;
    background: white;
    border-right: 1px solid var(--border-color);
    overflow-x: hidden;
    overflow-y: auto;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transition: all 0.3s ease;
    z-index: 100;
}

.sidebar.collapsed {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.sidebar.collapsed .sidebar-header {
    padding: 24px 10px;
    justify-content: center;
}

.logo {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .logo {
    display: none;
}

.logo h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 侧边栏切换按钮 */
.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 18px;
    font-weight: bold;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.sidebar.collapsed .sidebar-toggle .toggle-icon {
    transform: rotate(180deg);
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

.nav-menu {
    padding-bottom: 24px;
    margin-bottom: 30px;
    transition: opacity 0.3s ease;
    display: block !important;  /* 强制单列布局，覆盖header.css的flex布局 */
    flex-direction: column !important;
}

.sidebar.collapsed .nav-menu {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.nav-section {
    margin-bottom: 5px;
    padding: 0;
    display: block;  /* 确保分组也是块级元素 */
}

.nav-section:last-child {
    margin-bottom: 0;
}

.nav-section h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    padding: 8px 20px;
    margin-bottom: 8px;
    background: var(--bg-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;  /* 确保标题是块级元素 */
}

.nav-item {
    display: block !important;  /* 强制每个菜单项占一行 */
    padding: 5px 20px 5px 20px;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    width: 100%;  /* 确保宽度100% */
}

.header {
    flex: 1;
    margin-left: 200px;

    padding: 0px 24px;
    transition: margin-left 0.3s ease;
    min-width: 0;
    align-content: center;
}


/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: 280px;
    margin-bottom: 60px;
    padding: 24px;
    padding-top: 80px;  /* 为footer留出空间 */
    transition: margin-left 0.3s ease;
    min-width: 0;
}

.main-content.sidebar-collapsed {
    margin-left: 60px;
}

/* 工具栏 */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.toolbar h1 {
    font-size: 24px;
    font-weight: 600;
}

/* 过滤区域 */
.filter-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.search-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* 按钮 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: white;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* 表格 */
.table-container {
    background: white;
    border-radius: 8px;
    /* 当表格宽于容器时启用横向滚动 */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    /* 当列较多时提供最低宽度，超过容器时出现横向滚动 */
    min-width: 720px; /* 可根据列数调整 */
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-color);
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background: var(--bg-color);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* 分页 */
.pagination {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#data-count {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--bg-color);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Toast提示 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #1e293b;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    transform: translateX(450px);
    transition: transform 0.3s;
    z-index: 2000;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

/* Footer */
.footer {
    position: fixed;
    bottom: 0;
    left: 60px;
    right: 0;
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
    text-align: center;
    z-index: 50;
    transition: left 0.3s ease;
}

.main-content.sidebar-collapsed + .footer + .header{
    left: 60px;
}

.footer p {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .header {
        left: 0;
    }

    .main-content {
        margin-left: 0;
    }

    .footer {
        left: 0;
    }

    .search-controls {
        grid-template-columns: 1fr;
    }

    .data-table {
        font-size: 13px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 12px;
    }
}
