/* =========================================================
   保质期计算工具 - shelf_life_calculator.css
   ========================================================= */

/* 入场动画 keyframes（使用 transform + opacity，禁用 width/height/left/top 触发重排） */
@keyframes slc-fadein {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slc-card-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Tab 内容切换动画 */
.slc-tab-anim {
    animation: slc-fadein 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 结果卡片入场动画 */
.slc-card-in {
    animation: slc-card-in 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 批量表格列宽 */
.slc-col-name       { width: 20%; }
.slc-col-date       { width: 18%; }
.slc-col-shelf-life { width: 12%; }
.slc-col-unit       { width: 10%; }
.slc-col-expiry     { width: 18%; }
.slc-col-status     { width: 14%; }
.slc-col-action     { width: 8%;  }

/* 容器 */
.slc-container {
    padding: 24px;
    min-height: 480px;
}

/* =========================================================
   Tab 导航
   ========================================================= */
.slc-tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.slc-tab-btn {
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.slc-tab-btn:hover {
    color: #3b82f6;
    background: #eff6ff;
    transform: translateY(-1px);
}

.slc-tab-btn.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    background: linear-gradient(to bottom, #eff6ff, #dbeafe);
    font-weight: 600;
}

/* =========================================================
   表单通用样式
   ========================================================= */
.slc-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-width: 580px;
    margin-bottom: 18px;
}

.slc-form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slc-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.slc-required {
    color: #ef4444;
    margin-left: 2px;
}

.slc-optional {
    color: #9ca3af;
    font-size: 12px;
    font-weight: normal;
}

.slc-input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 7px;
    font-size: 14px;
    color: #1f2937;
    background: #fafafa;
    transition: border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.slc-input:focus {
    outline: none;
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.slc-date-input {
    max-width: 200px;
}

.slc-shelf-life-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.slc-number-input {
    width: 120px;
    flex-shrink: 0;
}

.slc-select {
    padding: 9px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 7px;
    font-size: 14px;
    color: #374151;
    background: #fafafa;
    cursor: pointer;
    transition: border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 80px;
}

.slc-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
    background: #fff;
}

.slc-form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 4px;
}

/* =========================================================
   快捷填充按钮
   ========================================================= */
.slc-quick-tips {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 12px 14px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.slc-quick-label {
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
    font-weight: 500;
}

.slc-quick-btn {
    padding: 5px 13px;
    font-size: 12px;
    color: #3b82f6;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.slc-quick-btn:hover {
    background: #dbeafe;
    border-color: #60a5fa;
    color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.2);
}

/* =========================================================
   结果卡片
   ========================================================= */
.slc-result-card {
    border-radius: 14px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.09), 0 1px 6px rgba(0, 0, 0, 0.05);
    margin-top: 8px;
    max-width: 100%;
    background: #fff;
    transition: box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.slc-result-card:hover {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
}

.slc-result-status-bar {
    height: 6px;
    background: #e5e7eb;
}

.slc-result-status-bar.status-good {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}

.slc-result-status-bar.status-warning {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.slc-result-status-bar.status-expired {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.slc-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 12px;
}

.slc-result-product {
    font-size: 17px;
    font-weight: 700;
    color: #111827;
}

.slc-status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.slc-status-badge.status-good {
    background: #dcfce7;
    color: #16a34a;
}

.slc-status-badge.status-warning {
    background: #fef3c7;
    color: #d97706;
}

.slc-status-badge.status-expired {
    background: #fee2e2;
    color: #dc2626;
}

.slc-result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 4px 16px 12px;
    border-bottom: 1px solid #f3f4f6;
}

.slc-result-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.slc-result-item:hover {
    background: #f9fafb;
}

.slc-result-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.slc-result-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.slc-result-label {
    font-size: 12px;
    color: #9ca3af;
}

.slc-result-value {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}

.slc-expiry-date {
    color: #374151;
}

.slc-days-remaining.status-good {
    color: #16a34a;
}

.slc-days-remaining.status-warning {
    color: #d97706;
}

.slc-days-remaining.status-expired {
    color: #dc2626;
}

/* 进度条（使用 transform:scaleX 避免 width 触发重排） */
.slc-progress-wrap {
    padding: 4px 18px 20px;
}

.slc-progress-bar {
    height: 12px;
    background: #f3f4f6;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 6px;
}

.slc-progress-fill {
    height: 100%;
    width: 100%;
    border-radius: 10px;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    background: #22c55e;
}

.slc-progress-fill.status-good {
    background: linear-gradient(90deg, #86efac, #22c55e);
}

.slc-progress-fill.status-warning {
    background: linear-gradient(90deg, #fde68a, #f59e0b);
}

.slc-progress-fill.status-expired {
    background: linear-gradient(90deg, #fca5a5, #ef4444);
}

.slc-progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #9ca3af;
}

.slc-progress-percent {
    font-weight: 600;
    color: #6b7280;
}

/* =========================================================
   批量计算
   ========================================================= */
.slc-batch-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.slc-batch-table-wrap {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.slc-batch-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 640px;
}

.slc-batch-table thead th {
    padding: 12px 14px;
    background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
    color: #374151;
    font-weight: 600;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    font-size: 13px;
    letter-spacing: 0.01em;
}

.slc-batch-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.slc-batch-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.slc-batch-table tbody tr:last-child {
    border-bottom: none;
}

.slc-batch-table tbody tr:hover {
    background: #f9fafb;
}

.slc-batch-table td {
    padding: 8px 10px;
    vertical-align: middle;
}

.slc-batch-input {
    width: 100%;
    padding: 6px 8px;
    border: 1.5px solid #e5e7eb;
    border-radius: 5px;
    font-size: 13px;
    color: #374151;
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.slc-batch-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

.slc-batch-select {
    width: 100%;
    padding: 6px 8px;
    border: 1.5px solid #e5e7eb;
    border-radius: 5px;
    font-size: 13px;
    color: #374151;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.slc-batch-select:focus {
    outline: none;
    border-color: #3b82f6;
}

.slc-batch-expiry {
    font-size: 13px;
    color: #374151;
    font-weight: 500;
    white-space: nowrap;
}

.slc-batch-status-cell {
    white-space: nowrap;
}

.slc-batch-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.slc-batch-badge.status-good {
    background: #dcfce7;
    color: #16a34a;
}

.slc-batch-badge.status-warning {
    background: #fef3c7;
    color: #d97706;
}

.slc-batch-badge.status-expired {
    background: #fee2e2;
    color: #dc2626;
}

.slc-batch-badge.status-pending {
    background: #f3f4f6;
    color: #6b7280;
}

.slc-remove-btn {
    background: transparent;
    border: 1px solid #fca5a5;
    color: #ef4444;
    border-radius: 5px;
    padding: 4px 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.slc-remove-btn:hover {
    background: #fee2e2;
    border-color: #ef4444;
    transform: scale(1.08);
}

/* 批量汇总 */
.slc-batch-summary {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f0fdf4 0%, #f0f9ff 100%);
    border-radius: 10px;
    border: 1px solid #bbf7d0;
    margin-top: 12px;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.08);
    align-items: center;
}

.slc-summary-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #374151;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255,255,255,0.7);
}

.slc-summary-item.slc-good {
    color: #15803d;
    background: #dcfce7;
}

.slc-summary-item.slc-warning {
    color: #b45309;
    background: #fef3c7;
}

.slc-summary-item.slc-expired {
    color: #b91c1c;
    background: #fee2e2;
}

/* =========================================================
   AI 智能建议
   ========================================================= */
.slc-ai-intro {
    padding: 14px 18px;
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    border-radius: 10px;
    border: 1px solid #bfdbfe;
    margin-bottom: 22px;
    color: #374151;
    font-size: 14px;
    line-height: 1.6;
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.06);
}

.slc-ai-intro p {
    margin: 0;
}

.slc-ai-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.slc-ai-input-row .slc-input {
    flex: 1;
    min-width: 0;
}

/* Loading */
.slc-ai-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    color: #6b7280;
    font-size: 14px;
    justify-content: center;
    margin: 20px 0;
}

.slc-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: slc-spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes slc-spin {
    to { transform: rotate(360deg); }
}

/* AI结果 */
.slc-ai-result {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.09), 0 1px 6px rgba(0, 0, 0, 0.05);
    margin-top: 20px;
    max-width: 100%;
    animation: slc-card-in 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.slc-ai-result-title {
    padding: 16px 20px 14px;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    border-bottom: 1px solid #e5e7eb;
}

.slc-ai-result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #f3f4f6;
    margin: 0;
}

.slc-ai-result-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
}

