/* 
   紧急修复：所有按钮点击问题
   此文件将强制确保所有按钮可以点击
   最高优先级CSS修复
*/

/* ============================================================
   0. 全局伪元素不拦截点击（最高优先级）
   ============================================================ */
*::before,
*::after {
    pointer-events: none !important;
}

/* ============================================================
   1. 强制确保所有按钮可点击（最高优先级）
   ============================================================ */
   
/* 移除任何可能阻止点击的全局样式 */
* {
    /* 移除可能阻止点击的样式，但保留必要的样式 */
}

/* 确保所有按钮类型可以点击 */
button,
.btn,
.task-btn,
.task-type-btn,
input[type="button"],
input[type="submit"],
[role="button"] {
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative !important;
    z-index: 9999 !important;
}

/* 任务类型切换按钮专用修复 */
.task-type-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 10000 !important;
    position: relative !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

.task-type-btn:hover {
    pointer-events: auto !important;
}

.task-type-btn i {
    pointer-events: none !important; /* 图标不拦截点击 */
}

/* 管理操作按钮修复 */
.admin-actions {
    pointer-events: auto !important;
    position: relative !important;
    z-index: 9999 !important;
}

.admin-btn,
.admin-btn.edit,
.admin-btn.delete,
.admin-btn.toggle {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 10000 !important;
    position: relative !important;
}

.admin-btn i {
    pointer-events: none !important;
}

/* 禁用状态例外 */
button:disabled,
.btn:disabled,
.task-btn:disabled,
input[type="button"]:disabled,
input[type="submit"]:disabled {
    pointer-events: none !important;
    cursor: not-allowed !important;
    opacity: 0.5 !important;
}

/* 确保按钮内的元素不拦截点击 */
button *,
.btn *,
.task-btn * {
    pointer-events: none !important; /* 让点击事件传递到按钮本身 */
}

/* ============================================================
   2. 任务卡片按钮特殊处理
   ============================================================ */
.task-item {
    /* 确保卡片不阻止内部按钮点击 */
    pointer-events: auto !important;
}

.task-actions {
    pointer-events: auto !important;
    position: relative !important;
    z-index: 10000 !important; /* 极高层级 */
}

.task-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 10001 !important; /* 最高层级 */
    position: relative !important;
}

.task-btn:not(:disabled):hover {
    cursor: pointer !important;
}

/* ============================================================
   3. 导航栏和设置按钮
   ============================================================ */
.nav-item,
.nav-link,
.settings-btn,
.user-menu,
.user-menu button,
.dropdown-btn,
#logoutBtn,
#loginBtn {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 9999 !important;
    position: relative !important;
}

/* ============================================================
   4. 模态框和模态框按钮
   ============================================================ */
.modal {
    pointer-events: auto !important;
    z-index: 100000 !important; /* 极高层级，确保模态框显示在最上层 */
}

.modal.active {
    display: flex !important; /* 确保激活时显示 */
    visibility: visible !important;
    opacity: 1 !important;
}

.modal-content {
    pointer-events: auto !important;
    z-index: 100001 !important;
}

.modal button,
.modal .btn,
.modal-close-btn,
.modal-close {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 100002 !important;
}

/* 确保关闭按钮样式不被覆盖 - 统一 modal-close 和 modal-close-btn */
.modal-close-btn,
.modal-close,
#taskDetailCloseBtn {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 100015 !important;
    position: relative !important;
}

.modal-close-btn:hover,
.modal-close:hover,
#taskDetailCloseBtn:hover {
    pointer-events: auto !important;
    cursor: pointer !important;
}

.modal-close-btn:active,
.modal-close:active,
#taskDetailCloseBtn:active {
    pointer-events: auto !important;
}

/* 任务详情模态框 - 由 admin-modal-scroll-fix.css 管理 */

/* Flow2API 按钮专用修复 */
.flow2api-action-btn,
button.flow2api-action-btn,
#flow2apiTokensTableBody button,
#flow2apiTokensTableBody .btn {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 10000 !important;
    position: relative !important;
}

#flow2apiTokensTableBody td,
#flow2apiTokensTableBody td > div {
    pointer-events: auto !important;
}

/* ============================================================
   5. 表单按钮
   ============================================================ */
form button,
form .btn,
form input[type="submit"],
form input[type="button"] {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 9999 !important;
    position: relative !important;
}

