.history-item {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: 100% !important; /* 确保卡片填满网格单元格高度 */
    overflow: hidden !important;
    background-color: #fff !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 10px !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.07) !important;
    transition: all 0.25s ease-in-out !important;
    margin-bottom: 0 !important; /* 网格布局中不需要margin-bottom */
}

.history-item:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

@media (max-width: 767px) {
    .history-item {
        flex-direction: column;
    }
}

.history-info {
    flex: 1;
    padding: 15px;
}

.history-prompt {
    font-size: 16px;
    margin-bottom: 10px;
}

.history-prompt.collapsed {
    position: relative !important;
    overflow: hidden !important;
    max-height: 3em !important;
    text-overflow: initial !important;
    white-space: normal !important;
    margin-bottom: 5px !important;
    padding-right: 90px !important;
}

.history-prompt .show-more {
    display: inline-block !important;
    position: absolute !important;
    right: 0 !important;
    bottom: 0 !important;
    color: #007bff !important;
    background-color: #fff !important;
    padding: 0 5px !important;
    margin: 0 !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: normal !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    z-index: 5 !important;
    border-radius: 3px !important;
    box-shadow: -5px 0 10px 5px white !important;
}

.history-meta {
    font-size: 14px;
    color: #666;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.history-status {
    font-weight: bold;
}

.status-success {
    color: #38a169;
}

.status-error {
    color: #e53e3e;
}

.status-pending {
    color: #718096;
}

.no-history {
    padding: 20px;
    text-align: center;
    color: #718096;
    font-style: italic;
}

/* 突出显示效果 */
.highlight-task {
    border: 2px solid #4299e1;
    background-color: #ebf8ff;
}

