/* 库存管理系统 - 移动端优先样式 (v2) */

/* ===== 基础 ===== */
body {
    background: #f5f7fa;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
                 "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    padding-bottom: 70px; /* 给底部导航腾空间 */
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: 0.5px;
    font-size: 1.1rem;
}

/* ===== 卡片 ===== */
.card {
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: none;
    margin-bottom: 0.75rem;
}
.card-header {
    background: #fff;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    border-radius: 10px 10px 0 0 !important;
}
.card-body {
    padding: 1rem;
}

/* ===== 按钮 - 统一触屏友好 ===== */
.btn {
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
}
.btn-lg, .btn.w-100 {
    padding: 0.7rem 1rem;
    font-size: 1rem;
}
.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    min-width: 34px;
    min-height: 34px;
}

/* ===== 表单 ===== */
.form-control, .form-select {
    border-radius: 8px;
    font-size: 1rem;
    min-height: 44px; /* 触屏友好 */
    padding: 0.5rem 0.75rem;
}
.form-control:focus, .form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.2);
    border-color: #667eea;
}
.form-label {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}
.input-group .form-control {
    min-height: 44px;
}
.input-group-text {
    border-radius: 8px 0 0 8px;
}

/* ===== 徽标 ===== */
.badge {
    font-weight: 500;
    font-size: 0.8rem;
    padding: 0.3em 0.6em;
}
code {
    color: #e83e8c;
    font-size: 0.85em;
}

/* ===== 表格基础 ===== */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: none;
    white-space: nowrap;
    background: #f8f9fa;
}
.table td {
    vertical-align: middle;
}
.table-danger {
    --bs-table-bg: #fff5f5;
}
.table-responsive {
    border-radius: 0 0 10px 10px;
}
.pagination {
    margin-bottom: 0;
}

/* ===== 滚动条 ===== */
.table-responsive::-webkit-scrollbar {
    height: 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

/* ===== 手机端底部导航 ===== */
.mobile-bottom-nav {
    display: none; /* 桌面端隐藏 */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    padding: 4px 0;
    /* iOS safe area */
    padding-bottom: max(4px, env(safe-area-inset-bottom, 4px));
}
.mobile-bottom-nav .nav-item {
    flex: 1;
    text-align: center;
}
.mobile-bottom-nav .nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 4px;
    color: #6c757d;
    font-size: 0.7rem;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.15s;
}
.mobile-bottom-nav .nav-link i {
    font-size: 1.3rem;
    margin-bottom: 2px;
}
.mobile-bottom-nav .nav-link.active {
    color: #0d6efd;
    background: rgba(13,110,253,0.08);
}
.mobile-bottom-nav .nav-link:active {
    background: rgba(13,110,253,0.15);
}

