/* 历史页面样式 */
.history-page-root {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
}

.history-container {
    flex: 1;
    min-height: 0;
    height: 100%;
    width: 100%;
    background-color: #fafafa;
    margin: 0 auto;
    padding: 0px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

[data-theme="dark"] .history-container {
    background-color: #161616;
}

.history-content-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}


.history-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-shrink: 0;
    padding: 30px 30px 10px;
}

/* 可滚动的内容区域 */
.history-content {
    flex: 1;
    overflow-y: auto;
    padding: 0px 30px 20px;
    margin-bottom: 10px;
}

.history-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sort-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-label {
    color: #6b7280;
    font-size: 14px;
    margin-right: 10px;
}

[data-theme="dark"] .sort-label {
    color: #9ca3af;
}

.sort-buttons {
    display: flex;
    align-items: center;
    gap: 20px;
}

.sort-btn {
    height: 40px;
    border: 1px solid #E5E7EB;
    border-radius: 4px;
    background-color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 10px 30px;
}

.sort-btn:hover {
    border-color: #D1D5DB;
    background-color: #F9FAFB;
}

.sort-btn.active {
    border-color: #3B82F6;
    background-color: #EFF6FF;
}

.sort-btn img {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

.sort-btn.active img {
    opacity: 1;
}

[data-theme="dark"] .sort-btn {
    background-color: #212121;
    border-color: #404040;
}

[data-theme="dark"] .sort-btn:hover {
    border-color: #525252;
    background-color: #262626;
}

[data-theme="dark"] .sort-btn.active {
    border-color: #3B82F6;
    background-color: #1E3A8A;
}

/* 图片网格布局 - 固定宽度，自动换行 */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    width: 100%;
    align-content: start;
    justify-content: flex-start;
}

/* 图片卡片样式 - 与首页内容卡片样式保持一致 */
.history-card {
    width: 100%;
    min-width: unset;
    min-height: auto;
    background-color: #fff;
    border-radius: 10px;
    padding: 10px 10px 20px;
    box-sizing: border-box;
    position: relative;
    border: 1px solid #F2F2F2;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .history-card {
    background: #212121;
    border: 1px solid #212121;
}

.history-card-image {
    width: 100%;
    height: 128px;
    background-color: #f6f6f6;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #999;
    font-size: 14px;
    flex-shrink: 0;
    margin-bottom: 20px;
}

[data-theme="dark"] .history-card-image {
    background-color: #404040;
}

.history-card-image img {
    /* width: 100%; */
    height: -webkit-fill-available;
    border-radius: 4px;
}

.history-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.history-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    gap: 8px;
}

.history-delete-btn,
.history-edit-btn {
    width: 72px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: PingFangSC-Regular;
    font-size: 14px;
    letter-spacing: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    align-self: flex-end;
    border: 1px solid #E6E6E6;
    color: #666666;
    background: #FFFFFF;
}

.history-delete-btn:hover,
.history-edit-btn:hover {
    transform: scale(1.05);
}

[data-theme="dark"] .history-delete-btn,
[data-theme="dark"] .history-edit-btn {
    color: #fff;
    background-color: #333333;
    border: none;
}

/* 加载和状态样式 */
.history-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    backdrop-filter: blur(2px);
}

[data-theme="dark"] .history-loading {
    background-color: rgba(22, 22, 22, 0.8);
}

.history-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

[data-theme="dark"] .history-loading-spinner {
    border: 4px solid #404040;
    border-top: 4px solid #60a5fa;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 空状态容器 */
#historyEmptyState {
    margin-top: 24px;
}

/* 错误提示样式 */
.history-error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

[data-theme="dark"] .history-error {
    background-color: #292929;
    border-color: #404040;
    color: #ff6b6b;
}

/* ========== 响应式样式（按断点从大到小排列） ========== */

/* 1200px 及以下 */
@media (max-width: 1200px) {
    .history-header {
        padding: 25px 25px 10px;
    }

    .history-content {
        padding: 0px 25px 25px;
    }

    .history-grid {
        gap: 16px;
    }
}

/* 1050px 及以下 */
@media (max-width: 1050px) {
    .history-header {
        padding: 20px 20px 10px;
    }

    .history-content {
        padding: 0px 20px 20px;
    }

    .history-grid {
        gap: 15px;
    }
}

/* 900px 及以下 */
@media (max-width: 900px) {
    .history-header {
        padding: 18px 18px 10px;
    }

    .history-content {
        padding: 0px 18px 18px;
    }

    .history-grid {
        gap: 14px;
    }
}

/* 800px 及以下 */
@media (max-width: 800px) {
    .history-header {
        padding: 16px 16px 10px;
    }

    .history-content {
        padding: 0px 16px 16px;
    }

    .history-grid {
        gap: 12px;
    }

    .history-delete-btn,
    .history-edit-btn {
        width: 72px;
        height: 28px;
        font-size: 13px;
    }
}

/* 768px 及以下 */
@media (max-width: 768px) {
    .history-header {
        padding: 15px 15px 10px;
    }

    .history-content {
        padding: 0px 15px 15px;
    }

    .history-grid {
        gap: 10px;
    }

    .history-card {
        padding: 10px 10px 16px;
    }

    .history-card-image {
        margin-bottom: 12px;
    }

    .history-delete-btn,
    .history-edit-btn {
        width: 72px;
        height: 28px;
        font-size: 12px;
    }
}

/* 加载状态提示样式 */
#historyLoadingTip {
    text-align: center;
    padding: 20px;
    color: #c5c5c5;
    font-size: 14px;
}

#historyNoMoreTip {
    text-align: center;
    padding: 15px;
    color: #c5c5c5;
    font-size: 12px;
}

