<!-- 领料车管理 - 智能仓储风格 -->
<template>
  <div class="stock-requisition-page">
    <!-- 背景层 -->
    <div class="bg-layer" :style="{ backgroundImage: `url(${bgImg})` }" />

    <!-- 顶部标题区域 -->
    <div class="header-section">
      <button class="logout-btn" @click="goToHome">
        <i class="fas fa-arrow-left" />
        <span>{{ isRegular == 'true' ? '返回常用领料' : '返回领料' }}</span>
      </button>
      <h1 class="page-title">领料车管理</h1>
      <div class="header-actions">
        <!-- 占位 -->
      </div>
    </div>

    <!-- 主内容区域 -->
    <main class="main-content">
      <!-- 筛选区域 -->
      <div class="filter-section">
        <div class="filter-row">
          <div class="filter-item">
            <label class="filter-label">类型</label>
            <v-select
              v-model="inventoryType"
              :options="inventoryTypeList"
              :reduce="item => item.value"
              label="label"
              placeholder="请选择类型"
              :clearable="true"
              :filterable="true"
              class="filter-select dark-select"
              @update:model-value="getDatas"
            >
              <template #no-options>
                <span>无该选项数据</span>
              </template>
            </v-select>
          </div>
          <div class="filter-item">
            <label class="filter-label">名称</label>
            <input
              v-model="inventoryName"
              type="text"
              placeholder="请输入名称"
              class="filter-input dark-input"
              @keyup.enter="getDatas"
            />
          </div>
          <div class="filter-buttons">
            <button class="search-btn" @click="getDatas">
              搜索
            </button>
            <button class="reset-btn" @click="handleReset">
              重置
            </button>
          </div>
        </div>
      </div>

      <!-- 全选控制栏 -->
      <div v-if="carList.length > 0" class="select-all-bar">
        <van-checkbox :model-value="isAllSelected" @update:model-value="toggleSelectAll">
          <span class="select-all-text">全选当前页（已选 {{ selectedIds.length }} 项）</span>
        </van-checkbox>
      </div>

      <!-- 卡片网格区域 -->
      <div ref="cardGridWrapper" class="card-grid-wrapper" @scroll="handleScroll">
        <!-- 空状态 -->
        <div v-if="carList.length === 0 && !loading" class="empty-state">
          <i class="fas fa-shopping-cart empty-icon" />
          <p>领料车为空</p>
        </div>

        <!-- 卡片网格 -->
        <div v-else class="card-grid">
          <div
            v-for="(item, index) in carList"
            :key="item.id || index"
            class="inventory-card"
            :class="{ 'selected': selectedIds.includes(item.id) }"
            @click="toggleSelect(item.id)"
          >
            <!-- 卡片序号 -->
            <div class="card-index">{{ index + 1 }}</div>
            
            <!-- 图片区域 -->
            <div class="card-image">
              <img v-if="item.imageUrl" :src="item.imageUrl" alt="设备图片" />
              <div v-else class="image-placeholder">
                <i :class="getInventoryIcon(item.inventoryType)" />
              </div>
            </div>
            
            <!-- 信息区域 -->
            <div class="card-info">
              <div class="info-row">
                <span class="info-label">名称:</span>
                <span class="info-value">{{ item.inventoryName || '-' }}</span>
              </div>
              <div class="info-row">
                <span class="info-label">编号:</span>
                <span class="info-value">{{ item.inventoryNo || '-' }}</span>
              </div>
              <div class="info-row location-row">
                <i class="fas fa-map-marker-alt location-icon" />
                <span class="info-value">{{ item.positionName || '-' }} / {{ item.warehouseName || '-' }}</span>
              </div>
            </div>
            
            <!-- 选中状态指示 -->
            <div v-if="selectedIds.includes(item.id)" class="selected-indicator">
              <i class="fas fa-check" />
            </div>
          </div>
        </div>

        <!-- 加载更多提示 -->
        <div v-if="loadingMore" class="loading-more">
          <div class="loading-more-spinner" />
          <span>加载中...</span>
        </div>
        <div v-else-if="noMoreData && carList.length > 0" class="no-more-data">
          <span>没有更多数据了</span>
        </div>
      </div>
    </main>

    <!-- 底部操作按钮 -->
    <div class="bottom-actions">
      <button
        class="delete-btn"
        :disabled="selectedIds.length === 0"
        @click="deleteStock"
      >
        删除选中
      </button>
      <button
        class="submit-btn"
        :disabled="selectedIds.length === 0"
        @click="submitStock"
      >
        提交领料
      </button>
    </div>

    <!-- 拣货确认弹窗 - 科技感风格 -->
    <div v-if="confirmModalVisible" class="tech-modal-overlay" @click.self="handleConfirmCancel">
      <div class="tech-modal">
        <div class="modal-content-row">
          <div class="modal-text">
            <h3>请您确认要进行的操作</h3>
            <p>您是否要进入仓库，并开始拣货？</p>
          </div>
          <div class="modal-icon">
            <div class="icon-box">
              <i class="fas fa-clipboard-check" />
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button class="modal-btn cancel-btn" @click="handleConfirmCancel">取消</button>
          <button class="modal-btn confirm-btn" @click="handleConfirmOk">确认</button>
        </div>
      </div>
    </div>

    <!-- 删除确认弹窗 - 科技感风格 -->
    <div v-if="deleteModalVisible" class="tech-modal-overlay" @click.self="handleDeleteCancel">
      <div class="tech-modal danger-modal">
        <div class="modal-content-row">
          <div class="modal-text">
            <h3>确认删除</h3>
            <p>确认将工装设备从领料车中删除吗？</p>
          </div>
          <div class="modal-icon">
            <div class="icon-box danger-box">
              <i class="fas fa-trash-alt" />
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button class="modal-btn cancel-btn" @click="handleDeleteCancel">取消</button>
          <button class="modal-btn danger-confirm-btn" @click="handleDeleteOk">确认删除</button>
        </div>
      </div>
    </div>

    <!-- Loading -->
    <div v-if="loading" class="loading-overlay">
      <div class="loading-dots">
        <div class="dot" />
        <div class="dot" />
        <div class="dot" />
      </div>
      <span class="loading-text">加载中...</span>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, nextTick, computed } from 'vue';