.slc-ai-result-icon {
    font-size: 22px;
    flex-shrink: 0;
    margin-top: 1px;
}

.slc-ai-result-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slc-ai-result-key {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 2px;
}

.slc-ai-result-val {
    font-size: 14px;
    color: #1f2937;
    line-height: 1.6;
}

.slc-ai-apply {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-top: 1px solid #f3f4f6;
}

.slc-ai-apply-tip {
    font-size: 12px;
    color: #9ca3af;
}

/* 原始回复 */
.slc-ai-raw-wrap {
    padding: 10px 18px 14px;
    border-top: 1px solid #f3f4f6;
}

.slc-ai-raw-toggle {
    background: transparent;
    border: none;
    font-size: 12px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.slc-ai-raw-toggle:hover {
    color: #3b82f6;
}

.slc-ai-raw {
    margin-top: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    color: #475569;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

/* =========================================================
   Toast 通知
   ========================================================= */
.slc-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 11px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: #1f2937;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slc-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.slc-toast.toast-success {
    background: #16a34a;
}

.slc-toast.toast-warning {
    background: #d97706;
}

.slc-toast.toast-error {
    background: #dc2626;
}

.slc-toast.toast-info {
    background: #2563eb;
}

/* =========================================================
   响应式适配
   ========================================================= */
@media (max-width: 768px) {
    .slc-container {
        padding: 16px;
    }

    .slc-tab-btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .slc-result-grid {
        grid-template-columns: 1fr;
    }

    .slc-ai-result-grid {
        grid-template-columns: 1fr;
    }

    .slc-ai-input-row {
        flex-direction: column;
        align-items: stretch;
    }

    .slc-ai-input-row .button {
        width: 100%;
    }

    .slc-batch-toolbar {
        gap: 8px;
    }

    .slc-batch-summary {
        gap: 10px;
    }

    .slc-result-card {
        max-width: 100%;
    }

    .slc-ai-result {
        max-width: 100%;
    }
}

@media (max-width: 640px) {
    .slc-tab-nav {
        gap: 2px;
    }

    .slc-tab-btn {
        padding: 8px 10px;
        font-size: 12px;
    }

    .slc-quick-tips {
        padding: 10px 12px;
    }

    .slc-form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .slc-form-actions .button,
    .slc-form-actions .secondary {
        width: 100%;
        text-align: center;
    }

    .slc-result-card {
        max-width: 100%;
    }

    .slc-ai-result {
        max-width: 100%;
    }

    .slc-batch-toolbar .button,
    .slc-batch-toolbar .secondary,
    .slc-batch-toolbar .third {
        width: 100%;
    }

    .slc-batch-toolbar {
        flex-direction: column;
    }

    .slc-toast {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* =========================================================
   隐藏辅助类（必须放在文件最末尾，确保覆盖前面所有 display:flex/block 类定义）
   同等CSS特异性下后声明的规则优先；同时 jQuery 内联样式（更高特异性）仍可正常覆盖它。
   ========================================================= */
.slc-hidden {
    display: none;
}
