/* ========================================
   任务查询模态框 - 简洁居中版
   所有设备统一居中显示
======================================== */

/* 模态框容器 */
.task-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden; /* 只禁止横向滚动 */
    overflow-y: auto;   /* 允许纵向滚动，防止内容过长 */
    max-width: 100vw;
    max-height: 100vh;
}

/* 显示状态 */
.task-modal[style*="display: flex"],
.task-modal[style*="display: block"]:not([style*="display: none"]) {
    display: flex !important;
}

/* 背景遮罩 */
.task-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 模态框主体 - 始终居中 */
.task-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    transform: scale(0.95);
    animation: modalFadeIn 0.3s ease forwards;
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* 移动端触摸滚动优化 */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

@keyframes modalFadeIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 关闭时动画 */
.task-modal.closing .task-modal-content {
    animation: modalFadeOut 0.3s ease forwards;
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* ========== 头部区域 ========== */
.task-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.task-modal-header h3 {
    margin: 0;
    font-size: 22px;
    color: #1565c0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 关闭按钮 */
.task-modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.task-modal-close:hover {
    background: #f5f5f5;
    color: #333;
    transform: rotate(90deg);
}

.task-modal-close:active {
    transform: rotate(90deg) scale(0.9);
}

/* ========== 内容区域 ========== */
.task-modal-body {
    color: #333;
}

/* 查询区域 */
.query-section {
    margin-bottom: 25px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 14px;
    border: 2px solid #dee2e6;
}

.query-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 12px;
}

.query-label::before {
    content: '🔍';
    font-size: 16px;
}

.required {
    color: #e74c3c;
    font-weight: 900;
}

.query-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.query-input {
    flex: 1;
    padding: 13px 16px;
    border: 2px solid #ced4da;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Courier New', Consolas, Monaco, monospace;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    background: white;
}

.query-input:hover {
    border-color: #90caf9;
}

.query-input:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.15);
    background: #fff;
}

.query-input-group .btn {
    padding: 12px 24px;
    white-space: nowrap;
    flex-shrink: 0;
}

.query-hint {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
    margin: 0;
}

.query-hint::before {
    content: '💡';
    font-size: 14px;
}

/* 查询结果区域 */
#queryResultSection {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    animation: fadeInDown 0.3s ease;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.query-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(33, 150, 243, 0.15);
    flex-wrap: wrap;
    gap: 12px;
}