import { useRouter } from 'vue-router';
import { showNotify } from 'vant';
import vSelect from 'vue-select';
import 'vue-select/dist/vue-select.css';

// 图片资源
import bgImg from '../assets/images/bj.png';

import { getWarehouseList } from '../api/stock.js';
import { queryCFPickCar, deleteCFPickCar, saveCFStockOutPrepare } from '../api/stockOut.js';

const router = useRouter();

// 滚动容器ref
const cardGridWrapper = ref(null);

// 弹窗控制
const confirmModalVisible = ref(false);
const deleteModalVisible = ref(false);

const userId = ref(undefined);
const warehouseId = ref(undefined);
const inventoryName = ref('');
const inventoryNo = ref('');
const inventoryType = ref(undefined);
const warehouseList = ref([]);
const carList = ref([]);
const selectedIds = ref([]);

const loading = ref(false);
const loadingMore = ref(false);
const noMoreData = ref(false);
const isRegular = ref(false);

const inventoryTypeList = ref([
    { value: 'Clamp', label: '工装' },
    { value: 'Instrument', label: '设备' },
    // { value: 'FinishProduct', label: '成品' },
]);

// 无限滚动参数
const pageSize = 20;
const currentStart = ref(0);
const total = ref(0);

// 计算是否全选
const isAllSelected = computed(() => {
    if (carList.value.length === 0) return false;
    return carList.value.every(item => selectedIds.value.includes(item.id));
});

// 切换选择
const toggleSelect = id => {
    const index = selectedIds.value.indexOf(id);
    if (index > -1) {
        selectedIds.value.splice(index, 1);
    } else {
        selectedIds.value.push(id);
    }
};