/* ===== 手机端：表格→卡片转换 ===== */
@media (max-width: 767.98px) {
    /* 基础间距 */
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }
    .navbar .container-fluid {
        padding-left: 16px;
        padding-right: 16px;
    }
    h4 {
        font-size: 1.15rem;
    }

    /* body底部留白增加 */
    body {
        padding-bottom: 80px;
    }

    /* 表格→卡片转换 */
    .table-responsive table.table {
        width: 100%;
    }
    .table-responsive table.table thead {
        display: none;
    }
    .table-responsive table.table tbody,
    .table-responsive table.table tfoot,
    .table-responsive table.table tr {
        display: block;
    }
    .table-responsive table.table tr {
        background: #fff;
        border: 1px solid #e8e8e8;
        border-radius: 10px;
        padding: 12px 14px;
        margin-bottom: 10px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        position: relative;
    }
    .table-responsive table.table tr:last-child {
        margin-bottom: 0;
    }
    .table-responsive table.table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 5px 0;
        border: none;
        font-size: 0.9rem;
        min-height: 32px;
    }
    .table-responsive table.table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6c757d;
        font-size: 0.78rem;
        flex-shrink: 0;
        margin-right: 8px;
        min-width: 60px;
    }
    .table-responsive table.table td.text-end {
        justify-content: flex-end;
    }
    .table-responsive table.table td.text-end::before {
        order: -1;
        margin-right: auto;
    }
    .table-responsive table.table td.text-center {
        justify-content: center;
    }
    .table-responsive table.table td.text-center::before {
        display: none;
    }
    /* 空白占位行不显示 */
    .table-responsive table.table td:empty::before {
        content: none;
    }
    /* 空状态 */
    .table-responsive table.table td[colspan] {
        display: block;
        text-align: center;
        padding: 20px;
    }
    .table-responsive table.table td[colspan]::before {
        display: none;
    }

    /* tfoot 行 -- 汇总行在小屏上保持清晰 */
    .table-responsive table.table tfoot tr {
        background: #f8f9fa;
        border: 1px solid #dee2e6;
    }
    .table-responsive table.table tfoot td {
        font-weight: 600;
        font-size: 0.85rem;
    }
    .table-responsive table.table tfoot td:empty,
    .table-responsive table.table tfoot td:has(::before):empty {
        display: none;
    }

    /* 表格内按钮行 */
    .table-responsive table.table td:has(.btn):not(:has(::before)) {
        justify-content: flex-end;
        gap: 6px;
        padding-top: 8px;
        border-top: 1px solid #eee;
        margin-top: 4px;
    }
    .table-responsive table.table td .btn {
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* 导航栏在手机上紧凑 */
    .navbar-brand {
        font-size: 1rem;
    }

    /* 筛选表单手机端堆叠更清爽 */
    .row.g-2 .col-md-2,
    .row.g-2 .col-md-3,
    .row.g-2 .col-md-4,
    .row.g-2 .col-md-5 {
        width: 100%;
    }
    .row.g-2 .form-label {
        font-size: 0.82rem;
        margin-bottom: 0.1rem;
    }

    /* 统计卡片在手机上 */
    .card .row.g-3 > [class*="col-"] {
        width: 50%;
    }
    .card .row.g-3 > [class*="col-"] .card-body {
        padding: 0.7rem;
    }
    .card .row.g-3 h2 {
        font-size: 1.3rem;
    }
    .card .row.g-3 h6 {
        font-size: 0.75rem;
    }

    /* 库存查询的汇总统计 */
    .row.g-3.mb-3 > .col-md-4 {
        width: 50%;
    }
    .row.g-3.mb-3 h2 {
        font-size: 1.2rem;
    }
    .row.g-3.mb-3 h6 {
        font-size: 0.75rem;
    }

    /* 库存查询的分类卡片header */
    .card-header .d-flex {
        flex-wrap: wrap;
        gap: 4px;
    }
    .card-header small {
        font-size: 0.75rem;
    }

    /* 库存流水 - 筛选行 */
    .row.g-2 .col-md-2.align-items-end .btn {
        margin-top: 4px;
    }

    /* 分页 */
    .pagination .page-link {
        padding: 0.4rem 0.7rem;
        font-size: 0.85rem;
        min-width: 36px;
        text-align: center;
    }

    /* 首页快捷操作按钮更大 */
    .d-grid.gap-2 .btn {
        padding: 0.8rem 1rem;
        font-size: 1rem;
    }

    /* 底部导航显示 */
    .mobile-bottom-nav {
        display: flex;
    }

    /* 入库/出库/添加商品页面 - 手机端全宽 */
    .row.justify-content-center > .col-md-8,
    .row.justify-content-center > .col-lg-6 {
        width: 100%;
    }

    /* 预警列表在手机上 */
    .list-group-item.d-flex {
        flex-wrap: wrap;
        padding: 10px 12px;
    }

    /* 商品表单 - 手机端两列变一列 */
    .product-form .row.g-3 > .col-md-4,
    .product-form .row.g-3 > .col-md-6 {
        width: 100%;
    }

    /* 模态框手机端全屏 */
    .modal-dialog {
        margin: 0.5rem;
    }
    .modal-content {
        border-radius: 12px;
    }

    /* 提示 */
    .alert {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

/* ===== 桌面微调 ===== */
@media (min-width: 768px) {
    .navbar-brand {
        font-size: 1.2rem;
    }
}

/* 预警行高亮 */
.table-danger {
    --bs-table-bg: #fff5f5;
}

/* 清除浮动 */
.modal-footer .btn {
    min-height: 40px;
}
