/* EDI分拣系统主样式文件 - 基于Bootstrap 5.3 */

/* Bootstrap自定义主题变量 */
:root {
    --bs-primary: #1890ff;
    --bs-primary-rgb: 24, 144, 255;
    --bs-secondary: #6c757d;
    --bs-success: #52c41a;
    --bs-info: #1890ff;
    --bs-warning: #faad14;
    --bs-danger: #ff4d4f;
    --bs-light: #f8f9fa;
    --bs-dark: #001529;
    
    --bs-primary-text-emphasis: #052c65;
    --bs-secondary-text-emphasis: #2b2f32;
    --bs-success-text-emphasis: #0a3622;
    --bs-info-text-emphasis: #052c65;
    --bs-warning-text-emphasis: #664d03;
    --bs-danger-text-emphasis: #58181c;
    --bs-light-text-emphasis: #495057;
    --bs-dark-text-emphasis: #495057;
}

/* 全局样式重置 */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--bs-dark-text-emphasis);
    background-color: var(--bs-light);
}

/* 主容器布局 */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 固定侧边栏布局 */
.wrapper {
    position: relative;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    background-color: #f8f9fa;
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.main-content {
    margin-left: 250px;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: margin-left 0.3s ease;
}

.main-content.expanded {
    margin-left: 0;
}

/* 确保与Bootstrap flex-grow-1兼容 */
.main-content .container-fluid {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* 关键修复：允许flex子项收缩 */
    overflow-y: visible; /* 修复：改为visible，让内容自然流动 */
    padding-bottom: 2rem; /* 添加底部间距确保内容不被截断 */
}

/* 确保主内容区域可以正常滚动 */
.main-content .container-fluid > div {
    flex-shrink: 0; /* 防止子元素被压缩 */
}

/* 确保侧边栏内容不会溢出 */
.sidebar .nav {
    padding-bottom: 1rem;
}

/* 侧边栏滚动条样式 */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 侧边栏菜单项样式优化 */
.sidebar .nav-link {
    transition: all 0.2s ease;
    border-radius: 0.375rem;
    margin-bottom: 0.25rem;
}

.sidebar .nav-link:hover {
    background-color: rgba(24, 144, 255, 0.1);
    transform: translateX(2px);
}

.sidebar .nav-link.active {
    background-color: var(--bs-primary);
    color: white;
}

.sidebar .nav-link.active:hover {
    background-color: var(--bs-primary);
    transform: translateX(0);
}

/* 子菜单样式 */
.sidebar .nav .nav .nav-link {
    font-size: 0.875rem;
    padding-left: 2rem;
}

.sidebar .nav .nav .nav-link:hover {
    background-color: rgba(24, 144, 255, 0.05);
}

/* 用户信息区域样式 */
.sidebar .border-top {
    border-color: #dee2e6 !important;
}

/* 移动端菜单切换按钮 */
.sidebar-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--bs-primary);
    color: white;
    border: none;
    border-radius: 0.375rem;
    padding: 0.5rem;
    cursor: pointer;
    display: none;
}

/* 侧边栏收缩/展开按钮 - 全新设计 */
.sidebar-toggle-btn {
    position: fixed;
    top: 0; /* 移动到顶部 */
    left: 250px; /* 初始位置在侧边栏右边缘 */
    width: 40px;
    height: 40px;
    background: var(--bs-primary);
    border: none;
    border-radius: 0 8px 8px 0; /* 右侧圆角，左侧贴边 */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    z-index: 1050; /* 确保在header之上 */
}

.sidebar-toggle-btn:hover {
    background: #1677ff;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.sidebar-toggle-btn i {
    font-size: 18px;
    color: white;
    transition: transform 0.3s ease;
}

/* 侧边栏收缩时按钮位置调整 - 通过wrapper类控制 */
.wrapper.sidebar-collapsed .sidebar-toggle-btn {
    left: 0; /* 移动到屏幕左边缘，完全贴边 */
    border-radius: 0 8px 8px 0; /* 保持右侧圆角，左侧贴边 */
    z-index: 1050; /* 确保在侧边栏收缩时仍然可见 */
}

