/* EDI分拣系统响应式样式文件 */

/* 基于Bootstrap 5.3的响应式调整 */

/* 移动端侧边栏调整 */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -250px;
        width: 250px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        background-color: var(--bs-dark) !important;
        transform: none !important; /* 覆盖桌面端的收缩效果 */
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .sidebar.collapsed {
        transform: none !important; /* 移动端不应用收缩效果 */
        left: -250px;
    }
    
    .main-content {
        margin-left: 0;
        overflow-y: visible; /* 修复：改为visible，允许自然滚动 */
        height: auto; /* 修复：改为auto，允许内容自然扩展 */
        min-height: 100vh; /* 保持最小高度 */
        position: relative;
    }
    
    .main-content.expanded {
        margin-left: 0; /* 移动端不应用展开效果 */
    }
    
    .sidebar-toggle {
        display: block !important;
    }
    
    .sidebar-toggle-btn {
        display: none !important; /* 移动端隐藏收缩按钮 */
    }
    
    .sidebar-overlay {
        display: block !important;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    
    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }
    
    main {
        padding: 15px;
    }
    
    .table-responsive {
        font-size: 12px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .form-control {
        font-size: 14px;
    }
    
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .toast-container {
        left: 10px;
        right: 10px;
        max-width: calc(100% - 20px);
    }
}

/* 平板端调整 */
@media (min-width: 769px) and (max-width: 992px) {
    .sidebar {
        width: 200px;
    }
    
    .sidebar.collapsed {
        width: 0;
        transform: translateX(-100%);
    }
    
    .sidebar .nav-link {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .main-content {
        margin-left: 200px;
        overflow-y: visible; /* 修复：改为visible，允许自然滚动 */
        position: relative;
    }
    
    .main-content.expanded {
        margin-left: 0;
    }
    
    .sidebar-toggle {
        display: none !important; /* 平板端隐藏移动端菜单按钮 */
    }
    
    .sidebar-toggle-btn {
        display: flex; /* 平板端显示收缩按钮 */
        left: 200px; /* 平板端侧边栏宽度 */
        top: 0; /* 移动到顶部 */
        z-index: 1002; /* 确保按钮始终可见 */
    }
    
    .wrapper.sidebar-collapsed .sidebar-toggle-btn {
        left: 20px; /* 移动到屏幕左边缘，但留出20px边距 */
        z-index: 1002; /* 确保在侧边栏收缩时仍然可见 */
    }
}

/* 大屏幕调整 */
@media (min-width: 1200px) {
    /* 移除container-fluid的宽度限制，让所有panel保持一致的宽度 */
    
    .sidebar-toggle {
        display: none !important; /* 大屏幕隐藏移动端菜单按钮 */
    }
    
    .sidebar-toggle-btn {
        display: flex; /* 大屏幕显示收缩按钮 */
        left: 250px; /* 大屏幕侧边栏宽度 */
        top: 0; /* 移动到顶部 */
        z-index: 1002; /* 确保按钮始终可见 */
    }
    
    .wrapper.sidebar-collapsed .sidebar-toggle-btn {
        left: 20px; /* 移动到屏幕左边缘，但留出20px边距 */
        z-index: 1002; /* 确保在侧边栏收缩时仍然可见 */
    }
}

/* 中等屏幕调整 */
@media (min-width: 993px) and (max-width: 1199px) {
    .sidebar-toggle {
        display: none !important; /* 中等屏幕隐藏移动端菜单按钮 */
    }
    
    .sidebar-toggle-btn {
        display: flex; /* 中等屏幕显示收缩按钮 */
        left: 250px; /* 中等屏幕侧边栏宽度 */
        top: 0; /* 移动到顶部 */
        z-index: 1002; /* 确保按钮始终可见 */
    }
    
    .wrapper.sidebar-collapsed .sidebar-toggle-btn {
        left: 20px; /* 移动到屏幕左边缘，但留出20px边距 */
        z-index: 1002; /* 确保在侧边栏收缩时仍然可见 */
    }
}

/* 打印样式 */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .pagination {
        display: none !important;
    }
    
    main {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
    }
    
    .table {
        font-size: 10pt;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }
}

/* 高分辨率屏幕调整 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .img-retina {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* 横屏调整 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .navbar {
        min-height: 40px;
    }
    
    .navbar-brand {
        font-size: 16px;
    }
    
    .sidebar {
        min-height: calc(100vh - 40px);
    }
    
    main {
        min-height: calc(100vh - 40px);
    }
}

/* 无障碍访问调整 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .navbar-dark {
        background-color: #0c0c0c !important;
    }
    
    .bg-light {
        background-color: #2d2d2d !important;
        color: #fff !important;
    }
    
    .table {
        color: #fff !important;
    }
    
    .table th {
        background-color: #3d3d3d !important;
        color: #fff !important;
    }
    
    .card {
        background-color: #2d2d2d !important;
        color: #fff !important;
        border-color: #3d3d3d !important;
    }
    
    .form-control {
        background-color: #3d3d3d !important;
        color: #fff !important;
        border-color: #5d5d5d !important;
    }
    
    .form-control:focus {
        background-color: #4d4d4d !important;
        border-color: #1890ff !important;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-control {
        min-height: 44px;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    .table td,
    .table th {
        padding: 12px 8px;
    }
    
    .nav-link {
        padding: 16px;
    }
}

/* 小屏幕设备优化 */
@media (max-width: 576px) {
    .stats-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .search-form .row {
        flex-direction: column;
        gap: 10px;
    }
    
    .table-responsive {
        border: none;
    }
    
    .table-responsivead {
        display: none;
    }
    
    .table-responsive,
    .table-responsive tbody,
    .table-responsive tr,
    .table-responsive td {
        display: block;
        width: 100% !important;
    }
    
    .table-responsive tr {
        margin-bottom: 15px;
        border: 1px solid #dee2e6;
        border-radius: 4px;
    }
    
    .table-responsive td {
        border: none;
        border-bottom: 1px solid #dee2e6;
        position: relative;
        padding-left: 50%;
    }
    
    .table-responsive td:before {
        position: absolute;
        top: 12px;
        left: 12px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        content: attr(data-label);
    }
}

/* 焦点样式优化 */
.btn:focus,
.form-control:focus,
.nav-link:focus {
    outline: 2px solid #1890ff;
    outline-offset: 2px;
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .btn {
        border-width: 2px;
    }
    
    .form-control {
        border-width: 2px;
    }
    
    .table {
        border-width: 2px;
    }
    
    .card {
        border-width: 2px;
    }
}