/*
Theme Name: 1WMS Warehouse
Theme URI: https://example.com/wms-warehouse
Author: Your Name
Author URI: https://example.com
Description: 仓库管理主题，白灰配色，响应式表格，移动端滑动查看。
Version: 2.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wms
*/

/* ========== 全局样式 ========== */
:root {
    --wms-bg: #f5f5f5;
    --wms-card-bg: #ffffff;
    --wms-text: #333333;
    --wms-text-light: #666666;
    --wms-border: #e0e0e0;
    --wms-primary: #4a4a4a;
    --wms-primary-hover: #333333;
    --wms-danger: #d9534f;
    --wms-radius: 6px;
    --wms-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* 只重置主题自己的容器，避免破坏 WordPress 编辑器/第三方插件样式 */
.wms-container, .wms-container *,
.wms-nav, .wms-nav *,
.wms-card, .wms-card * {
    box-sizing: border-box;
}

body {
    margin: 0;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--wms-bg);
    color: var(--wms-text);
    line-height: 1.6;
    font-size: 14px;
}

a {
    color: var(--wms-primary);
    text-decoration: none;
    transition: color 0.2s;
}
a:hover {
    color: var(--wms-primary-hover);
}

/* 页面容器 */
.wms-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 卡片 */
.wms-card {
    background: var(--wms-card-bg);
    border-radius: var(--wms-radius);
    box-shadow: var(--wms-shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.wms-card h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--wms-text);
    border-bottom: 2px solid var(--wms-border);
    padding-bottom: 8px;
}

/* ========== 产品信息表格（美化） ========== */
.wms-product-info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 16px;
}
.wms-product-info-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--wms-border);
}
.wms-product-info-table td.label {
    width: 30%;
    font-weight: 600;
    color: var(--wms-text);
    background: #fafafa;
}
.wms-product-info-table td.value {
    width: 70%;
    color: var(--wms-text-light);
}
.wms-product-info-table td.stock-value {
    font-size: 24px;
    font-weight: bold;
    color: #d9534f; /* 红色 */
}

/* ========== 表格响应式 ========== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: -ms-autohiding-scrollbar;
    position: relative;
    max-width: 100%;
}
/* 移动端渐隐阴影提示 */
@media (max-width: 768px) {
    .table-responsive::before,
    .table-responsive::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 20px;
        pointer-events: none;
        z-index: 1;
    }
    .table-responsive::before {
        left: 0;
        background: linear-gradient(to right, rgba(255,255,255,0.9), rgba(255,255,255,0));
    }
    .table-responsive::after {
        right: 0;
        background: linear-gradient(to left, rgba(255,255,255,0.9), rgba(255,255,255,0));
    }
}

table.wms-table {
    width: auto;
    min-width: 100%;
    border-collapse: collapse;
    background: #fff;
    table-layout: auto;
    white-space: nowrap;
}

.wms-table th,
.wms-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--wms-border);
    white-space: nowrap;
}

.wms-table thead th {
    background-color: #fafafa;
    font-weight: 600;
    color: var(--wms-text);
    border-bottom: 2px solid var(--wms-border);
}

.wms-table tbody tr:hover {
    background-color: #f9f9f9;
}

.wms-table .text-danger {
    color: var(--wms-danger);
    font-weight: bold;
}

/* 类型列颜色 */
.wms-type-inbound {
    background-color: #d4edda; /* 绿色 */
    color: #155724;
    font-weight: bold;
}
.wms-type-outbound {
    background-color: #f8d7da; /* 红色 */
    color: #721c24;
    font-weight: bold;
}

/* ========== 按钮样式 ========== */
.wms-btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: center;
    vertical-align: middle;
    transition: all 0.2s;
    background-color: var(--wms-primary);
    color: #fff;
    text-decoration: none;
    margin-right: 8px;
}

.wms-btn:hover,
.wms-btn:focus {
    background-color: var(--wms-primary-hover);
    color: #fff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(74,74,74,0.4);
}

.wms-btn-secondary {
    background-color: #fff;
    color: var(--wms-text);
    border: 1px solid #cccccc;
}
.wms-btn-secondary:hover {
    background-color: #f5f5f5;
    border-color: #999999;
    color: var(--wms-text);
}

.wms-btn-danger {
    background-color: var(--wms-danger);
    color: #fff;
}
.wms-btn-danger:hover {
    background-color: #c9302c;
}

