/*
╔══════════════════════════════════════════════════════════╗
║  outbound.css - 智能出库模块样式                         ║
║                                                          ║
║  📌 插拔式模块：删掉这个文件 + outbound.js 即可禁用       ║
║  📌 包含：                                                ║
║     1. 出库主弹窗（上下分层 Super Modal）                 ║
║     2. 销售单生成器弹窗                                   ║
║     3. 销售单预览/打印页                                   ║
╚══════════════════════════════════════════════════════════╝
*/

/* ========================================
   1. 出库主弹窗 - 全屏覆盖
   ======================================== */
.ob-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    z-index: 500;
    justify-content: center;
    align-items: stretch;
}
.ob-modal-overlay.show { display: flex; }

.ob-modal-container {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    animation: slideUp 0.3s ease;
}

/* 顶栏 */
.ob-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ob-modal-header h2 {
    font-size: 17px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}
.ob-modal-close {
    background: none; border: none;
    color: var(--text-muted); font-size: 24px;
    cursor: pointer; padding: 4px;
}
.ob-modal-close:hover { color: var(--text-primary); }

/* ========================================
   上半部分：AI录入区
   ======================================== */
.ob-input-layer {
    padding: 14px 16px 10px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ob-input-label {
    font-size: 12px; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 1px; margin-bottom: 8px;
}
.ob-input-layer .ai-textarea {
    height: 60px;
    margin-bottom: 8px;
}
.ob-input-actions {
    display: flex; gap: 6px; align-items: center;
    margin-bottom: 6px;
}
.ob-input-actions .voice-toggle-btn {
    height: 38px; font-size: 12.5px; flex: 0 0 auto;
    padding: 0 12px; min-width: auto;
}
.ob-clear-btn {
    width: 38px; height: 38px;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 14px;
    cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.ob-clear-btn:hover { color: var(--danger); border-color: rgba(239,68,68,0.3); }

.ob-add-btn {
    height: 38px; padding: 0 16px;
    background: var(--primary); color: white; border: none;
    border-radius: var(--radius-sm);
    font-size: 12.5px; font-weight: 700;
    cursor: pointer; font-family: inherit;
    display: flex; align-items: center; gap: 5px;
    margin-left: auto; white-space: nowrap;
    transition: all 0.12s;
}
.ob-add-btn:hover { background: var(--primary-dark); }
.ob-add-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.ob-input-status {
    font-size: 11px; color: var(--text-muted);
    min-height: 14px; text-align: center;
}

/* ========================================
   分割线
   ======================================== */
.ob-divider {
    display: flex; justify-content: space-between;
    align-items: center; padding: 8px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ob-divider span:first-child {
    font-size: 12px; font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 1px;
}
.ob-cart-count {
    font-size: 11px; font-weight: 600;
    color: var(--primary);
    background: var(--primary-glow);
    padding: 2px 8px; border-radius: 10px;
}

/* ========================================
   下半部分：购物车清单
   ======================================== */
.ob-cart-layer {
    flex: 1; overflow-y: auto;
    padding: 0;
    min-height: 120px;
}
.ob-cart-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted); text-align: center;
}
.ob-cart-empty i { font-size: 32px; margin-bottom: 10px; opacity: 0.3; }
.ob-cart-empty p { font-size: 13px; }

.ob-cart-table {
    width: 100%; border-collapse: collapse;
}
.ob-cart-table thead th {
    padding: 8px 12px; text-align: left;
    font-size: 10.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
}
.ob-cart-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    vertical-align: middle;
}
.ob-cart-table tr:hover { background: var(--bg-card); }
.ob-cart-table tr.ob-row-warn td { color: var(--danger); }
.ob-cart-table .ob-stock-hint {
    display: block; font-size: 10px;
    color: var(--danger); font-weight: 600;
    margin-top: 2px;
}

/* 数量输入框 */
.ob-qty-input {
    width: 64px; padding: 5px 8px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 14px;
    font-family: 'DM Sans', sans-serif; font-weight: 700;
    text-align: center;
}
.ob-qty-input:focus { outline: none; border-color: var(--primary); }

