/**
 * 补货规则新建/编辑弹窗样式
 */

/* 模态框容器 */
.rules-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.rules-modal-overlay.active {
    display: flex;
}

/* 模态框内容 */
.rules-modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* 模态框头部 */
.rules-modal-header {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}

.rules-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #1d2129;
    margin: 0;
}

.rules-modal-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #6b7280;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.rules-modal-close-btn:hover {
    background: #f3f4f6;
    color: #1d2129;
}

/* 模态框主体 */
.rules-modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.rules-modal-body::-webkit-scrollbar {
    width: 6px;
}

.rules-modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.rules-modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.rules-modal-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 步骤指示器 */
.rules-steps-container {
    margin-bottom: 16px;
    padding: 0 0 16px 0;
}

.rules-steps {
    display: flex;
    justify-content: space-between;
    background: #f9fafb;
    border-radius: 6px;
    padding: 4px;
    border: 1px solid #e5e7eb;
}

.rules-step {
    flex: 1;
    text-align: center;
    padding: 12px 8px;
    position: relative;
    cursor: pointer;
}

.rules-step.active {
    background: #eff6ff;
    border-radius: 4px;
    border: 1px solid transparent;
    margin: 0 -1px;
}

.rules-step.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #0052d9;
    border-radius: 2px 2px 0 0;
}

.rules-step-number {
    display: inline-block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
}

.rules-step.active .rules-step-number {
    background: #0052d9;
    color: white;
}

.rules-step-title {
    font-size: 14px;
    color: #4b5563;
    white-space: nowrap;
}

.rules-step.active .rules-step-title {
    color: #0052d9;
    font-weight: 500;
}

/* 步骤内容 */
.rules-step-contents {
    min-height: 400px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
}

.rules-step-content {
    display: none;
    padding: 20px;
}

.rules-step-content.active {
    display: block;
}

/* 表单区域 */
.rules-form-section {
    margin-bottom: 20px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
    overflow: hidden;
}

.rules-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: white;
}

.rules-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #1d2129;
    margin: 0;
    padding: 6px 12px;
    border-radius: 4px;
    display: inline-block;
}

.rules-form-grid {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.rules-form-item {
    display: flex;
    flex-direction: column;
}

.rules-form-item.full-width {
    grid-column: 1 / -1;
}

.rules-form-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
    position: relative;
}

.rules-input-counter {
    font-size: 12px;
    color: #6b7280;
    margin-left: 8px;
    font-weight: normal;
}

.rules-form-label.required::after {
    content: '*';
    color: #ef4444;
    margin-left: 4px;
    font-weight: bold;
}

.rules-form-input,
.rules-form-textarea {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    color: #374151;
    width: 100%;
}

.rules-form-input:focus,
.rules-form-textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.1);
    outline: none;
}

.rules-form-input.input-error,
.rules-form-textarea.input-error {
    border-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    animation: shake 0.5s;
}

.section-error {
    animation: pulse 0.5s;
    border: 1px solid #ef4444;
    border-radius: 6px;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.rules-form-textarea {
    min-height: 60px;
    resize: vertical;
    font-family: inherit;
}

/* 货品区域 */
.rules-form-section .rules-section-header {
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.rules-product-scope-options {
    display: flex;
    gap: 8px;
    align-items: center;
}

.rules-product-scope-option {
    padding: 6px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
}

.rules-product-scope-option:hover {
    border-color: #0052d9;
    background-color: rgba(0, 82, 217, 0.05);
}

.rules-product-scope-option.selected {
    border-color: #0052d9;
    background-color: rgba(0, 82, 217, 0.05);
}

.rules-product-scope-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.rules-product-scope-label {
    display: block;
    cursor: pointer;
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: #1d2129;
}

.rules-products-container {
    padding: 16px;
}

.rules-all-products-container {
    padding: 16px;
}

.rules-all-products-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #6b7280;
    text-align: center;
    background-color: rgba(0, 82, 217, 0.05);
    border-radius: 8px;
}

.rules-all-products-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.rules-products-list {
    min-height: 120px;
}

.rules-empty-products {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #6b7280;
    text-align: center;
}

.rules-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.rules-add-product-btn {
    padding: 8px 16px;
    background: #0052d9;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 82, 217, 0.2);
}

.rules-add-product-btn:hover {
    background: #0041b3;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 82, 217, 0.3);
}

.rules-add-product-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 3px rgba(0, 82, 217, 0.2);
}