/* 深色主题下的加载状态样式 */
[data-theme="dark"] #historyLoadingTip {
    color: #666;
}

[data-theme="dark"] #historyNoMoreTip {
    color: #666;
}

/* 历史「改图」详情弹窗 */
.history-detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

.history-detail-modal {
    position: relative;
    width: min(1040px, calc(100vw - 48px));
    height: min(720px, calc(100vh - 48px));
    max-height: calc(100vh - 48px);
    background: #eeeeee;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 头部与用户设置弹窗共用 .user-setting-modal-header（见 userSettingModal.css） */

.history-detail-body {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
    min-height: 0;
    flex: 1 1 auto;
}

.history-detail-sidebar {
    flex: 0 0 clamp(280px, 32%, 380px);
    width: clamp(280px, 32%, 380px);
    max-width: 380px;
    min-width: 260px;
    background: #fff;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e5e7eb;
}

.history-detail-fields-card {
    background: #f3f4f6;
    border-radius: 8px;
    padding: 12px 14px;
    min-height: 48px;
}

.history-detail-sidebar-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 16px 16px;
    min-height: 0;
}

.history-detail-sidebar-footer {
    padding: 16px 20px 20px;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
    background: #fff;
}

.history-detail-main {
    flex: 1 1 58%;
    min-width: 0;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    padding: 20px 24px 24px;
}

.history-detail-image-wrap {
    flex: 1 1 auto;
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

.history-detail-main-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.history-detail-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    flex-shrink: 0;
}

.history-detail-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.history-detail-field {
    font-size: 13px;
}

/* 标签与值同一行（工具名称、出图尺寸等） */
.history-detail-field.history-detail-field--inline {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    /* gap: 12px; */
}

.history-detail-field.history-detail-field--inline .history-detail-label {
    flex-shrink: 0;
    margin-bottom: 0;
}

.history-detail-field.history-detail-field--inline .history-detail-value {
    text-align: right;
    min-width: 0;
}

.history-detail-label {
    color: #4b5563;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
}

.history-detail-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.history-detail-value {
    color: #111827;
    line-height: 1.45;
    word-break: break-word;
    font-size: 12px;
    font-weight: 400;
}

.history-detail-dim {
    color: #9ca3af;
    margin-left: 4px;
    font-size: 12px;
}

.history-detail-prompt {
    color: #111827;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
    font-weight: 400;
}

.history-detail-prompt.muted {
    color: #6b7280;
    font-size: 12px;
}




    /* 参数信息弹窗内创意描述/负面提示：仅本页样式，对齐生成页 .prompt-textarea（design.css） */
    .history-detail-prompt {
        color: #111827;
        line-height: 1.5;
        white-space: pre-wrap;
        word-break: break-word;
        font-size: 12px;
        font-weight: 400;
        background: #fff;
        border: 1px solid #e6e6e6;
        border-radius: 4px;
        padding: 12px 16px;
        box-sizing: border-box;
    }

    .history-detail-prompt.muted {
        color: #6b7280;
        font-size: 12px;
        background: #fff;
        border: 1px solid #e6e6e6;
    }

    [data-theme="dark"] .history-detail-prompt {
        color: #fff;
        background: #232324;
        border: 1px solid #333;
    }

    [data-theme="dark"] .history-detail-prompt.muted {
        color: #9ca3af;
    }





.history-detail-copy {
    border: none;
    background: none;
    color: #2563eb;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}

.history-detail-copy:hover {
    text-decoration: underline;
}

.history-detail-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.history-detail-thumbs.style {
    align-items: flex-start;
}

.history-detail-thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
}

.history-detail-style-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.history-detail-weight {
    font-size: 11px;
    color: #6b7280;
}

.history-detail-loading,
.history-detail-error,
.history-detail-empty {
    font-size: 13px;
    color: #6b7280;
    padding: 8px 0;
}

.history-detail-error {
    color: #dc2626;
}

.history-detail-btn {
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
}

.history-detail-btn.primary {
    background: #374151;
    color: #fff;
    border-color: #374151;
}

.history-detail-btn.primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.history-detail-btn.secondary:hover {
    background: #f9fafb;
}

.history-detail-btn.full {
    width: 100%;
}

[data-theme="dark"] .history-detail-fields-card {
    background: #374151;
}

[data-theme="dark"] .history-detail-modal {
    background: #1f2937;
}

[data-theme="dark"] .history-detail-sidebar,
[data-theme="dark"] .history-detail-sidebar-footer {
    background: #111827;
    border-color: #374151;
}

[data-theme="dark"] .history-detail-label {
    color: #d1d5db;
}

[data-theme="dark"] .history-detail-value {
    color: #f3f4f6;
}

[data-theme="dark"] .history-detail-main {
    background: #0f172a;
}

[data-theme="dark"] .history-detail-image-wrap {
    background: #111827;
    border-color: #374151;
}

[data-theme="dark"] .history-detail-btn.secondary {
    background: #1f2937;
    color: #e5e7eb;
    border-color: #374151;
}

@media (max-width: 640px) {
    .history-detail-modal {
        width: calc(100vw - 24px);
        height: min(92vh, calc(100vh - 24px));
    }

    .history-detail-body {
        flex-direction: column;
        flex-wrap: nowrap;
    }

    .history-detail-sidebar {
        flex: 0 0 auto;
        width: 100%;
        max-width: none;
        min-width: 0;
        max-height: 44vh;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .history-detail-main {
        flex: 1 1 auto;
        min-height: 200px;
    }

    .history-detail-main-img {
        max-height: 42vh;
    }
}

[data-theme="dark"] .user-setting-modal-header{
    background-color: #111827 !important;
}

[data-theme="dark"] .history-detail-weight {
    font-size: 11px;
    color: #fff;
}