.query-result-header h4 {
    margin: 0;
    font-size: 18px;
    color: #1565c0;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 状态徽章 */
.result-status-badge {
    padding: 7px 18px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 700;
    background: #e0e0e0;
    color: #666;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.5px;
}

.result-status-badge.success {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
    color: white;
    box-shadow: 0 3px 12px rgba(76, 175, 80, 0.4);
}

.result-status-badge.running {
    background: linear-gradient(135deg, #42a5f5 0%, #1e88e5 100%);
    color: white;
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 3px 12px rgba(33, 150, 243, 0.4);
}

.result-status-badge.failed {
    background: linear-gradient(135deg, #ef5350 0%, #e53935 100%);
    color: white;
    box-shadow: 0 3px 12px rgba(244, 67, 54, 0.4);
}

.result-status-badge.pending {
    background: linear-gradient(135deg, #ffa726 0%, #fb8c00 100%);
    color: white;
    box-shadow: 0 3px 12px rgba(255, 152, 0, 0.4);
}

@keyframes pulse {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* 结果信息网格 */
.result-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.result-info-item {
    background: linear-gradient(135deg, #f5f7fa 0%, #e8f0f7 100%);
    padding: 14px 16px;
    border-radius: 12px;
    border: 2px solid #bbdefb;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.result-info-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #2196f3 0%, #1976d2 100%);
}

.result-info-item:hover {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.25);
    border-color: #90caf9;
}

.result-info-item .info-label {
    display: block;
    font-size: 12px;
    color: #1565c0;
    margin-bottom: 6px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-info-item .info-value {
    display: block;
    font-size: 14px;
    color: #263238;
    font-weight: 600;
    word-break: break-all;
    line-height: 1.5;
}

.result-info-item code {
    font-family: 'Courier New', Consolas, Monaco, monospace;
    background: rgba(33, 150, 243, 0.1);
    padding: 3px 8px;
    border-radius: 6px;
    color: #0d47a1;
    font-size: 12px;
    font-weight: 600;
}

/* 账号详情区域 */
#accountDetailsSection {
    margin-top: 20px;
    animation: fadeInDown 0.3s ease 0.1s backwards;
}

.account-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(76, 175, 80, 0.15);
}

.account-details-header h5 {
    margin: 0;
    font-size: 18px;
    color: #2e7d32;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 按钮样式 */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    line-height: 1.4;
}

.btn-primary {
    background: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(30, 136, 229, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 136, 229, 0.4);
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-success {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
    color: white;
    box-shadow: 0 3px 10px rgba(76, 175, 80, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-success::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-success:hover::before {
    left: 100%;
}

.btn-success:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* 导出 CSV 按钮特殊样式 */
#exportQueryCSV {
    min-width: auto;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* 账号详情网格 */
.account-details-grid {
    background: linear-gradient(135deg, #f1f8e9 0%, #dcedc8 100%);
    border: 2px solid #aed581;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(139, 195, 74, 0.15);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    border-left: 4px solid #8bc34a;
    gap: 12px;
    transition: all 0.3s;
}

.detail-row:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(139, 195, 74, 0.2);
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-row strong {
    color: #33691e;
    font-size: 13px;
    min-width: 130px;
    flex-shrink: 0;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.detail-row strong::before {
    content: '▪';
    color: #8bc34a;
    margin-right: 6px;
    font-size: 16px;
}

.detail-row span {
    flex: 1;
    text-align: right;
    font-size: 13px;
    color: #424242;
    word-break: break-all;
    font-weight: 500;
    line-height: 1.6;
}

.token-text {
    font-family: 'Courier New', Consolas, Monaco, monospace;
    font-size: 11px !important;
    background: rgba(139, 195, 74, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
    max-width: 100%;
}

/* 错误信息区域 - 扁平化设计 */
.error-section {
    margin-top: 20px;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    border-left: 4px solid #f44336;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: fadeInDown 0.3s ease;
}

.error-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid #ffebee;
}

.error-icon {
    font-size: 24px;
    line-height: 1;
}

.error-header strong {
    font-size: 16px;
    font-weight: 600;
    color: #d32f2f;
}

.error-label {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.error-message {
    padding: 0;
    background: transparent;
    border-radius: 0;
    color: #333;
    font-size: 14px;
    line-height: 1.8;
    word-break: break-word;
    margin-bottom: 15px;
}

.retry-btn {
    width: 100%;
    margin-top: 10px;
}

/* 失败任务列表 */
.failed-tasks-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 5px 0;
}

.failed-task-item {
    background: #fafafa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    border-left: 3px solid #ff5252;
    transition: all 0.2s ease;
}

.failed-task-item:hover {
    background: #f5f5f5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

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

.task-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.task-item-title {
    font-weight: 600;
    color: #d32f2f;
    font-size: 14px;
}

.task-item-badge {
    background: #ffebee;
    color: #c62828;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.task-item-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

.task-item-info strong {
    color: #333;
    font-weight: 600;
    min-width: 70px;
    display: inline-block;
}

.task-item-info code {
    background: #e0e0e0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-family: 'Courier New', monospace;
}

.task-error-detail {
    margin-top: 10px;
    padding: 10px;
    background: #fff3e0;
    border-radius: 6px;
    border-left: 3px solid #ff9800;
}

.task-error-detail strong {
    color: #e65100;
    font-size: 12px;
    display: block;
    margin-bottom: 5px;
}

.task-error-detail div {
    color: #666;
    font-size: 13px;
    line-height: 1.5;
}

/* 滚动条美化 */
.task-modal-content::-webkit-scrollbar,
.failed-tasks-list::-webkit-scrollbar {
    width: 6px;
}

.task-modal-content::-webkit-scrollbar-track,
.failed-tasks-list::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 10px;
}

.task-modal-content::-webkit-scrollbar-thumb,
.failed-tasks-list::-webkit-scrollbar-thumb {
    background: #bdbdbd;
    border-radius: 10px;
    transition: background 0.2s ease;
}

.task-modal-content::-webkit-scrollbar-thumb:hover,
.failed-tasks-list::-webkit-scrollbar-thumb:hover {
    background: #9e9e9e;
}

/* ==========================================
   响应式设计 - 所有设备居中显示
========================================== */

/* 平板和小笔记本 (≤ 992px) */
@media (max-width: 992px) {
    .task-modal-content {
        max-width: 550px;
        width: 92%;
        padding: 28px 25px;
    }

    .task-modal-header h3 {
        font-size: 21px;
    }
    
    .error-section {
        padding: 16px;
    }
    
    .failed-task-item {
        padding: 12px;
    }
}

/* 小屏平板 (≤ 768px) */
@media (max-width: 768px) {
    .task-modal {
        padding: 15px;
    }

    .task-modal-content {
        max-width: 500px;
        width: 95%;
        padding: 25px 20px;
        max-height: 90vh;
    }

    .task-modal-header {
        margin-bottom: 18px;
        padding-bottom: 12px;
    }

    .task-modal-header h3 {
        font-size: 20px;
    }

    .task-modal-close {
        font-size: 26px;
        width: 34px;
        height: 34px;
    }

    .query-section {
        margin-bottom: 18px;
        padding: 16px;
    }

    .query-label::before {
        font-size: 15px;
    }

    .result-info-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .query-input-group {
        flex-direction: column;
        gap: 8px;
    }

    .query-input-group .btn {
        width: 100%;
    }

    .account-details-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .account-details-header h5 {
        font-size: 17px;
    }
    
    .error-section {
        padding: 15px;
        margin-top: 15px;
    }
    
    .error-header {
        margin-bottom: 12px;
        padding-bottom: 10px;
    }
    
    .error-icon {
        font-size: 20px;
    }
    
    .failed-task-item {
        padding: 12px;
        margin-bottom: 10px;
    }
    
    .task-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .failed-tasks-list {
        max-height: 300px;
    }

    #exportQueryCSV {
        width: 100%;
        justify-content: center;
        padding: 10px 18px;
        font-size: 14px;
    }

    .account-details-grid {
        padding: 16px;
    }

    .detail-row {
        flex-direction: column;
        gap: 8px;
        padding: 14px;
        align-items: flex-start;
    }

    .detail-row:hover {
        transform: translateX(0) translateY(-2px);
    }

    .detail-row strong {
        min-width: auto;
        font-size: 12px;
    }

    .detail-row span {
        text-align: left;
        font-size: 12px;
        width: 100%;
    }

    .token-text {
        font-size: 10px !important;
        padding: 3px 6px;
    }
}

/* 大手机 (≤ 576px) */
@media (max-width: 576px) {
    .task-modal {
        padding: 12px;
        align-items: flex-start; /* 从顶部开始，方便滚动 */
        padding-top: 20px;
    }

    .task-modal-content {
        width: 98%;
        padding: 22px 18px;
        max-height: 90vh;
        border-radius: 14px;
        margin: 0 auto;
    }

    .task-modal-header h3 {
        font-size: 19px;
    }

    .query-section {
        padding: 14px;
    }

    .query-label {
        font-size: 13px;
    }

    .query-label::before {
        font-size: 14px;
    }

    .query-input {
        font-size: 14px;
        padding: 11px 14px;
    }

    .btn {
        padding: 11px 18px;
        font-size: 14px;
    }

    .query-hint {
        font-size: 11px;
    }

    .account-details-header h5 {
        font-size: 16px;
    }

    .account-details-grid {
        padding: 14px;
        border-radius: 14px;
    }

    .detail-row {
        padding: 12px;
        margin-bottom: 6px;
    }
}

/* 小手机 (≤ 480px) */
@media (max-width: 480px) {
    .task-modal {
        padding: 10px;
    }

    .task-modal-content {
        width: 100%;
        padding: 20px 15px;
        max-height: 93vh;
        border-radius: 12px;
    }

    .task-modal-header {
        margin-bottom: 15px;
        padding-bottom: 10px;
    }

    .task-modal-header h3 {
        font-size: 18px;
        gap: 6px;
    }

    .task-modal-close {
        font-size: 24px;
        width: 32px;
        height: 32px;
    }

    .query-section {
        padding: 12px;
    }

    .query-label {
        font-size: 13px;
        margin-bottom: 8px;
    }

    .query-label::before {
        font-size: 14px;
    }

    .query-input {
        font-size: 13px;
        padding: 10px 12px;
        border-radius: 8px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .query-hint {
        font-size: 11px;
    }

    .result-info-item {
        padding: 10px;
    }

    .account-details-header h5 {
        font-size: 16px;
    }

    #exportQueryCSV {
        padding: 10px 16px;
        font-size: 13px;
    }

    .account-details-grid {
        padding: 12px;
        border-radius: 12px;
    }

    .detail-row {
        padding: 10px 12px;
        margin-bottom: 6px;
        border-radius: 8px;
    }

    .detail-row strong,
    .detail-row span {
        font-size: 12px;
    }

    .token-text {
        font-size: 10px !important;
    }

    .query-result-header h4 {
        font-size: 16px;
    }

    .result-status-badge {
        font-size: 12px;
        padding: 5px 12px;
    }
}

/* 超小屏 (≤ 360px) */
@media (max-width: 360px) {
    .task-modal {
        padding: 8px;
    }

    .task-modal-content {
        padding: 18px 12px;
        border-radius: 10px;
    }

    .task-modal-header h3 {
        font-size: 16px;
    }

    .task-modal-close {
        font-size: 22px;
        width: 30px;
        height: 30px;
    }

    .query-section {
        padding: 10px;
        border-radius: 12px;
    }

    .query-label {
        font-size: 12px;
    }

    .query-label::before {
        font-size: 13px;
    }

    .query-input {
        font-size: 12px;
        padding: 9px 10px;
    }

    .query-hint {
        font-size: 11px;
    }

    .query-hint::before {
        font-size: 12px;
    }

    .btn {
        padding: 9px 14px;
        font-size: 12px;
    }

    .account-details-header h5 {
        font-size: 15px;
    }

    #exportQueryCSV {
        padding: 9px 14px;
        font-size: 12px;
    }

    .account-details-grid {
        padding: 10px;
        border-radius: 10px;
    }

    .detail-row {
        padding: 8px 10px;
        margin-bottom: 5px;
        border-radius: 6px;
    }

    .detail-row strong,
    .detail-row span {
        font-size: 11px;
    }

    .detail-row strong::before {
        font-size: 14px;
        margin-right: 4px;
    }

    .token-text {
        font-size: 9px !important;
        padding: 2px 5px;
    }
}