/* 已选择的货品表格 */
.rules-selected-products-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.rules-selected-products-table th {
    background: #f3f4f6;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.rules-selected-products-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    color: #4b5563;
}

.rules-selected-products-table tr:last-child td {
    border-bottom: none;
}

.rules-remove-product-btn {
    padding: 6px 10px;
    border: 1px solid #ef4444;
    background: white;
    color: #ef4444;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.rules-remove-product-btn:hover {
    background: #ef4444;
    color: white;
}

/* 触发条件选项 */
.rules-trigger-options {
    padding: 16px;
}

.rules-trigger-option {
    display: flex;
    align-items: flex-start;
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    background: white;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.rules-trigger-option:last-child {
    margin-bottom: 0;
}

.rules-trigger-option:hover {
    border-color: #d1d5db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.rules-trigger-option.selected {
    border-color: #0052d9;
    background: #f0f7ff;
}

.rules-trigger-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f9fafb;
    border-color: #e5e7eb;
}

.rules-trigger-option.disabled:hover {
    border-color: #e5e7eb;
    box-shadow: none;
}

.rules-trigger-option input[type="radio"] {
    margin: 0 12px 0 0;
    pointer-events: none;
}

.rules-trigger-option input[type="radio"]:disabled {
    cursor: not-allowed;
}

.rules-trigger-label {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    flex: 1;
}

.rules-trigger-title {
    font-weight: 600;
    color: #1d2129;
    margin-bottom: 4px;
    font-size: 16px;
}

.rules-trigger-desc {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.4;
}

.rules-time-input-container {
    margin-top: 12px;
}

.rules-time-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rules-time-input-group .rules-form-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.rules-time-input-group .rules-form-input {
    max-width: 200px;
}

/* 多时间点样式 */
.rules-time-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.rules-add-time-btn {
    padding: 6px 12px;
    background: #0052d9;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.rules-add-time-btn:hover {
    background: #0046c0;
}

.rules-add-time-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.rules-time-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

.rules-time-item .rules-form-input {
    flex: 1;
    max-width: 200px;
}

.rules-remove-time-btn {
    padding: 6px 12px;
    background: #e34d59;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.rules-remove-time-btn:hover {
    background: #c42b37;
}

.rules-time-note {
    font-size: 12px;
    color: #6b7280;
    margin-top: 8px;
}

/* 补货策略选项 */
.rules-strategy-options {
    padding: 16px;
}

.rules-strategy-option {
    display: flex;
    align-items: flex-start;
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    background: white;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.rules-strategy-option:last-child {
    margin-bottom: 0;
}

.rules-strategy-option:hover {
    border-color: #d1d5db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.rules-strategy-option.selected {
    border-color: #0052d9;
    background: #f0f7ff;
}

.rules-strategy-option input[type="radio"] {
    margin: 0 12px 0 0;
    pointer-events: none;
}

.rules-strategy-label {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    width: 100%;
    flex: 1;
}

.rules-strategy-title {
    font-weight: 600;
    color: #1d2129;
    margin-bottom: 8px;
    font-size: 16px;
}

.rules-strategy-desc {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.4;
}

.rules-strategy-content {
    margin-top: 8px;
}

/* 输入错误提示样式 */
.input-error-tooltip {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff2f0;
    border: 1px solid #ffccc7;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 12px;
    color: #ff4d4f;
    white-space: nowrap;
    z-index: 100;
    margin-top: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: none;
}

.input-error-tooltip::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 12px;
    border-width: 0 5px 5px;
    border-style: solid;
    border-color: transparent transparent #ffccc7 transparent;
}

.rules-form-item {
    position: relative;
}

/* 禁用状态样式 */
.rules-strategy-option.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f9fafb;
    border-color: #e5e7eb;
}