.wms-btn:disabled,
.wms-btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========== 表单样式 ========== */
.wms-form-group {
    margin-bottom: 15px;
}
.wms-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--wms-text);
}
.wms-form-group input[type="text"],
.wms-form-group input[type="number"],
.wms-form-group select,
.wms-form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cccccc;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}
.wms-form-group input:focus,
.wms-form-group select:focus,
.wms-form-group textarea:focus {
    border-color: var(--wms-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(74,74,74,0.2);
}

/* ========== 消息提示 ========== */
.wms-alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-weight: 500;
}
.wms-alert-success {
    background-color: #dff0d8;
    color: #3c763d;
    border: 1px solid #d6e9c6;
}
.wms-alert-error {
    background-color: #f2dede;
    color: #a94442;
    border: 1px solid #ebccd1;
}

/* ========== 响应式调整 ========== */
@media (max-width: 768px) {
    .wms-container {
        padding: 12px;
    }
    .wms-btn {
        padding: 5px 10px;
        font-size: 13px;
        margin-right: 4px;
    }
    .wms-card {
        padding: 15px;
    }
    .wms-product-info-table td.label {
        width: 40%;
    }
    .wms-product-info-table td.value {
        width: 60%;
    }
    .wms-product-info-table td.stock-value {
        font-size: 20px;
    }
}

/* ========== WordPress 管理栏适配 ========== */
@media screen and (min-width: 783px) {
    body.admin-bar .wms-nav { top: 32px; }
}
@media screen and (max-width: 782px) {
    body.admin-bar .wms-nav { top: 46px; }
}

/* ========== 导航搜索框 ========== */
.wms-nav-search { flex: 1 1 220px; min-width: 180px; }
.wms-nav-search form { display: flex; gap: 6px; }
.wms-nav-search input[type="text"] {
    flex: 1;
    padding: 7px 12px;
    border: 1px solid var(--wms-border);
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    min-width: 120px;
}
.wms-nav-search input[type="text"]:focus {
    outline: none;
    border-color: var(--wms-primary);
    box-shadow: 0 0 0 2px rgba(74,74,74,0.2);
}
@media (max-width: 768px) {
    .wms-nav-search { flex: 1 1 auto; min-width: 0; width: auto; }
}