// 全选/取消全选
const toggleSelectAll = checked => {
    if (checked) {
        carList.value.forEach(item => {
            if (!selectedIds.value.includes(item.id)) {
                selectedIds.value.push(item.id);
            }
        });
    } else {
        const currentListIds = carList.value.map(item => item.id);
        selectedIds.value = selectedIds.value.filter(id => !currentListIds.includes(id));
    }
};

// 获取设备类型图标
const getInventoryIcon = type => {
    const iconMap = {
        '工装': 'fas fa-cube',
        '设备': 'fas fa-cogs',
        '成品': 'fas fa-box',
    };
    return iconMap[type] || 'fas fa-cube';
};

// 滚动事件处理 - 无限滚动
const handleScroll = e => {
    const container = e.target;
    const { scrollTop, scrollHeight, clientHeight } = container;
    
    // 距离底部100px时触发加载
    if (scrollHeight - scrollTop - clientHeight < 100) {
        loadMore();
    }
};

// 检查容器是否需要继续加载（当内容不足以产生滚动条时自动加载更多）
const checkAndLoadMore = async () => {
    await nextTick();
    const container = cardGridWrapper.value;
    if (!container) return;
    
    // 如果内容高度不足以产生滚动条，且还有更多数据，继续加载
    if (container.scrollHeight <= container.clientHeight && !noMoreData.value && !loadingMore.value) {
        loadMore();
    }
};

// 加载更多数据
const loadMore = async () => {
    if (loadingMore.value || noMoreData.value || loading.value) return;
    
    loadingMore.value = true;
    
    const loginInfo = localStorage.getItem('#LoginInfo');
    if (loginInfo) {
        const loginInfoObj = JSON.parse(loginInfo);
        userId.value = loginInfoObj.userId;
    }
    
    const params = {
        inventoryName: inventoryName.value,
        inventoryNo: inventoryNo.value,
        inventoryType: inventoryType.value,
        warehouseId: warehouseId.value,
        userId: userId.value,
        start: currentStart.value,
        length: pageSize,
    };

    try {
        const res = await queryCFPickCar(params);
        if (res.errorCode == 0) {
            if (res.datas && res.datas.length > 0) {
                carList.value = [...carList.value, ...res.datas];
                currentStart.value += res.datas.length;
                total.value = res.total;
                
                // 检查是否还有更多数据
                if (carList.value.length >= res.total) {
                    noMoreData.value = true;
                } else {
                    // 加载完成后检查是否需要继续加载
                    checkAndLoadMore();
                }
            } else {
                noMoreData.value = true;
            }
        }
    } catch (error) {
        console.error('加载更多数据失败:', error);
    } finally {
        loadingMore.value = false;
    }
};

// 初次加载物料数据
const getPickerCarList = async () => {
    loading.value = true;
    currentStart.value = 0;
    noMoreData.value = false;
    
    const loginInfo = localStorage.getItem('#LoginInfo');
    if (loginInfo) {
        const loginInfoObj = JSON.parse(loginInfo);
        userId.value = loginInfoObj.userId;
    }
    
    const params = {
        inventoryName: inventoryName.value,
        inventoryNo: inventoryNo.value,
        inventoryType: inventoryType.value,
        warehouseId: warehouseId.value,
        userId: userId.value,
        start: 0,
        length: pageSize,
    };

    try {
        const res = await queryCFPickCar(params);
        if (res.errorCode == 0) {
            if (res.datas && res.datas.length > 0) {
                carList.value = res.datas;
                currentStart.value = res.datas.length;
                total.value = res.total;
                
                if (carList.value.length >= res.total) {
                    noMoreData.value = true;
                } else {
                    // 初次加载完成后检查是否需要继续加载
                    checkAndLoadMore();
                }
            } else {
                carList.value = [];
                total.value = 0;
                noMoreData.value = true;
            }
        } else {
            showNotify({ type: 'danger', message: res.errorMessage });
        }
    } catch (error) {
        console.log('获取领料车列表API调用失败', error);
        showNotify({ type: 'danger', message: '获取领料车列表API调用失败' });
    } finally {
        loading.value = false;
    }
};