/* 删除按钮 */
.ob-row-del {
    background: none; border: none;
    color: var(--text-muted); font-size: 14px;
    cursor: pointer; padding: 4px 8px;
    transition: all 0.15s;
}
.ob-row-del:hover { color: var(--danger); }

/* ========================================
   底部结算栏
   ======================================== */
.ob-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    gap: 12px;
}
.ob-slip-check {
    display: flex; align-items: center; gap: 7px;
    font-size: 13px; font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer; white-space: nowrap;
    user-select: none;
}
.ob-slip-check input[type="checkbox"] {
    width: 17px; height: 17px;
    accent-color: var(--primary);
}
.ob-confirm-btn {
    height: 44px; padding: 0 24px;
    background: var(--danger); color: white; border: none;
    border-radius: var(--radius-md);
    font-size: 14px; font-weight: 700;
    cursor: pointer; font-family: inherit;
    display: flex; align-items: center; gap: 6px;
    transition: all 0.12s; white-space: nowrap;
}
.ob-confirm-btn:hover { background: #DC2626; }
.ob-confirm-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ========================================
   2. 销售单生成器弹窗
   ======================================== */
.ob-slip-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    z-index: 600;
    justify-content: center;
    align-items: center;
}
.ob-slip-overlay.show { display: flex; }

.ob-slip-container {
    width: 92%; max-width: 480px;
    max-height: 90vh; overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 20px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
    animation: modalIn 0.25s ease;
}
.ob-slip-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 16px;
}
.ob-slip-header h2 {
    font-size: 17px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}

/* 客户输入 */
.ob-slip-client {
    margin-bottom: 16px;
}
.ob-slip-client label {
    display: block; font-size: 12px;
    font-weight: 600; color: var(--text-secondary);
    margin-bottom: 5px;
}
.ob-client-input-wrap { position: relative; }
.ob-client-input {
    width: 100%; padding: 10px 14px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 14px; font-family: inherit;
}
.ob-client-input:focus { outline: none; border-color: var(--primary); }
.ob-client-suggestions {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 150px; overflow-y: auto; z-index: 10;
}
.ob-client-suggestions.show { display: block; }
.ob-client-suggestion-item {
    padding: 8px 14px; cursor: pointer;
    font-size: 13px; color: var(--text-primary);
    transition: background 0.1s;
}
.ob-client-suggestion-item:hover { background: var(--bg-card-hover); }

/* 定价表格 */
.ob-slip-table-wrap { margin-bottom: 14px; }
.ob-slip-table {
    width: 100%; border-collapse: collapse;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm); overflow: hidden;
}
.ob-slip-table th {
    padding: 8px 10px; text-align: left;
    font-size: 10.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}
.ob-slip-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.ob-slip-table tr:last-child td { border-bottom: none; }
.ob-price-input {
    width: 72px; padding: 5px 8px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--primary); font-size: 14px;
    font-family: 'DM Sans', sans-serif; font-weight: 700;
    text-align: center;
}
.ob-price-input:focus { outline: none; border-color: var(--primary); }
.ob-subtotal {
    font-weight: 700; color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
}

/* 总计 */
.ob-slip-total {
    display: flex; justify-content: space-between;
    align-items: center; padding: 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 14px;
}
.ob-slip-total span:first-child {
    font-size: 14px; font-weight: 600; color: var(--text-secondary);
}
.ob-total-amount {
    font-size: 26px; font-weight: 900;
    color: var(--danger);
    font-family: 'DM Sans', sans-serif;
}

/* 导出按钮 */
.ob-slip-export-btn {
    width: 100%; height: 46px;
    background: var(--primary); color: white; border: none;
    border-radius: var(--radius-md);
    font-size: 14px; font-weight: 700;
    cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all 0.12s;
}
.ob-slip-export-btn:hover { background: var(--primary-dark); }

/* ========================================
   3. 销售单预览（可截图/打印）
   ======================================== */
.ob-receipt-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 700;
    justify-content: center; align-items: center;
    flex-direction: column; gap: 14px;
}
.ob-receipt-overlay.show { display: flex; }

