/**
 * 通用组件样式模块
 * 包含：模态框、通用按钮、表单输入框、任务按钮
 */

/* ==================== 模态框 ==================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background-color: #ffffff;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e4e7ed;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #303133;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #909399;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 24px;
    height: 24px;
}

.modal-close:hover {
    color: #303133;
}

.modal-body {
    padding: 20px;
}

.modal-body label {
    display: block;
    font-size: 14px;
    color: #606266;
    margin-bottom: 8px;
}

/* 🆕 阶段2+3：表单组样式 */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-of-type {
    margin-bottom: 0;
}

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

/* 🆕 阶段2+3：弹窗提示样式 */
.modal-hint {
    margin-top: 16px;
    padding: 12px;
    background-color: #f4f4f5;
    border-left: 3px solid #409eff;
    border-radius: 4px;
    font-size: 13px;
    color: #606266;
    line-height: 1.6;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e4e7ed;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ==================== 通用按钮 ==================== */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background-color: #409eff;
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #66b1ff;
}

.btn-danger {
    background-color: #f56c6c;
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #f78989;
}

.btn-cancel {
    background-color: #ffffff;
    color: #606266;
    border: 1px solid #dcdfe6;
}

.btn-cancel:hover {
    color: #409eff;
    border-color: #c6e2ff;
    background-color: #ecf5ff;
}

/* ==================== 表单输入框 ==================== */