// 返回领料
const goToHome = () => {
    if (isRegular.value == 'true') {
        router.push('/regular-requisition');
    } else {
        router.push('/stock-requisition');
    }
};

// 重置筛选条件
const handleReset = () => {
    warehouseId.value = undefined;
    inventoryName.value = '';
    inventoryNo.value = '';
    inventoryType.value = undefined;
    getDatas();
};

// 从领料车里删除工装设备
const deleteStock = () => {
    if (selectedIds.value.length == 0) {
        showNotify({ type: 'danger', message: '请至少选择一个工装设备' });
        return;
    }
    // 显示删除确认弹窗
    deleteModalVisible.value = true;
};

//  删除接口
const deleteStockCarApi = async () => {
    loading.value = true;
    const params = {
        pickingCarIds: selectedIds.value,
    };
    try {
        const res = await deleteCFPickCar(params);
        if (res.errorCode == 0) {
            showNotify({ type: 'success', message: '删除成功' });
            selectedIds.value = [];
            getDatas();
        } else {
            showNotify({ type: 'danger', message: res.errorMessage });
        }
    } catch (error) {
        console.log('删除领料车API调用失败', error);
        showNotify({ type: 'danger', message: '删除领料车API调用失败' });
    } finally {
        loading.value = false;
    }
};
// 获取仓库列表
const getWarehouses = async () => {
    try {
        const res = await getWarehouseList();
        if (res.errorCode == 0) {
            if (res.datas && res.datas.length > 0) {
                warehouseList.value = res.datas;
            } else {
                warehouseList.value = [];
            }
        } else {
            showNotify({ type: 'danger', message: res.errorMessage });
        }
    } catch (error) {
        console.error('获取仓库数据失败:', error);
        showNotify({ type: 'danger', message: '获取仓库数据失败' });
    }
};

// 拣货确认弹窗处理
const handleConfirmOk = () => {
    confirmModalVisible.value = false;
    router.push('/order-picking');
};

const handleConfirmCancel = () => {
    confirmModalVisible.value = false;
    getDatas();
};

// 删除确认弹窗处理
const handleDeleteOk = () => {
    deleteModalVisible.value = false;
    deleteStockCarApi();
};

const handleDeleteCancel = () => {
    deleteModalVisible.value = false;
};

// 查询（重新搜索时重置列表）
const getDatas = () => {
    // 滚动到顶部
    if (cardGridWrapper.value) {
        cardGridWrapper.value.scrollTop = 0;
    }
    getPickerCarList();
};

// 领料
const submitStock = async () => {
    if (selectedIds.value.length == 0) {
        showNotify({ type: 'danger', message: '请至少选择一个工装设备' });
        return;
    }
    loading.value = true;
    const params = {
        pickingCarIds: selectedIds.value,
    };

    try {
        const res = await saveCFStockOutPrepare(params);
        if (res.errorCode == 0) {
            // 提交成功后清除选择项
            selectedIds.value = [];
            // 刷新列表数据
            getDatas();
            confirmModalVisible.value = true;
        } else {
            showNotify({ type: 'danger', message: res.errorMessage });
        }
    } catch (error) {
        console.log('生成领料单API调用失败', error);
        showNotify({ type: 'danger', message: '生成领料单API调用失败' });
    } finally {
        loading.value = false;
    }
};
onMounted(() => {
    getDatas();
    getWarehouses();
    isRegular.value = router.currentRoute.value.query.isRegular;
});
</script>

<style scoped>
/* ========== 基础样式 - 所有屏幕固定布局 ========== */
.stock-requisition-page {
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  position: relative;
  font-family: 'Microsoft YaHei', sans-serif;
  color: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 背景层 */
.bg-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #041c3d;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 0;
}

