/* 订单明细表列显隐：避免不含税与含税列同时显示造成冗余 */
/* 税率>0: 隐藏不含税单价与金额列，仅显示含税与含税金额 */
.items-table.tax-mode .untaxed-price-col,
.items-table.tax-mode .untaxed-amount-col {
    display: none !important;
}
/* 税率=0: 隐藏含税与含税金额列，仅显示不含税单价与金额 */
.items-table:not(.tax-mode) .taxed-price-col,
.items-table:not(.tax-mode) .taxed-amount-col {
    display: none !important;
}

/* ====== 库存调整类单据(报升/报损/调拨)：只显示不含税单价+金额 ====== */
/* 隐藏：税率(%)、含税价、含税金额 三列 */
/* 保留：单价(不含税)、金额(不含税) */
.items-table.stock-adj-mode .tax-rate-col,
.items-table.stock-adj-mode .taxed-price-col,
.items-table.stock-adj-mode .taxed-amount-col {
    display: none !important;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
}

/* 收件地址：只读无框，长地址自适应 */
.address-readonly {
    width: 100%;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 8px 0 !important;
    font-size: 14px;
    color: #374151;
    cursor: default;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
}
.address-readonly:focus {
    outline: none;
    border: none;
    box-shadow: none;
    background: transparent;
}
.address-readonly::-webkit-scrollbar {
    height: 4px;
}
.address-readonly::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

/* 收款/付款账户合并列：占据原账户+账号两列宽度 */
#payment-bank-group {
    grid-column: span 2;
}