/* ========== 可搜索下拉组件（全局化，供产品/记录选择使用） ========== */
.wms-searchable-select { position: relative; width: 100%; }
.wms-searchable-select .wms-search-input {
    width: 100%; padding: 8px 12px; border: 1px solid var(--wms-border); border-radius: 4px;
    font-size: 14px; background: #fff;
}
.wms-searchable-select .wms-search-input:focus { outline: none; border-color: #1890ff; box-shadow: 0 0 0 2px rgba(24,144,255,0.2); }
.wms-searchable-select .wms-search-dropdown {
    display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
    max-height: 260px; overflow-y: auto; background: #fff; border: 1px solid var(--wms-border);
    border-top: none; border-radius: 0 0 4px 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin: 0; padding: 0; list-style: none;
}
.wms-searchable-select.open .wms-search-dropdown { display: block; }
.wms-searchable-select .wms-search-option {
    padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s; margin: 0;
}
.wms-searchable-select .wms-search-option:hover { background: #e6f7ff; }
.wms-searchable-select .wms-search-option.selected { background: #bae7ff; }
.wms-search-loading, .wms-search-empty { padding: 12px 15px; text-align: center; color: #999; font-size: 13px; }
.wms-search-more { padding: 8px; text-align: center; }
.wms-search-more button { padding: 4px 12px; }
.wms-recon-tab.active { background: #1890ff !important; color: #fff !important; border-color: #1890ff !important; }

/* ========== 移动端悬停阴影提示（仅移动端显示） ========== */

/* ========== 导航栏（按钮风格 + 固定置顶） ========== */
.wms-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.wms-nav .wms-container {
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.wms-nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.wms-nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.wms-nav-user span {
    color: #666666;
    font-size: 14px;
}

/* 仓库导航文字按钮（桌面隐藏） */
.wms-nav-toggle {
    display: none;
}

/* ==================== 移动端导航：仓库导航文字按钮，点击展开 ==================== */
/* 用 JS 加的 .is-mobile 类控制，不依赖媒体查询，任何手机浏览器都生效 */
.wms-nav.is-mobile > .wms-container {
    padding: 5px 8px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    row-gap: 4px;
}
.wms-nav.is-mobile .wms-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid var(--wms-border);
    border-radius: 4px;
    background: #fff;
    color: var(--wms-text);
    font-size: 13px;
    line-height: 1.35;
    cursor: pointer;
    flex: 0 0 auto;
    margin-right: 0;
    order: 1;
    font-weight: 600;
}
.wms-nav.is-mobile .wms-nav-caret {
    transition: transform 0.2s;
    font-size: 11px;
}
.wms-nav.is-mobile.open .wms-nav-caret {
    transform: rotate(180deg);
}
.wms-nav.is-mobile .wms-nav-search {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    order: 2;
}
.wms-nav.is-mobile .wms-nav-search form { gap: 4px; }
.wms-nav.is-mobile .wms-nav-search input[type="text"] {
    padding: 4px 8px;
    font-size: 13px;
    height: 31px;
    min-width: 0;
    flex: 1 1 0;
    box-sizing: border-box;
}
.wms-nav.is-mobile .wms-nav-search .wms-btn {
    padding: 3px 8px;
    font-size: 13px;
    margin-right: 0;
    white-space: nowrap;
    height: 31px;
    line-height: 1.3;
}
.wms-nav.is-mobile .wms-nav-user {
    width: auto;
    flex: 0 0 auto;
    order: 3;
    justify-content: flex-end;
    gap: 4px;
    display: flex;
    align-items: center;
}
.wms-nav.is-mobile .wms-nav-user .wms-btn {
    padding: 4px 7px;
    font-size: 12px;
    white-space: nowrap;
    margin-right: 0;
    line-height: 1.35;
}
.wms-nav.is-mobile .wms-nav-links {
    display: none;
    width: 100%;
    order: 5;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding-top: 4px;
    margin-top: 2px;
    border-top: 1px solid var(--wms-border);
}
.wms-nav.is-mobile.open .wms-nav-links {
    display: flex;
}
.wms-nav.is-mobile .wms-nav-links .wms-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 6px 8px;
    font-size: 13px;
    margin-right: 0;
    line-height: 1.35;
    border-radius: 4px;
}

/* 媒体查询兜底 */
@media (max-width: 768px) {
    .wms-nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 5px 10px;
        border: 1px solid var(--wms-border);
        border-radius: 4px;
        background: #fff;
        color: var(--wms-text);
        font-size: 13px;
        line-height: 1.35;
        cursor: pointer;
        flex: 0 0 auto;
        margin-right: 0;
        font-weight: 600;
    }
    .wms-nav .wms-container {
        padding: 5px 8px;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 5px;
        row-gap: 4px;
    }
    .wms-nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding-top: 4px;
        border-top: 1px solid var(--wms-border);
    }
    .wms-nav.open .wms-nav-links {
        display: flex;
    }
    .wms-nav-links .wms-btn {
        display: block;
        width: 100%;
        text-align: center;
        padding: 6px 8px;
        font-size: 13px;
        margin-right: 0;
        line-height: 1.35;
        border-radius: 4px;
    }
    .wms-nav-search {
        flex: 1 1 auto;
        min-width: 0;
        width: auto;
    }
    .wms-nav-search input[type="text"] {
        padding: 4px 8px;
        font-size: 13px;
        height: 31px;
        min-width: 0;
        flex: 1 1 0;
        box-sizing: border-box;
    }
    .wms-nav-search .wms-btn {
        padding: 3px 8px;
        font-size: 13px;
        margin-right: 0;
        white-space: nowrap;
        height: 31px;
        line-height: 1.3;
    }
    .wms-nav-user {
        width: auto;
        flex: 0 0 auto;
        justify-content: flex-end;
        gap: 4px;
    }
    .wms-nav-user .wms-btn {
        padding: 4px 7px;
        font-size: 12px;
        white-space: nowrap;
        margin-right: 0;
        line-height: 1.35;
    }
}

@media (max-width: 480px) {
    .wms-nav .wms-container { padding: 4px 6px; gap: 4px; }
    .wms-nav-search .wms-btn { font-size: 12px; padding: 3px 6px; }
    .wms-nav-user .wms-btn { font-size: 12px; padding: 3px 6px; }
}

/* 产品详情页二维码区域样式优化 */
#print-area .print-item-name {
    font-size: 24px;          /* 字体放大 */
    font-weight: bold;
    max-width: 200px;         /* 与二维码宽度一致（默认200px） */
    margin: 0 auto 10px;
    word-wrap: break-word;    /* 允许换行，防止超出 */
    white-space: normal;
}
#print-area img {
    max-width: 200px;
    height: auto;
}
/* 盘点对比表格：产品名称列可换行 */
.wms-inv-name {
    white-space: normal !important;
    word-break: break-word;
    min-width: 160px;
}
.wms-inventory-table th, .wms-inventory-table td {
    white-space: nowrap;
}