/* ========== 主内容区域 ========== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 30px;
  position: relative;
  z-index: 10;
  min-height: 0;
  overflow: hidden;
}

/* ========== 筛选区域 ========== */
.filter-section {
  background: rgba(9, 61, 140, 0.5);
  border: 1px solid #049FD8;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-label {
  font-size: 16px;
  color: #7ec8ff;
  white-space: nowrap;
  font-weight: 500;
}

.filter-select {
  width: 200px;
}

.filter-input.dark-input {
  width: 200px;
  padding: 10px 15px;
  background: rgba(13, 58, 106, 0.8);
  border: 1px solid #2a7fff;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: all 0.3s;
}

.filter-input.dark-input::placeholder {
  color: #7ec8ff;
  opacity: 0.7;
}

.filter-input.dark-input:focus {
  border-color: #00bfff;
  box-shadow: 0 0 10px rgba(0, 191, 255, 0.3);
}

.filter-buttons {
  display: flex;
  gap: 15px;
  margin-left: auto;
}

.search-btn,
.reset-btn {
  padding: 10px 30px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
}

.search-btn {
  background: linear-gradient(90deg, #1e90ff 0%, #00bfff 100%);
  color: #fff;
}

.search-btn:hover {
  box-shadow: 0 0 15px rgba(30, 144, 255, 0.6);
  transform: translateY(-2px);
}

.reset-btn {
  background: rgba(13, 58, 106, 0.8);
  border: 1px solid #2a7fff;
  color: #fff;
}

.reset-btn:hover {
  background: rgba(26, 74, 122, 0.8);
  box-shadow: 0 0 10px rgba(30, 144, 255, 0.3);
}

/* ========== 全选控制栏 ========== */
.select-all-bar {
  background: rgba(9, 61, 140, 0.3);
  border: 1px solid #049FD8;
  border-radius: 8px;
  padding: 10px 20px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.select-all-text {
  font-size: 14px;
  color: #7ec8ff;
  font-weight: 500;
}

:deep(.select-all-bar .van-checkbox__label) {
  color: #7ec8ff;
}

/* ========== 卡片网格区域 ========== */
.card-grid-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 10px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.card-grid-wrapper::-webkit-scrollbar {
  display: none;
}

/* 加载更多样式 */
.loading-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 0;
  color: #7ec8ff;
  font-size: 14px;
}

.loading-more-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(30, 144, 255, 0.3);
  border-top-color: #00bfff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.no-more-data {
  text-align: center;
  padding: 15px 0;
  color: #5a8abf;
  font-size: 13px;
}

/* 空状态 */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #7ec8ff;
  padding: 60px 0;
}

.empty-icon {
  font-size: 80px;
  margin-bottom: 20px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 18px;
  margin: 0;
}

/* 卡片网格 - 4列布局 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

/* ========== 设备卡片样式 ========== */
.inventory-card {
  background: rgba(5, 30, 60, 0.8);
  border: 2px solid #0d4a8a;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.inventory-card:hover {
  border-color: #1e90ff;
  box-shadow: 0 0 20px rgba(30, 144, 255, 0.3);
  transform: translateY(-3px);
}

.inventory-card.selected {
  border-color: #00bfff;
  box-shadow: 0 0 25px rgba(0, 191, 255, 0.5);
  background: rgba(10, 50, 100, 0.9);
}

/* 卡片序号 - 左上角 */
.card-index {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #1e90ff 0%, #00bfff 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 191, 255, 0.4);
}

/* 图片区域 */
.card-image {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 15px;
  margin-bottom: 10px;
  border-radius: 8px;
  width: calc(100% - 30px);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #f0f4f8 0%, #e8ecf0 100%);
  color: #94a3b8;
  font-size: 48px;
}

/* 信息区域 */
.card-info {
  padding: 10px 15px 15px;
}

.info-row {
  display: flex;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 14px;
}

.info-row:last-child {
  margin-bottom: 0;
}