/* 5.1 模态框内表单按钮 - 最高优先级 */
.modal form button,
.modal form .btn,
.modal .admin-form-actions button,
.modal .admin-form-actions .btn,
#userEditModal button,
#createUserModal button,
#resetPasswordModal button,
#flow2apiTokenModal button,
#flow2apiImportModal button {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 100011 !important;
    position: relative !important;
}

/* ============================================================
   6. 工具栏按钮
   ============================================================ */
.toolbar button,
.task-toolbar button,
.toolbar .btn,
.task-toolbar .btn,
#autoRefreshBtn,
#manualRefreshBtn,
#batchDownloadBtn,
#batchDeleteBtn,
#batchCreateBtn,
#startEnhanceBtn,
#startImageEnhanceBtn {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 9999 !important;
    position: relative !important;
}

/* ============================================================
   7. 过滤标签按钮
   ============================================================ */
.tab-btn,
.filter-tabs button {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 9999 !important;
    position: relative !important;
}

/* ============================================================
   8. 确保没有遮罩层覆盖按钮
   ============================================================ */
.task-item::before,
.task-item::after,
.btn::before,
.btn::after,
button::before,
button::after {
    pointer-events: none !important; /* 伪元素不拦截点击 */
}

/* ============================================================
   9. 视频清晰化页面按钮
   ============================================================ */
.enhance-upload-box button,
.video-upload-area button,
#removeVideoBtn,
#removeImageBtn {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 9999 !important;
    position: relative !important;
}

/* ============================================================
   10. 登录/注册按钮
   ============================================================ */
.auth-box button,
.auth-box .btn,
.btn-fancy-auth,
#authSwitchLink {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 9999 !important;
    position: relative !important;
}

/* 设置按钮和退出按钮 */
#settingsBtn,
#logoutBtn,
.btn-icon {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 9999 !important;
    position: relative !important;
}

/* ============================================================
   11. 确保按钮容器不阻止点击
   ============================================================ */
.button-group,
.btn-group,
.action-buttons,
.detail-actions {
    pointer-events: auto !important;
}

/* ============================================================
   12. 调试辅助：鼠标悬停高亮可点击元素
   ============================================================ */
button:not(:disabled):hover,
.btn:not(:disabled):hover,
.task-btn:not(:disabled):hover {
    outline: 2px solid rgba(249, 115, 22, 0.5) !important;
    outline-offset: 2px !important;
}

/* ============================================================
   13. 确保页面容器不阻止按钮点击
   ============================================================ */
.page-section,
.main-content,
.container,
#tasksPage,
#homePage,
#batchPage,
#enhancePage {
    pointer-events: auto !important;
}

/* ============================================================
   14. 卡片内所有子元素正确处理点击
   ============================================================ */
   
/* 任务卡片容器 - 确保不阻止内部按钮 */
.task-item {
    overflow: visible !important; /* 关键：确保按钮不被裁剪 */
    contain: none !important; /* 移除 contain 限制，允许内容溢出 */
}

/* 卡片头部 - 降低层级，不能覆盖按钮 */
.task-card-header {
    position: relative !important;
    z-index: 1 !important; /* 低层级 */
    pointer-events: auto !important;
}

/* 卡片主体 */
.task-card-body {
    position: relative !important;
    z-index: 2 !important; /* 稍高层级 */
    pointer-events: auto !important;
    overflow: visible !important; /* 确保按钮区域可见 */
}

/* 预览图片、状态占位符 - 不能阻止按钮点击 */
.card-preview-image,
.status-placeholder,
.task-prompt,
.task-tags,
.task-title-row {
    pointer-events: auto !important;
    position: relative !important;
    z-index: 1 !important; /* 低层级 */
}

/* 按钮层级加固 */
.task-actions button,
.task-actions .task-btn {
    pointer-events: auto !important;
    z-index: 10001 !important;
    position: relative !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* 移除可能导致登录/退出按钮同时显示的强制 display */
#loginBtn, #logoutBtn, #settingsBtn {
    /* 不再强制 display，交给 JS 处理 */
}

/* 强制确保查看按钮可点击 */
.task-btn.view {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 999999 !important; /* 查看按钮最高优先级 */
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    position: relative !important;
    display: inline-flex !important;
}

/* 确保按钮内的所有内容（图标、文字）都不拦截点击 */
.task-btn.view * {
    pointer-events: none !important;
}