.rules-strategy-option.disabled:hover {
    border-color: #e5e7eb;
    box-shadow: none;
}

.rules-strategy-option.disabled input[type="radio"] {
    cursor: not-allowed;
}

.rules-strategy-option.disabled label {
    cursor: not-allowed;
    pointer-events: none;
}

.rules-strategy-option.disabled .rules-strategy-label {
    cursor: not-allowed;
}

/* 任务策略样式 */
.rules-wave-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* 移除margin-top，让选择框和标题在同一行 */
}

.rules-wave-option {
    display: flex;
    align-items: flex-start;
    padding: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.rules-wave-option:last-child {
    margin-bottom: 0;
}



.rules-wave-option input[type="radio"] {
    margin: 0 12px 0 0;
    /* 移除pointer-events: none，允许radio元素接收点击事件 */
}

.rules-wave-label {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    flex: 1;
}

.rules-wave-title {
    font-weight: 600;
    color: #1d2129;
    margin-bottom: 4px;
    font-size: 14px;
    line-height: 1.5;
    font-family: inherit;
}

.rules-wave-desc {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.4;
    font-family: inherit;
}

/* 确认区域 */
.rules-confirmation-container {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    overflow: hidden;
}

.rules-confirmation-content {
    padding: 16px;
}

.rules-confirmation-section {
    margin-bottom: 16px;
}

.rules-confirmation-section:last-child {
    margin-bottom: 0;
}

.rules-confirmation-section h5 {
    font-size: 16px;
    font-weight: 600;
    color: #1d2129;
    margin: 0 0 8px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #e5e7eb;
}

.rules-confirmation-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.confirmation-item {
    display: flex;
    margin-bottom: 8px;
}

.confirmation-item:last-child {
    margin-bottom: 0;
}

.confirmation-label {
    font-weight: 500;
    color: #374151;
    margin-right: 8px;
    min-width: 100px;
}

.confirmation-value {
    color: #4b5563;
    word-break: break-all;
    font-weight: 500;
}

.confirmation-detail {
    font-size: 14px;
    color: #6b7280;
    margin-top: 6px;
    padding-left: 16px;
    position: relative;
}

.confirmation-detail::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 8px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #9ca3af;
}

.confirmation-empty {
    color: #6b7280;
    font-style: italic;
    padding: 8px;
}

.confirmation-all-products {
    display: flex;
    align-items: center;
    padding: 12px;
    background: rgba(0, 82, 217, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(0, 82, 217, 0.1);
}

.confirmation-all-products-icon {
    font-size: 24px;
    margin-right: 12px;
    opacity: 0.7;
}

.confirmation-all-products-text {
    font-size: 16px;
    font-weight: 500;
    color: #1d2129;
}

.confirmation-products-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.confirmation-products-table th {
    background: #f9fafb;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.confirmation-products-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6;
    color: #4b5563;
}

.confirmation-products-table tr:last-child td {
    border-bottom: none;
}

/* 模态框底部 */
.rules-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.rules-modal-btn {
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
}

.rules-modal-btn-primary {
    background: #0052d9;
    color: white;
    border-color: #0052d9;
}

.rules-modal-btn-primary:hover {
    background: #003a8c;
}

.rules-modal-btn-secondary {
    background: white;
    color: #4b5563;
    border-color: #d1d5db;
}

.rules-modal-btn-secondary:hover {
    background: #f3f4f6;
}

/* 旧的货品选择器样式已移除，现在使用公共货品选择弹窗组件 */

/* 响应式设计 */
@media (max-width: 768px) {
    .rules-modal-content {
        width: 95%;
        max-width: none;
        max-height: 95vh;
    }
    
    .rules-form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .rules-confirmation-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .rules-steps {
        flex-direction: column;
        gap: 20px;
    }
    
    .rules-steps::before {
        display: none;
    }
    
    .rules-step {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
    
    .rules-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px;
    }
    
    .rules-add-product-btn {
        align-self: flex-end;
    }
    
    /* 旧的货品选择器响应式样式已移除，公共货品选择弹窗有自己的响应式设计 */
}