.ob-receipt-container {
    width: 88%; max-width: 380px;
    background: #fff; color: #111;
    border-radius: 12px; padding: 24px 20px;
    font-family: 'Noto Sans SC', sans-serif;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.ob-receipt-head { text-align: center; margin-bottom: 16px; }
.ob-receipt-head h3 { font-size: 18px; font-weight: 900; margin-bottom: 6px; }
.ob-receipt-meta { font-size: 12px; color: #666; line-height: 1.6; }
.ob-receipt-table {
    width: 100%; border-collapse: collapse;
    margin-bottom: 12px;
}
.ob-receipt-table th {
    padding: 6px 4px; font-size: 11px;
    text-align: left; border-bottom: 2px solid #333;
    font-weight: 700;
}
.ob-receipt-table td {
    padding: 5px 4px; font-size: 12.5px;
    border-bottom: 1px solid #ddd;
}
.ob-receipt-total {
    text-align: right; font-size: 18px;
    font-weight: 900; padding: 10px 0;
    border-top: 2px solid #333;
}
.ob-receipt-footer {
    text-align: center; font-size: 11px;
    color: #999; margin-top: 10px;
    padding-top: 10px; border-top: 1px dashed #ddd;
}
.ob-receipt-actions { display: flex; gap: 10px; }
.ob-receipt-print, .ob-receipt-done {
    height: 42px; padding: 0 24px;
    border: none; border-radius: var(--radius-md);
    font-size: 13px; font-weight: 700;
    cursor: pointer; font-family: inherit;
    display: flex; align-items: center; gap: 6px;
}
.ob-receipt-print { background: white; color: #333; }
.ob-receipt-done { background: var(--primary); color: white; }

/* 打印时只显示收据 */
@media print {
    body * { display: none !important; }
    .ob-receipt-container,
    .ob-receipt-container * { display: block !important; }
    .ob-receipt-container { position: fixed; top: 0; left: 0; width: 100%; box-shadow: none; border-radius: 0; }
    .ob-receipt-table, .ob-receipt-table * { display: table !important; }
    .ob-receipt-table tr, .ob-receipt-table tr * { display: table-row !important; }
    .ob-receipt-table th, .ob-receipt-table td { display: table-cell !important; }
    .ob-receipt-actions { display: none !important; }
    .ob-receipt-overlay { display: block !important; background: none; }
}

/* ========================================
   电脑端适配
   ======================================== */
@media (min-width: 768px) {
    .ob-modal-container {
        max-width: 560px; height: auto;
        max-height: 92vh; border-radius: var(--radius-xl);
        margin-top: 20px;
    }
}

/* ========================================
   保存图片按钮
   ======================================== */
.ob-receipt-save {
    height: 42px; padding: 0 24px;
    border: none; border-radius: var(--radius-md);
    font-size: 13px; font-weight: 700;
    cursor: pointer; font-family: inherit;
    display: flex; align-items: center; gap: 6px;
    background: var(--primary); color: white;
    transition: all 0.12s;
}
.ob-receipt-save:hover { background: var(--primary-dark); }

/* ========================================
   历史客户图标按钮（输入框右侧）
   ======================================== */
.ob-client-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ob-client-input-wrap .ob-client-input {
    flex: 1;
}
.ob-client-history-btn {
    width: 40px; height: 40px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.ob-client-history-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ========================================
   历史客户列表弹窗
   ======================================== */
.ob-client-list-popup {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    z-index: 20;
    max-height: 240px;
    overflow-y: auto;
}
.ob-client-list-popup.show { display: block; }

.ob-client-list-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}
.ob-client-list-head button {
    background: none; border: none;
    font-size: 18px; color: var(--text-muted);
    cursor: pointer;
}
.ob-client-list-head button:hover { color: var(--text-primary); }

.ob-client-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.ob-client-list-item:last-child { border-bottom: none; }
.ob-client-list-item:hover { background: var(--bg-elevated); }

.ob-client-list-name {
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    flex: 1;
}
.ob-client-list-name:hover { color: var(--primary); }

.ob-client-list-del {
    background: none; border: none;
    color: var(--text-muted); font-size: 12px;
    cursor: pointer; padding: 4px 6px;
    flex-shrink: 0;
}
.ob-client-list-del:hover { color: var(--danger); }

.ob-client-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* 包裹层需要relative定位以支持弹窗 */
.ob-slip-client {
    position: relative;
    margin-bottom: 16px;
}