@media (max-width: 1200px) {
    .form-row {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1000px) {
    .form-row {
        grid-template-columns: repeat(3, 1fr);
    }
    #payment-bank-group {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 订单明细表格 - Excel风格 */
.items-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 12px;
    border: 1.5px solid #6B8E23;
    border-radius: 4px;
    overflow: hidden;
    table-layout: fixed;
}

/* 独立边框类 - 与码单表格一致 */
.excel-border-r { border-right: 1.5px solid #6B8E23; }
.excel-border-b { border-bottom: 1.5px solid #6B8E23; }
.excel-border-t { border-top: 1.5px solid #6B8E23; }
.excel-border-l { border-left: 1.5px solid #6B8E23; }

.items-table th,
.items-table td {
    padding: 4px 6px;
    text-align: left;
    font-size: 13px;
    border-right: 1.5px solid #6B8E23;
    border-bottom: 1.5px solid #6B8E23;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.items-table th:last-child,
.items-table td:last-child {
    border-right: none;
}

.items-table th {
    background: #D9E1F2;
    font-weight: 600;
    color: #1F2937;
    text-align: center;
    padding: 6px 4px;
    white-space: nowrap;
}

.items-table input[type=number]::-webkit-inner-spin-button,
.items-table input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.items-table input[type=number] {
    -moz-appearance: textfield;
}

.items-table .num-input {
    text-align: right;
}

.items-table .num-display {
    text-align: right;
    font-weight: 500;
}

/* Excel风格输入框 */
.items-table .excel-input {
    width: 100%;
    padding: 2px 4px;
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    transition: all 0.15s;
}

.items-table .excel-input:focus {
    box-shadow: 0 0 0 1px #165DFF;
    background: #fff;
}

.items-table .excel-input.text-center {
    text-align: center;
}

.items-table .excel-input.text-right {
    text-align: right;
}

/* 表格内居中对齐 */
.items-table td.text-center,
.items-table th.text-center {
    text-align: center;
}

/* 颜色块容器 */
.items-table .color-cell {
    display: flex;
    align-items: center;
    gap: 4px;
}

.items-table .color-block {
    display: inline-block;
    width: 28px;
    height: 28px;
    border-radius: 3px;
    flex-shrink: 0;
    vertical-align: middle;
}

/* 选中行样式 */
.items-table tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.items-table tr:hover td {
    background-color: rgba(229, 231, 235, 0.6) !important;
}
.items-table tr.row-selected,
.items-table tr.row-selected td {
    background-color: #a5c8ff !important;
    border: none !important;
}

/* 测色状态指示器 */
.colorimeter-connected {
    background-color: #22c55e !important;
}
.colorimeter-disconnected {
    background-color: #ef4444 !important;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f8f9fa;
    flex-shrink: 0;
}

.btn {
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover {
    opacity: 0.9;
}

.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending {
    background: rgba(22, 93, 255, 0.15);
    color: #1d4ed8;
}

.status-paid {
    background: #fef3c7;
    color: #d97706;
}

.status-shipped {
    background: #dcfce7;
    color: #16a34a;
}

.status-completed {
    background: #f3f4f6;
    color: #6b7280;
}

.status-cancelled {
    background: #fee2e2;
    color: #dc2626;
}

.view-mode input,
.view-mode select,
.view-mode textarea {
    background: #f8f9fa;
    cursor: default;
}

/* 自定义下拉组件样式 */
.custom-select {
    position: relative;
    width: 100%;
}

.custom-select select,
.custom-select input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
    cursor: pointer;
    background-color: white;
}

.custom-select select:focus,
.custom-select input[type="text"]:focus {
    outline: none;
    border-color: #2563eb;
}

.custom-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.dropdown-search {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    outline: none;
}

.dropdown-search:focus {
    border-bottom-color: #2563eb;
}

.dropdown-options {
    flex: 1;
    overflow-y: auto;
    max-height: 200px;
}

.dropdown-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f5f5f5;
    transition: background-color 0.15s;
}

.dropdown-option:hover {
    background-color: #f0f4ff;
}

.dropdown-option.selected {
    background-color: #e0e7ff;
    color: #3730a3;
}

.dropdown-footer {
    padding: 8px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.dropdown-add-btn {
    width: 100%;
    padding: 8px;
    border: 1px dashed #2563eb;
    background: white;
    color: #2563eb;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.dropdown-add-btn:hover {
    background: #2563eb;
    color: white;
}

/* 隐藏原生select但保留功能 */
.custom-select select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.custom-select select:disabled {
    background-color: #f8f9fa;
    cursor: not-allowed;
}

.view-mode .custom-select select,
.view-mode .custom-select input[type="text"] {
    background: #f8f9fa;
    cursor: default;
    pointer-events: none;
}

/* Autocomplete Select Component */
.autocomplete-select {
    position: relative;
    display: inline-block;
}

.autocomplete-select .ac-input {
    width: 100%;
    min-width: 100px;
    padding: 6px 28px 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.autocomplete-select .ac-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.autocomplete-select .ac-input:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
    color: #9ca3af;
}

.autocomplete-select .ac-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #6b7280;
    font-size: 10px;
    transition: transform 0.2s;
}

.autocomplete-select.active .ac-arrow {
    transform: translateY(-50%) rotate(180deg);
}

/* 下拉框已移至body，使用fixed定位 */
.ac-dropdown {
    max-height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    box-sizing: border-box;
}

.ac-dropdown.active {
    display: block;
}

.ac-dropdown .ac-options {
    padding: 4px 0;
}

.ac-dropdown .ac-option {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
    white-space: nowrap;
}

.ac-dropdown .ac-option:hover,
.ac-dropdown .ac-option.highlighted {
    background-color: rgba(22, 93, 255, 0.20);
}

.ac-dropdown .ac-option.selected {
    background-color: rgba(22, 93, 255, 0.30);
    color: #1e40af;
    font-weight: 500;
}

.ac-dropdown .ac-clear-option {
    border-bottom: 1px solid #e5e7eb;
    color: #6b7280;
    font-style: italic;
}

.ac-dropdown .ac-clear-option:hover {
    background-color: #f3f4f6;
    color: #374151;
}

.ac-dropdown .ac-empty {
    padding: 12px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

/* 滚动条样式 */
.ac-dropdown::-webkit-scrollbar {
    width: 8px;
}

.ac-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.ac-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.ac-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.help-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
    color: #9ca3af;
    margin-left: 6px;
    font-size: 0.875rem;
}
.help-tip:hover,
.help-tip:focus {
    color: #165DFF;
}
.help-tip .help-tip-content {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    padding: 10px 14px;
    background: #1f2937;
    color: #fff;
    font-size: 12px;
    font-weight: normal;
    line-height: 1.6;
    border-radius: 6px;
    white-space: normal;
    word-wrap: break-word;
    z-index: 10001;
    pointer-events: none;
    min-width: 300px;
    max-width: 380px;
}
.help-tip:hover .help-tip-content,
.help-tip:focus .help-tip-content {
    visibility: visible;
    opacity: 1;
}
.help-tip .help-tip-content::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: #1f2937;
}