/**
 * 配送管理模块样式
 */

/* ========== 配送管理布局 ========== */
.delivery-wrapper {
    display: flex;
    gap: 20px;
    height: calc(100vh - 120px);
    min-height: 500px;
    position: relative;
    z-index: 1;
}

.delivery-sidebar {
    width: 200px;
    flex-shrink: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    position: relative;
    z-index: 2;
}

/* 配送管理页面专用 filter-bar 样式 */
#delivery-page .filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

#delivery-page .filter-bar::before {
    display: none; /* 移除左侧装饰条纹 */
}

#delivery-page .filter-bar > * {
    flex-shrink: 0;
}

#delivery-page .filter-bar .search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* 表格容器样式 */
#delivery-page .table-container {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.delivery-nav-header {
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.delivery-nav {
    padding: 10px 0;
}

.delivery-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
}

.delivery-nav-item:hover {
    background: #f5f5f5;
    color: #333;
}

.delivery-nav-item.active {
    background: #667eea;
    color: white;
}

.delivery-content {
    flex: 1;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 20px;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    min-width: 0; /* 防止flex子元素溢出 */
}

.delivery-tab-content {
    display: none;
    width: 100%;
    position: relative;
    z-index: 1;
}

.delivery-tab-content.active {
    display: block;
}

/* ========== 截单调度 ========== */
.cutoff-customer-list {
    margin-top: 20px;
}

.cutoff-customer-list .customer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.cutoff-customer-list .customer-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.2s;
}

.cutoff-customer-list .customer-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.cutoff-customer-list .customer-card label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: bold;
}

.cutoff-customer-list .customer-info {
    margin-top: 10px;
    font-size: 13px;
    color: #666;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.cutoff-customer-list .order-info {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #ddd;
}

.cutoff-customer-list .order-count {
    background: #28a745;
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.cutoff-customer-list .no-orders {
    color: #999;
    font-style: italic;
    margin-top: 10px;
}

.cutoff-summary {
    margin-top: 20px;
    padding: 20px;
    background: #e8f4e8;
    border-radius: 8px;
    border-left: 4px solid #28a745;
}

.cutoff-summary h4 {
    margin: 0 0 15px 0;
    color: #28a745;
}

.cutoff-summary .summary-stats {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.cutoff-summary .stat-item {
    display: flex;
    gap: 8px;
}

.cutoff-summary .stat-item span {
    color: #666;
}

.cutoff-summary .stat-item strong {
    color: #333;
    font-size: 18px;
}

.cutoff-summary .summary-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #c3e6cb;
}

.cutoff-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.cutoff-actions label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* ========== 路线规划 ========== */
.route-planner-container {
    margin-top: 20px;
}

.planner-list {
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
}

.planner-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: grab;
    transition: all 0.2s;
}

.planner-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.planner-item:active {
    cursor: grabbing;
}

.planner-item.dragging {
    opacity: 0.5;
    background: #e9ecef;
}

.planner-handle {
    color: #999;
    font-size: 20px;
    cursor: grab;
}