.wrapper.sidebar-collapsed .sidebar-toggle-btn:hover {
    transform: scale(1.05);
}

/* 遮罩层 */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

/* 顶部导航栏 */
.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    font-weight: 600;
}

/* 主内容区域 */
main {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    padding: 1.25rem;
    flex: 1;
    overflow-y: auto;
}

/* 修复表格响应式容器的滚动问题 */
.table-responsive {
    overflow-x: auto;
    overflow-y: visible; /* 防止垂直滚动被截断 */
    max-height: none; /* 移除高度限制 */
}

/* 特殊处理长表格的滚动 */
.table-responsive.table-scroll {
    max-height: 400px;
    overflow-y: auto;
}

/* 确保页面内容可以正常滚动 */
html, body {
    height: 100%;
    overflow-x: hidden;
}

#app {
    height: 100%;
    overflow: visible; /* 修复：允许内容滚动 */
}

.wrapper {
    height: 100vh;
    overflow: visible; /* 修复：允许内容滚动 */
}

/* 卡片样式增强 */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    margin-bottom: 1rem;
}

.card-header {
    background-color: var(--bs-light);
    border-bottom: 1px solid var(--bs-border-color);
    font-weight: 600;
}

/* 按钮样式增强 */
.btn {
    border-radius: 0.375rem;
    font-weight: 500;
}

/* 表格样式增强 */
.table {
    margin-bottom: 0;
}

.table th {
    background-color: var(--bs-light);
    border-top: none;
    font-weight: 600;
}

.table-hover tbody tr:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.05);
}

/* 表单样式增强 */
.form-control {
    border-radius: 0.375rem;
    border: 1px solid var(--bs-border-color);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

/* 面包屑导航 */
.breadcrumb {
    background-color: transparent;
    padding: 0;
    margin-bottom: 1rem;
}

/* 模态框样式增强 */
.modal-content {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
}

.modal-header {
    background-color: var(--bs-light);
    border-bottom: 1px solid var(--bs-border-color);
}

/* Toast通知样式 */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1055;
}

.toast {
    min-width: 300px;
    max-width: 500px;
    border-radius: 0.375rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,0.1);
}

/* 状态标签样式 */
.badge {
    font-size: 0.75em;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
}

/* 进度条样式 */
.progress {
    height: 0.5rem;
    border-radius: 0.25rem;
}

/* 工具提示 */
[data-bs-toggle="tooltip"] {
    cursor: help;
}

/* 加载状态 */
.loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1rem;
    height: 1rem;
    margin: -0.5rem 0 0 -0.5rem;
    border: 0.125rem solid var(--bs-light);
    border-top: 0.125rem solid var(--bs-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 统计信息卡片 */
.stats-card {
    background: linear-gradient(135deg, var(--bs-primary) 0%, var(--bs-info) 100%);
    color: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.stats-card .stats-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.stats-card .stats-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* 操作按钮组 */
.action-toolbar {
    background-color: var(--bs-light);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

/* 搜索表单区域 */
.search-section {
    background-color: var(--bs-light);
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--bs-secondary);
}

.empty-state .empty-icon {
    font-size: 3rem;
    color: var(--bs-secondary);
    margin-bottom: 1rem;
}

.empty-state .empty-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bs-light);
}

::-webkit-scrollbar-thumb {
    background: var(--bs-secondary);
    border-radius: 0.25rem;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bs-primary);
}

/* 渐变背景工具类 */
.bg-gradient-primary {
    background: linear-gradient(135deg, var(--bs-primary) 0%, #40a9ff 100%) !important;
}

/* 表格悬停效果增强 */
.table-hover tbody tr {
    transition: background-color 0.2s ease;
}

/* 卡片悬停效果增强 */
.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
}

/* 按钮悬停效果增强 */
.btn {
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

/* 徽章样式增强 */
.badge {
    transition: all 0.2s ease;
}

/* 模态框动画增强 */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    transform: translate(0, -50px);
    opacity: 0;
}

.modal.show .modal-dialog {
    transform: translate(0, 0);
    opacity: 1;
}

/* 标签页内容动画 */
.tab-pane {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 数据加载状态 */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}