.input-task-name {
    width: 100%;
    padding: 10px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.input-task-name:focus {
    outline: none;
    border-color: #409eff;
}

/* ==================== 任务操作按钮 ==================== */

.task-actions {
    display: flex;
    gap: 8px;
}

.task-btn {
    flex: 1;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.task-btn-primary {
    background-color: #409eff;
    color: #ffffff;
}

.task-btn-primary:hover {
    background-color: #66b1ff;
}

.task-btn-warning {
    background-color: #e6a23c;
    color: #ffffff;
}

.task-btn-warning:hover {
    background-color: #ebb563;
}

.task-btn-danger {
    background-color: #f56c6c;
    color: #ffffff;
}

.task-btn-danger:hover {
    background-color: #f78989;
}

.task-btn-success {
    background-color: #67c23a;
    color: #ffffff;
}

.task-btn-success:hover {
    background-color: #85ce61;
}

/* ==================== 🆕 阶段7：运行工具弹窗样式 ==================== */

/* 大号弹窗 */
.modal-large {
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-large .modal-body {
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

/* 工具运行区域 */
.tool-run-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e4e7ed;
}

.tool-run-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: #303133;
    margin: 0 0 12px 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

/* 工具信息 */
.tool-run-info {
    display: flex;
    gap: 24px;
    padding: 12px 16px;
    background-color: #f9fafc;
    border-radius: 6px;
}

.info-item {
    display: flex;
    gap: 8px;
    font-size: 14px;
}

.info-label {
    color: #909399;
    font-weight: 500;
}

.info-item span:last-child {
    color: #303133;
}

/* 🔧 工具信息简化样式 */
.tool-info-minimal {
    padding: 8px 0;
    margin-bottom: 16px;
    border-bottom: none;
}

.tool-created-at {
    font-size: 13px;
    color: #909399;
    padding-left: 4px;
}

/* 🆕 阶段9：可折叠区域样式 */
.section-header.clickable {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.btn-toggle {
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    color: #606266;
    transition: all 0.3s;
}

.btn-toggle:hover {
    color: #409eff;
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.3s;
}

.section-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 2000px;  /* 足够大以容纳所有内容 */
    opacity: 1;
}

.section-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
}

/* 历史操作栏 */
.history-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input {
    width: 200px;
    padding: 6px 12px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    font-size: 13px;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #409eff;
}

.sort-select {
    padding: 6px 12px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    background-color: #fff;
    transition: border-color 0.3s;
}

.sort-select:focus {
    outline: none;
    border-color: #409eff;
}

.btn-icon {
    padding: 6px 12px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-icon:hover {
    color: #409eff;
    border-color: #c6e2ff;
    background-color: #ecf5ff;
}

/* 历史列表 */
.history-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e4e7ed;
    border-radius: 6px;
    background-color: #fafafa;
}

.history-item {
    padding: 12px 16px;
    background-color: #fff;
    border-bottom: 1px solid #e4e7ed;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background-color: #f5f7fa;
}

/* 🆕 阶段7：首次执行记录高亮样式 */
.history-item.first-execution {
    background: linear-gradient(to right, #fffbeb 0%, #ffffff 100%);
    border-left: 3px solid #f59e0b;
}

.history-item.first-execution:hover {
    background: linear-gradient(to right, #fef3c7 0%, #f5f7fa 100%);
}

.history-item-main {
    flex: 1;
    min-width: 0;
}

.history-file-name {
    font-size: 14px;
    font-weight: 500;
    color: #303133;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #909399;
}

.history-actions-btns {
    display: flex;
    gap: 8px;
}

.btn-history {
    padding: 4px 12px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    background-color: #fff;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-history:hover {
    color: #409eff;
    border-color: #c6e2ff;
    background-color: #ecf5ff;
}

.btn-history.danger:hover {
    color: #f56c6c;
    border-color: #fbc4c4;
    background-color: #fef0f0;
}

/* ==================== 🆕 阶段6.2：执行历史表格（两列显示） ==================== */

.execution-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background-color: #fff;
}

.execution-history-table thead {
    background-color: #f5f7fa;
    border-bottom: 2px solid #e4e7ed;
}

.execution-history-table th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #606266;
    white-space: nowrap;
}

.execution-history-table tbody tr {
    border-bottom: 1px solid #e4e7ed;
    transition: background-color 0.2s;
}

.execution-history-table tbody tr:hover {
    background-color: #fafafa;
}

.execution-history-table tbody tr:last-child {
    border-bottom: none;
}

/* 首次执行记录高亮 */
.execution-history-table tbody tr.first-execution-row {
    background: linear-gradient(to right, #fffbeb 0%, #ffffff 100%);
    border-left: 3px solid #f59e0b;
}

.execution-history-table tbody tr.first-execution-row:hover {
    background: linear-gradient(to right, #fef3c7 0%, #fafafa 100%);
}

.execution-history-table td {
    padding: 12px 8px;
    vertical-align: middle;
}

/* 时间列 */
.col-time {
    width: 140px;
}

.badge-first-exec {
    display: inline-block;
    padding: 2px 8px;
    background-color: #fef3c7;
    color: #d97706;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    margin-bottom: 4px;
}

.time-text {
    font-size: 13px;
    color: #303133;
    margin-bottom: 2px;
}

.time-meta {
    font-size: 11px;
    color: #909399;
}

/* 文件列 */
.col-source-file,
.col-result-file {
    width: 220px;        /* 🐛 FIX: 固定宽度，防止过宽 */
    max-width: 220px;
}

/* 🐛 FIX: td 内部的包裹容器使用 flex 布局 */
.file-cell-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.file-info {
    flex: 1;
    min-width: 0;        /* 🐛 FIX: 配合overflow实现省略号 */
    max-width: 150px;    /* 🐛 FIX: 限制最大宽度 */
}

.file-name {
    font-size: 13px;
    color: #303133;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 11px;
    color: #909399;
}

.btn-file-download {
    flex-shrink: 0;
    padding: 4px 8px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    background-color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-file-download:hover {
    background-color: #ecf5ff;
    border-color: #409eff;
    transform: scale(1.1);
}

.text-muted {
    color: #c0c4cc;
    font-size: 12px;
}

/* 状态列 */
.col-status {
    width: 80px;
    text-align: center;
}

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

.status-badge.success {
    background-color: #f0f9ff;
    color: #059669;
}

.status-badge.failed {
    background-color: #fef2f2;
    color: #dc2626;
}

/* 操作列 */
.col-actions {
    width: 60px;
    text-align: center;
}

.btn-history-delete {
    padding: 4px 8px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    background-color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-history-delete:hover {
    background-color: #fef0f0;
    border-color: #f56c6c;
    transform: scale(1.1);
}

/* 空状态 */
.history-list .empty-state {
    padding: 40px 20px;
    text-align: center;
}

.history-list .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.history-list .empty-hint {
    font-size: 14px;
    color: #909399;
    margin: 0;
}

/* 分页 */
.history-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding: 8px 0;
}

.btn-page {
    padding: 6px 16px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    background-color: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-page:hover:not(:disabled) {
    color: #409eff;
    border-color: #c6e2ff;
    background-color: #ecf5ff;
}

.btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-size: 13px;
    color: #606266;
}

/* 文件上传区域 */
.tool-run-upload {
    padding: 20px;
    border: 2px dashed #d9d9d9;
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s;
    background-color: #fafafa;
}

.tool-run-upload:hover {
    border-color: #409eff;
    background-color: #f5f7fa;
}

.btn-upload {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: 1px solid #409eff;
    border-radius: 6px;
    background-color: #fff;
    color: #409eff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-upload:hover {
    background-color: #409eff;
    color: #fff;
}

.upload-icon {
    font-size: 16px;
}

.upload-hint {
    margin-top: 12px;
    font-size: 13px;
    color: #909399;
}

.current-file {
    margin-top: 16px;
    padding: 12px 16px;
    background-color: #fff;
    border: 1px solid #e4e7ed;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.file-icon {
    font-size: 24px;
}

.file-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #303133;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 13px;
    color: #909399;
}

.btn-remove {
    padding: 4px 8px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    background-color: #fff;
    color: #606266;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-remove:hover {
    color: #f56c6c;
    border-color: #fbc4c4;
    background-color: #fef0f0;
}

/* ==================== 🆕 阶段3：附件预览弹窗样式 ==================== */

.preview-info {
    padding: 16px 20px;
    background-color: #f5f7fa;
    border-bottom: 1px solid #e4e7ed;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #606266;
    flex-wrap: wrap;
}

.preview-info strong {
    color: #303133;
    font-weight: 600;
}

.preview-divider {
    color: #dcdfe6;
}

.preview-hint {
    color: #909399;
    font-style: italic;
    font-size: 13px;
}

.preview-table-container {
    padding: 20px;
    max-height: 500px;
    overflow: auto;
}

.preview-table-container .attachment-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.preview-table-container .attachment-preview-table th {
    background-color: #f5f7fa;
    color: #606266;
    font-weight: 600;
    padding: 10px 14px;
    text-align: left;
    border: 1px solid #e4e7ed;
    white-space: nowrap;
    /* 🔧 修复：移除sticky定位 */
    position: static;
}

.preview-table-container .attachment-preview-table td {
    padding: 10px 14px;
    border: 1px solid #e4e7ed;
    color: #606266;
    white-space: nowrap;
}

.preview-table-container .attachment-preview-table tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

.preview-table-container .attachment-preview-table tbody tr:hover {
    background-color: #ecf5ff;
}

.preview-table-container .attachment-more-hint {
    text-align: center;
    padding: 12px;
    color: #909399;
    font-size: 13px;
    font-style: italic;
    margin: 8px 0 0 0;
}