.planner-sequence {
    width: 30px;
    height: 30px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.planner-content {
    flex: 1;
}

.planner-content strong {
    color: #333;
    font-size: 15px;
}

.planner-content p {
    margin: 5px 0 0 0;
    color: #666;
    font-size: 13px;
}

.planner-content .address {
    color: #999;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.planner-actions {
    display: flex;
    gap: 8px;
}

.planner-actions-bar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.route-list {
    margin-top: 20px;
}

.route-list .route-item {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ========== 地图视图 ========== */
.map-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.map-container {
    background: #f5f5f5;
    border-radius: 8px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.map-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
}

.map-placeholder i {
    font-size: 60px;
    margin-bottom: 15px;
}

.map-placeholder .small {
    font-size: 12px;
    margin-top: 5px;
}

.map-info {
    padding: 15px;
    background: white;
    border-radius: 8px 8px 0 0;
}

.marker-list {
    padding: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.marker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.marker-item:hover {
    background: #f0f0f0;
}

.marker-item.completed {
    opacity: 0.6;
}

.marker-number {
    width: 24px;
    height: 24px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.marker-name {
    flex: 1;
    font-weight: 500;
}

.marker-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #e9ecef;
    color: #666;
}

.map-legend {
    display: flex;
    gap: 20px;
    padding: 10px 15px;
    background: white;
    border-radius: 0 0 8px 8px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.legend-item .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-item .dot.pending {
    background: #ffc107;
}

.legend-item .dot.delivering {
    background: #17a2b8;
}

.legend-item .dot.completed {
    background: #28a745;
}

/* ========== 打印预览 ========== */
.packing-list-preview {
    max-width: 800px;
}

.packing-list-preview .preview-header {
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 2px solid #333;
    margin-bottom: 20px;
}

.packing-list-preview .preview-header h3 {
    margin: 0;
    font-size: 20px;
}

.packing-list-preview .preview-section {
    margin-bottom: 20px;
}

.packing-list-preview .preview-section h4 {
    background: #e8f4e8;
    padding: 8px 12px;
    margin: 0;
    border-left: 4px solid #28a745;
    border-radius: 4px;
}

.customer-preview {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.customer-preview-header {
    font-weight: bold;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

.customer-preview-address {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.items-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.item-tag {
    background: #667eea;
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
}

/* ========== 配送详情 ========== */
.driver-detail .detail-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.driver-detail .detail-row span {
    width: 100px;
    color: #666;
}

.driver-detail .detail-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
}

.driver-detail .detail-section h4 {
    margin: 0 0 10px 0;
    color: #667eea;
}

.driver-detail .customer-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.driver-detail .customer-list li {
    padding: 5px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.driver-detail .badge {
    background: #28a745;
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
}

.task-detail .detail-section {
    margin-bottom: 15px;
}

.task-detail .detail-section h4 {
    background: #f5f5f5;
    padding: 8px 10px;
    margin: 0;
    border-left: 3px solid #667eea;
}

.task-detail .detail-row {
    display: flex;
    padding: 6px 0;
}

.task-detail .detail-row span {
    width: 80px;
    color: #666;
}

/* ========== 状态徽章 ========== */
.status-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.status-badge.status-pending,
.status-badge.status-active {
    background: #ffc107;
    color: #333;
}

.status-badge.status-delivering,
.status-badge.status-inactive {
    background: #17a2b8;
    color: white;
}

.status-badge.status-completed {
    background: #28a745;
    color: white;
}

.status-badge.status-abnormal {
    background: #dc3545;
    color: white;
}

.work-status {
    margin-left: 5px;
    padding: 1px 5px;
    border-radius: 8px;
    font-size: 11px;
}

.work-status-1 {
    background: #28a745;
    color: white;
}

.work-status-2 {
    background: #17a2b8;
    color: white;
}

.work-status-3 {
    background: #6c757d;
    color: white;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .delivery-wrapper {
        flex-direction: column;
    }
    
    .delivery-sidebar {
        width: 100%;
    }
    
    .delivery-nav {
        display: flex;
        flex-wrap: wrap;
        padding: 5px;
    }
    
    .delivery-nav-item {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .cutoff-customer-list .customer-grid {
        grid-template-columns: 1fr;
    }
    
    .planner-item {
        flex-wrap: wrap;
    }

    .planner-content {
        width: 100%;
    }
}

/* ========== 客户管理样式 ========== */
.customer-card .btn-sm {
    font-size: 15px;
}

.customer-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.customer-list li {
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.driver-customer-manager {
    padding: 10px 0;
}

.customer-checkbox-list {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    background: #fafafa;
}

.customer-checkbox-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 4px;
    transition: background 0.2s;
}

.customer-checkbox-item:hover {
    background: #e9ecef;
}

.customer-checkbox-item.checked {
    background: #e3f2fd;
}

.customer-checkbox-item input[type="checkbox"] {
    margin-right: 10px;
    width: 16px;
    height: 16px;
}

.customer-checkbox-item span {
    flex: 1;
}

.detail-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.detail-section h4 {
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.text-muted {
    color: #6c757d;
    font-size: 14px;
}

/* ========== 客户分配管理样式 ========== */
.driver-tag {
    background: #e3f2fd;
    color: #1976d2;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.selected-row {
    background: #fff3e0 !important;
}

.selected-row td {
    border-color: #ffcc80;
}

#assignCustomerBody tr:hover {
    background: #f5f5f5;
}

#assignCustomerBody tr.selected-row:hover {
    background: #fff3e0;
}

.batch-assign-bar {
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.batch-assign-bar .info {
    flex: 1;
    color: #666;
}

.badge-primary {
    background: #1976d2;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}

/* ========== 分页控件样式 ========== */
.delivery-tab-content .pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 15px;
    padding: 10px 0;
}

.delivery-tab-content .page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
}

.delivery-tab-content .page-btn:hover {
    background: #f0f0f0;
    border-color: #1976d2;
}

.delivery-tab-content .page-btn.active {
    background: #1976d2;
    border-color: #1976d2;
    color: white;
}

.delivery-tab-content .page-ellipsis {
    padding: 0 4px;
    color: #999;
}

.delivery-tab-content .page-info {
    margin-left: 15px;
    font-size: 13px;
    color: #666;
}

/* ========== 打印样式 ========== */
@media print {
    body * {
        visibility: hidden;
    }

    .print-container,
    .print-container * {
        visibility: visible;
    }

    .print-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
}