.info-label {
  color: #7ec8ff;
  white-space: nowrap;
  margin-right: 5px;
}

.info-value {
  color: #fff;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 位置行样式 */
.location-row {
  display: flex;
  align-items: center;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(30, 144, 255, 0.2);
}

.location-icon {
  color: #00bfff;
  margin-right: 6px;
  font-size: 12px;
}

/* 选中状态指示 - 右上角 */
.selected-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #00ff88 0%, #00cc6a 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 255, 136, 0.4);
}

/* ========== 底部操作按钮 ========== */
.bottom-actions {
  width: 100%;
  padding: 15px 30px;
  box-sizing: border-box;
  background: rgba(4, 28, 61, 0.95);
  z-index: 20;
  flex-shrink: 0;
  display: flex;
  gap: 20px;
}

.delete-btn,
.submit-btn {
  flex: 1;
  padding: 18px 0;
  border: none;
  border-radius: 12px;
  font-size: 24px;
  font-weight: bold;
  color: #fff;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.delete-btn {
  background: linear-gradient(90deg, #dc2626 0%, #ef4444 100%);
}

.delete-btn:hover:not(:disabled) {
  box-shadow: 0 0 30px rgba(220, 38, 38, 0.6);
  transform: translateY(-2px);
}

.submit-btn {
  background: #4a99e2;
}

.submit-btn:hover:not(:disabled) {
  box-shadow: 0 0 30px rgba(74, 153, 226, 0.6);
  transform: translateY(-2px);
}

.delete-btn:disabled,
.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: linear-gradient(90deg, #6b7280 0%, #9ca3af 100%);
}

/* 大弹窗样式 */
:deep(.large-dialog) {
  width: 85vw !important;
  max-width: 600px !important;
  border-radius: 16px !important;
}

:deep(.large-dialog .van-dialog__header) {
  padding: 2rem 1.5rem 1rem !important;
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  color: #111827 !important;
}

.large-dialog-content {
  padding: 1.5rem 2rem 2.5rem !important;
}

.large-dialog-content p {
  margin: 0;
  font-size: 1.25rem !important;
  line-height: 1.8 !important;
  color: #374151 !important;
  text-align: center;
}

:deep(.large-dialog .van-dialog__footer) {
  padding: 1rem 1.5rem 1.5rem !important;
  display: flex;
}

:deep(.large-dialog .van-dialog__cancel),
:deep(.large-dialog .van-dialog__confirm) {
  flex: 1;
  height: 56px !important;
  font-size: 1.125rem !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  border: none !important;
}

:deep(.large-dialog .van-dialog__cancel) {
  background-color: #f3f4f6 !important;
  color: #374151 !important;
  margin-right: 1rem;
}

:deep(.large-dialog .van-dialog__confirm) {
  background-color: #3b82f6 !important;
  color: white !important;
}

/* ========== 响应式 - 1920x1080 横屏 ========== */
@media screen and (orientation: landscape) {
  .stock-requisition-page {
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    overflow: hidden;
  }

  .header-section {
    padding: 10px 20px;
    flex-shrink: 0;
  }

  .page-title {
    font-size: 22px;
  }

  .logout-btn {
    padding: 6px 14px;
    font-size: 13px;
    left: 20px;
  }

  .logout-btn i {
    font-size: 14px;
  }

  .header-actions {
    right: 20px;
    gap: 10px;
  }

  .main-content {
    padding: 0 20px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .filter-section {
    padding: 10px 15px;
    margin-bottom: 10px;
    flex-shrink: 0;
  }

  .filter-row {
    gap: 12px;
  }

  .filter-label {
    font-size: 13px;
  }

  .filter-select {
    width: 150px;
  }

  .filter-input.dark-input {
    width: 150px;
    padding: 6px 10px;
    font-size: 12px;
  }

  :deep(.dark-select .vs__dropdown-toggle) {
    min-height: 32px;
    padding: 4px 8px;
  }

  .search-btn,
  .reset-btn {
    padding: 6px 20px;
    font-size: 13px;
  }

  .card-grid-wrapper {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 10px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .card-grid-wrapper::-webkit-scrollbar {
    display: none;
  }

  .card-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
  }

  .inventory-card {
    border-radius: 8px;
    border-width: 1px;
  }

  .card-image {
    margin: 8px;
    width: calc(100% - 16px);
    aspect-ratio: 4 / 3;
  }

  .card-index {
    width: 24px;
    height: 24px;
    font-size: 12px;
    top: 6px;
    left: 6px;
  }

  .card-info {
    padding: 6px 8px 8px;
  }

  .info-row {
    font-size: 14px;
    margin-bottom: 2px;
  }

  .location-row {
    margin-top: 2px;
    padding-top: 2px;
  }

  .location-icon {
    font-size: 10px;
    margin-right: 4px;
  }

  .image-placeholder {
    font-size: 28px;
  }

  .selected-indicator {
    width: 20px;
    height: 20px;
    font-size: 10px;
    top: 6px;
    right: 6px;
  }

  .loading-more {
    padding: 15px 0;
    font-size: 12px;
  }

  .loading-more-spinner {
    width: 16px;
    height: 16px;
  }

  .no-more-data {
    padding: 10px 0;
    font-size: 11px;
  }

  .bottom-actions {
    padding: 10px 20px;
    flex-shrink: 0;
    background: rgba(4, 28, 61, 0.95);
    gap: 15px;
  }

  .delete-btn,
  .submit-btn {
    padding: 12px 0;
    font-size: 18px;
    letter-spacing: 6px;
    border-radius: 8px;
  }
}

/* ========== 响应式 - 中等屏幕 ========== */
@media screen and (orientation: landscape) and (max-width: 1400px) {
  .card-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  .filter-select {
    width: 130px;
  }

  .filter-input.dark-input {
    width: 130px;
  }
}

/* ========== 响应式 - 竖屏 ========== */
@media screen and (orientation: portrait) and (max-width: 900px) {
  .stock-requisition-page {
    height: 100vh;
    overflow: hidden;
  }

  .card-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
  }

  .card-grid-wrapper {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .card-grid-wrapper::-webkit-scrollbar {
    display: none;
  }
}

/* ========== 科技感弹窗样式 ========== */
.tech-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 28, 61, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.tech-modal {
  background: linear-gradient(135deg, #0a3d6d 0%, #041c3d 100%);
  border: 1px solid #049FD8;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 0 40px rgba(4, 159, 216, 0.3);
}

.modal-content-row {
  padding: 30px;
  display: flex;
  align-items: center;
  gap: 30px;
}

.modal-text {
  flex: 1;
}

.modal-text h3 {
  font-size: 22px;
  font-weight: bold;
  color: #fff;
  margin: 0 0 12px 0;
}

.modal-text p {
  font-size: 16px;
  color: #7ec8ff;
  margin: 0;
  line-height: 1.6;
}

.modal-icon {
  flex-shrink: 0;
}

.icon-box {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #1e90ff 0%, #00bfff 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 191, 255, 0.3);
}

.danger-box {
  background: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.3);
}

.modal-footer {
  padding: 20px 30px 30px;
  display: flex;
  gap: 15px;
}

.modal-btn {
  flex: 1;
  padding: 14px 0;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.cancel-btn {
  background: transparent;
  border: 1px solid #2a7fff;
  color: #7ec8ff;
}

.cancel-btn:hover {
  background: rgba(42, 127, 255, 0.2);
}

.confirm-btn {
  background: linear-gradient(90deg, #1e90ff 0%, #00bfff 100%);
  border: none;
  color: #fff;
}

.confirm-btn:hover {
  box-shadow: 0 0 20px rgba(30, 144, 255, 0.5);
}

.danger-confirm-btn {
  background: linear-gradient(90deg, #ef4444 0%, #f87171 100%);
  border: none;
  color: #fff;
}

.danger-confirm-btn:hover {
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}
</style>