.highlight-task-success {
    border: 2px solid #48bb78;
    background-color: #f0fff4;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-left-color: #09f;
    border-radius: 50%;
    animation: loader-spin 1s infinite linear;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes loader-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 删除按钮样式 */
.btn-danger,
.btn-sm.btn-danger,
.history-actions .btn-danger,
.delete-history {
    background-color: #e53e3e !important;
    border-color: #c53030 !important;
    color: white !important;
}

.btn-danger:hover,
.btn-sm.btn-danger:hover,
.history-actions .btn-danger:hover,
.delete-history:hover {
    background-color: #c53030 !important;
    border-color: #9b2c2c !important;
}

.history-filter {
    margin-bottom: 20px;
}

.category-tabs {
    margin-top: 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.category-tab {
    transition: all 0.2s ease;
}

.specific-type {
    cursor: pointer;
}

.dropdown-item:hover {
    background-color: #f0f0f0;
}

/* 网格布局的现代样式 - 替代旧的flex布局 */
.history-type-badge {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 5px 8px;
    border-radius: 4px;
    margin-left: 10px;
}

.history-prompt {
    flex: 1;
    max-width: calc(100% - 100px);
    margin-bottom: 8px;
}

.history-meta {
    font-size: 0.85rem;
    color: #666;
}

.history-status {
    font-weight: 500;
}

.status-completed {
    color: #28a745;
}

.status-pending {
    color: #007bff;
    animation: pulse 1.5s infinite;
}

.status-failed {
    color: #dc3545;
}

.history-thumb {
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 10px;
    max-width: 100%;
    transition: transform 0.2s ease;
}

.history-thumb:hover {
    transform: scale(1.05);
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
    100% {
        opacity: 1;
    }
}

/* Filter Section */
.history-filter {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.history-filter h5 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 600;
    color: #343a40;
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.category-tab {
    padding: 10px 18px;
    font-size: 0.95em;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.25s ease-in-out;
    border: 1px solid transparent;
}

.category-tab.btn-outline-primary {
    color: #007bff;
    background-color: transparent;
    border-color: #007bff;
}

.category-tab.btn-outline-primary:hover {
    color: #fff;
    background-color: #007bff;
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.category-tab.active.btn-primary {
    color: #fff;
    background-color: #007bff;
    border-color: #007bff;
    box-shadow: 0 3px 10px rgba(0, 123, 255, 0.35);
}

.history-items {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 20px !important;
}

.history-items .alert-info {
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 1em;
}

.history-item .card {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    border: none !important;
    box-shadow: none !important;
    background: none !important;
}

.history-item .card-body {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    position: relative !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
}

.history-item .row {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    flex: 1 !important;
    flex-wrap: nowrap !important;
}

.history-item .card-body .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    flex-wrap: nowrap !important;
    display: flex !important;
    flex-direction: column !important;
}

.history-item .history-info {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 15px !important;
    margin: 0 !important;
    display: block !important;
    order: 0 !important;
    border-bottom: 1px solid #f0f0f0 !important;
    flex: 1 !important;
}

.history-item .history-prompt {
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 0 10px 0 !important;
    padding: 0 !important;
    text-align: left !important;
    word-break: break-all !important;
}

.history-item .d-flex {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}


.history-item .history-image {
    order: -1 !important;
    width: 100% !important;
    padding: 0 !important;
    background-color: #f8f9fa !important;
    border-bottom: 1px solid #dee2e6 !important;
    display: block !important;
    min-height: 200px !important;
    flex-shrink: 0 !important;
}


.history-info .history-prompt,
.history-info .history-meta,
.history-item .history-prompt,
.history-item .history-meta {
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
}


.history-item .row .history-image .history-actions {
    display: none !important;
}


.history-item .history-actions,
.history-item .card-body .history-actions,
.history-item .card-body > .history-actions {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 10px 15px !important;
    background-color: #fff !important;
    text-align: center !important;
    flex-shrink: 0 !important;
    border-top: 1px solid #f0f0f0 !important;
    position: relative !important;
    margin: 0 !important;
    order: 999 !important;
    box-sizing: border-box !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    transform: none !important;
    z-index: auto !important;
}

.history-item .history-actions .btn {
    min-width: 75px !important;
    padding: 6px 12px !important;
    font-size: 0.875em !important;
    border-radius: 5px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    display: inline-block !important;
}

.history-item .history-actions .btn-danger,
.history-item .history-actions .btn-success,
.history-item .history-actions .btn-info {
    min-width: 90px !important;
}


.history-item .history-image img.history-thumb {
    width: 100% !important;
    height: 220px !important;
    max-width: 100% !important;
    max-height: none !important;
    object-fit: cover !important;
    border-radius: 0 !important;
    margin: 0 !important;
    display: block !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
}


.history-item .history-image:empty::before {
    content: "无图片" !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 220px !important;
    background-color: #f0f0f0 !important;
    color: #999 !important;
    font-size: 18px !important;
    border-radius: 0 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
}


.history-item .row .history-image .history-actions .btn,
.history-item .history-actions .btn {
    min-width: 75px !important;
    padding: 6px 15px !important;
    font-size: 0.875em !important;
    border-radius: 5px !important;
    margin: 0 !important;
}


.history-actions .btn-success { background-color: #28a745 !important; border-color: #28a745 !important; color:white !important; }
.history-actions .btn-info    { background-color: #17a2b8 !important; border-color: #17a2b8 !important; color:white !important; }
.history-actions .btn-danger  { background-color: #dc3545 !important; border-color: #dc3545 !important; color:white !important; }

.history-actions .btn-success:hover { background-color: #218838 !important; border-color: #1e7e34 !important; }
.history-actions .btn-info:hover    { background-color: #138496 !important; border-color: #117a8b !important; }
.history-actions .btn-danger:hover  { background-color: #c82333 !important; border-color: #bd2130 !important; }


@media (max-width: 991px) {
    .history-items {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 767px) {
    .history-items {
        grid-template-columns: 1fr !important;
    }

    .history-item .row .history-image,
    .history-item .row .history-info,
    .history-item .row .history-actions {
        padding: 12px !important;
    }

    .history-item .row .history-image img.history-thumb {
        max-height: 200px !important;
    }
}

@media (max-width: 575px) {

    .history-item .row .history-image .history-actions,
    .history-item .history-actions {
        flex-direction: column !important;
        gap: 8px !important;
    }
}

.history-type-badge.clickable-type:hover,
.history-type-badge.clickable-type.active-type {
    filter: brightness(1.1);
    box-shadow: 0 3px 10px rgba(0,0,0,0.18);
    text-decoration: none;
}

.history-thumb[src=""], .history-thumb:not([src]) {
    background-color: #eee;
}


.about-history-info {
    background-color: #f8f9fa;
    padding: 20px 25px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    margin-top: 30px;
}

.about-history-info h4 {
    font-size: 1.2em;
    font-weight: 600;
    color: #343a40;
    margin-bottom: 15px;
}

.about-history-info p {
    color: #495057;
    line-height: 1.6;
    margin-bottom: 10px;
}

.about-history-info ul {
    padding-left: 20px;
    margin-bottom: 15px;
    list-style-type: disc;
}

.about-history-info ul li {
    margin-bottom: 8px;
    color: #495057;
}

.about-history-info strong {
    color: #1a202c;
}

.history-item .history-image .no-image-placeholder {
    width: 100%;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #999;
    font-size: 18px;
    border-radius: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.history-item .history-image .pending-image-placeholder {
    width: 100%;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #999;
    font-size: 18px;
    border-radius: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    letter-spacing: 2px;
}


.history-type-badge.badge-info,
.history-type-badge[data-type="multi-image"] {
    background: #e0f3ff !important;
    color: #007bff !important;
}

.history-type-badge.badge-success,
.history-type-badge[data-type="single-image"] {
    background: #e6f9e6 !important;
    color: #28a745 !important;
}

.history-type-badge.badge-primary,
.history-type-badge[data-type="text-to-image"] {
    background: #e6eaff !important;
    color: #4f6ef7 !important;
}

.history-type-badge.badge-danger,
.history-type-badge[data-type="3d-text-to-image"] {
    background: #ffeaea !important;
    color: #e53e3e !important;
}

.history-type-badge.badge-warning,
.history-type-badge[data-type="3d-single-image"] {
    background: #fffbe6 !important;
    color: #ff9800 !important;
}

.history-type-badge.badge-dark,
.history-type-badge[data-type="3d-multi-image"] {
    background: #e6e6e6 !important;
    color: #333 !important;
}

.history-type-badge.badge-purple,
.history-type-badge[data-type="3d-relief"] {
    background: #f3e8ff !important;
    color: #8b5cf6 !important;
}

.history-type-badge.badge-orange,
.history-type-badge[data-type="inpaint"] {
    background: #fff3e0 !important;
    color: #fd7e14 !important;
}

.history-type-badge.badge-teal,
.history-type-badge[data-type="image-color-separation"] {
    background: #e0f7f6 !important;
    color: #20b2aa !important;
}

.history-type-badge.badge-pink,
.history-type-badge[data-type="ecommerce-edit"] {
    background: #fce7f3 !important;
    color: #ec4899 !important;
}

.history-type-badge.badge-secondary {
    background: #f0f0f0 !important;
    color: #888 !important;
}


.loading-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 20px 0;
    text-align: center;
}

.loading-indicator .spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0, 123, 255, 0.2);
    border-top-color: rgba(0, 123, 255, 0.8);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.end-message {
    width: 100%;
    padding: 20px 0;
    text-align: center;
    color: #999;
    font-size: 14px;
    font-style: italic;
}


.history-item .d-flex .history-prompt,
.history-item .d-flex .history-prompt.card-text,
.d-flex .history-prompt,
.d-flex .history-prompt.card-text,
.d-flex p.history-prompt,
.d-flex p.card-text {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: calc(100% - 100px) !important;
}


.history-item .history-info .d-flex,
.history-info .d-flex {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    align-items: stretch !important;
    padding: 0 !important;
}


.history-item .history-info .d-flex .history-type-badge,
.history-info .d-flex .history-type-badge,
.d-flex .badge {
    position: static !important;
    align-self: flex-start !important;
    order: -1 !important;
    margin: 0 0 10px 0 !important;
    top: auto !important;
    right: auto !important;
}

.history-item .history-info .d-flex p.history-prompt,
.history-item .history-info .d-flex p.card-text,
.history-info .d-flex .history-prompt,
.history-info .d-flex .card-text {
    width: 100% !important;
    order: 0 !important;
    margin: 6px 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.history-item .history-info,
.history-info {
    position: relative !important;
    padding: 15px !important;
    display: flex !important;
    flex-direction: column !important;
}

.history-type-badge,
.history-type-badge.clickable-type {
    display: inline-block;
    background: #e0f3ff;
    color: #007bff;
    border-radius: 16px;
    padding: 4px 14px;
    font-size: 0.95em;
    font-weight: 500;
    text-decoration: none !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    margin-left: 10px;
    margin-right: 0;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border: none;
}

.history-type-badge.clickable-type:hover,
.history-type-badge.clickable-type.active-type {
    background: #007bff !important;
    color: #fff !important;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(0,123,255,0.18);
}

/* 最终强制修复 - 最高优先级 */
div.history-item div.card-body > div.history-actions {
    display: flex !important;
    position: relative !important;
    margin: 0 !important;
    padding: 10px 15px !important;
    width: 100% !important;
    order: 999 !important;
    background-color: #fff !important;
    border-top: 1px solid #f0f0f0 !important;
    flex-shrink: 0 !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px !important;
    box-sizing: border-box !important;
    flex-direction: row !important;
}

/* 确保所有可能影响的WordPress默认样式被覆盖 */
.history-item .history-actions,
.history-item div[class*="actions"] {
    font-size: inherit !important;
    color: inherit !important;
    line-height: normal !important;
    visibility: visible !important;
    float: none !important;
    clear: none !important;
}

/* 类型标签的点击悬停效果 */
.history-type-badge.clickable-type:hover,
.history-item .history-info .d-flex .history-type-badge.clickable-type:hover {
    cursor: pointer !important;
    transform: scale(1.05) !important;
    transition: all 0.2s ease !important;
    opacity: 0.9 !important;
}

/* 新增：类型标签选中状态样式 */
.history-type-badge.badge-selected {
    background-color: #007bff !important;
    color: white !important;
    border: 2px solid #0056b3 !important;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.4) !important;
    transform: scale(1.08) !important;
    font-weight: 600 !important;
    position: relative !important;
}

.history-type-badge.badge-selected::after {
    content: "✓" !important;
    margin-left: 5px !important;
    font-weight: bold !important;
    font-size: 0.9em !important;
}

.history-type-badge.badge-selected:hover {
    background-color: #0056b3 !important;
    transform: scale(1.05) !important;
    box-shadow: 0 3px 12px rgba(0, 123, 255, 0.5) !important;
}

.history-duration {
    margin-right: 10px;
    font-size: 0.8rem;
    color: #6c757d;
    background-color: rgba(108, 117, 125, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}