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

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

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

/* 确保关闭按钮样式不被覆盖 */
.modal-close-btn {
    width: 40px !important;
    height: 40px !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 18px !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.modal-close-btn:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.2)) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #ff6b6b !important;
    transform: rotate(90deg) scale(1.05) !important;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3) !important;
}

.modal-close-btn:active {
    transform: rotate(90deg) scale(0.95) !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2) !important;
}

/* 任务详情模态框特殊处理 - 确保初始隐藏，激活时显示 */
#taskDetailModal {
    display: none !important; /* 默认隐藏 */
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important; /* 隐藏时不接收点击 */
    z-index: 100000 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.8) !important;
}

#taskDetailModal.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important; /* 激活时可以接收点击 */
    align-items: flex-start !important;
    justify-content: center !important;
    padding: 40px 20px !important;
}

#taskDetailModal .modal-content {
    background: var(--bg-card) !important;
    border-radius: 20px !important;
    max-width: 900px !important;
    width: 100% !important;
    position: relative !important;
    z-index: 100002 !important;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.8) !important;
}

#taskDetailContent {
    pointer-events: auto !important;
    overflow-y: auto !important;
    padding: 25px !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;
}

/* ============================================================
   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;
}
