/* ============================================================
   sidebar.css — 历史侧边栏新拟态设计
   ============================================================ */

#history-sidebar,
#operation-history-sidebar {
    position: fixed;
    top: 58px;
    left: 16px;
    width: 340px;
    height: calc(100vh - 90px);
    max-height: calc(100vh - 90px);
    background: var(--sidebar-bg);
    backdrop-filter: var(--sidebar-filter);
    border: var(--sidebar-border);
    border-radius: var(--sidebar-radius);
    box-shadow: var(--sidebar-shadow);
    z-index: 1200;
    transform: translateX(calc(-100% - 32px)) scale(0.96);
    opacity: 0;
    transition: 
        transform 0.32s var(--ease-out), 
        opacity 0.24s ease,
        box-shadow var(--duration-normal) var(--ease-out);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#history-sidebar.show,
#operation-history-sidebar.show {
    transform: translateX(0) scale(1);
    opacity: 1;
}

.sidebar-header {
    padding: 16px 18px 14px;
    border-bottom: var(--sidebar-header-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: var(--sidebar-header-bg);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 650;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-close {
    width: 28px;
    height: 28px;
    background: var(--sidebar-control-bg);
    border: var(--sidebar-control-border);
    border-radius: var(--sidebar-control-radius);
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--duration-normal) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-close:hover {
    color: var(--text);
    background: var(--sidebar-control-bg);
    border: var(--sidebar-control-border);
    box-shadow: var(--sidebar-control-shadow);
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 2px 14px 14px;
    border-top: 12px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-list::-webkit-scrollbar {
    width: 4px;
}

.sidebar-list::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 4px;
}

.sidebar-list::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* 历史标签切换 */
.history-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 12px 14px 0;
    flex-shrink: 0;
}

.history-tab {
    border: var(--sidebar-control-border);
    background: var(--sidebar-control-bg);
    color: var(--text-soft);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    box-shadow: var(--sidebar-control-shadow);
}

.history-tab:hover {
    border-color: var(--line-strong);
    color: var(--text);
    background: var(--surface);
}

.history-tab.active {
    color: white;
    border-color: var(--accent);
    background: linear-gradient(145deg, var(--accent), var(--accent-hover));
    box-shadow: 
        0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* 范围提示 */
.history-scope-note {
    margin: 10px 14px 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
    color: var(--accent);
    font-size: 11px;
    line-height: 1.5;
    flex-shrink: 0;
    box-shadow: var(--neu-inset);
}

/* 工具栏 */
.history-toolbar {
    margin: 10px 14px 0;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: var(--sidebar-control-border);
    background: var(--sidebar-control-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    box-shadow: var(--neu-inset);
    /* 底部分隔阴影，滚动时视觉上不会贴在一起 */
    position: relative;
    z-index: 1;
}

.history-toolbar-info {
    min-width: 0;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-clear-btn {
    flex: 0 0 auto;
    height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(239, 68, 68, 0.25);
    background: linear-gradient(145deg, rgba(254, 242, 242, 0.9), rgba(254, 226, 226, 0.8));
    color: var(--danger);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    box-shadow: 
        2px 2px 6px rgba(239, 68, 68, 0.1),
        -2px -2px 6px rgba(255, 255, 255, 0.8);
}

.history-clear-btn:hover:not(:disabled) {
    background: linear-gradient(145deg, #fee2e2, #fecaca);
    border-color: rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
    box-shadow: 
        3px 3px 8px rgba(239, 68, 68, 0.15),
        -3px -3px 8px rgba(255, 255, 255, 0.9);
}

.history-clear-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.history-clear-btn .svg-icon {
    width: 13px;
    height: 13px;
}

.history-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.history-clean-btn {
    flex: 0 0 auto;
    height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(180, 180, 190, 0.3);
    background: linear-gradient(145deg, rgba(248, 250, 252, 0.9), rgba(241, 245, 249, 0.8));
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    box-shadow:
        2px 2px 6px rgba(0, 0, 0, 0.04),
        -2px -2px 6px rgba(255, 255, 255, 0.8);
}

.history-clean-btn:hover:not(:disabled) {
    background: linear-gradient(145deg, #f1f5f9, #e2e8f0);
    border-color: rgba(148, 163, 184, 0.4);
    color: var(--text);
    transform: translateY(-1px);
    box-shadow:
        3px 3px 8px rgba(0, 0, 0, 0.06),
        -3px -3px 8px rgba(255, 255, 255, 0.9);
}

.history-clean-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.history-clean-btn .svg-icon {
    width: 13px;
    height: 13px;
}

/* 空状态 */
.history-empty {
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
    margin-top: 20px;
    padding: 24px 16px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    box-shadow: var(--neu-inset);
}

/* 历史卡片 */
.history-item {
    background: var(--sidebar-item-bg);
    border: var(--sidebar-item-border);
    border-radius: var(--sidebar-item-radius);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
    cursor: grab;
    box-shadow: var(--sidebar-item-shadow);
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--sidebar-item-hover-shadow);
    border-color: var(--line-strong);
}

.history-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.history-size-badge {
    font-size: 11px;
    font-weight: 550;
    color: var(--text-muted);
    background: var(--surface-muted);
    border: 1px solid var(--line-soft);
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.history-batch-drag-handle[draggable="true"] {
    cursor: grab;
    border-radius: var(--radius-sm);
    padding: 2px 4px;
    margin: -2px -4px;
    transition: background var(--duration-fast) var(--ease-out);
}

.history-batch-drag-handle[draggable="true"]:hover {
    background: var(--accent-soft);
}

.history-batch-drag-handle[draggable="true"]:active {
    cursor: grabbing;
}

.history-thumb-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: var(--thumb-ratio, 16/9);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-muted);
    border: 1px solid rgba(203, 213, 225, 0.35);
    box-shadow: var(--neu-inset);
}

.history-thumb {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0;
    background: var(--surface-muted);
    cursor: grab;
    border: none;
    display: block;
}

.history-thumb:active {
    cursor: grabbing;
}

.history-broken-label {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px;
    box-sizing: border-box;
    color: var(--text-muted);
    background: repeating-linear-gradient(
        45deg, 
        rgba(226,232,240,0.5), 
        rgba(226,232,240,0.5) 8px, 
        rgba(248,250,252,0.7) 8px, 
        rgba(248,250,252,0.7) 16px
    );
    font-size: 12px;
    line-height: 1.45;
}

.history-item-broken .history-thumb {
    display: none;
}

.history-item-broken .history-broken-label {
    display: flex;
}

.history-thumb-failed {
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-linear-gradient(
        45deg,
        rgba(239, 68, 68, 0.06),
        rgba(239, 68, 68, 0.06) 8px,
        rgba(248, 250, 252, 0.7) 8px,
        rgba(248, 250, 252, 0.7) 16px
    );
    border-color: var(--danger, #ef4444);
}

.history-failed-label {
    text-align: center;
    padding: 12px;
    color: var(--danger, #ef4444);
    font-size: 12px;
    line-height: 1.5;
}

.history-failed-label small {
    color: var(--text-muted);
    font-size: 10px;
    display: block;
    margin-top: 4px;
    max-height: 2.8em;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 批次网格 */
.history-batch-grid {
    display: grid;
    grid-template-columns: repeat(var(--batch-cols, 2), 1fr);
    gap: 4px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.history-batch-cell {
    position: relative;
    aspect-ratio: var(--cell-ratio, 1);
    overflow: hidden;
    background: var(--surface-muted);
    border-radius: 4px;
    cursor: grab;
}

.history-batch-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.history-batch-cell-broken {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-muted);
    background: repeating-linear-gradient(45deg, rgba(226,232,240,0.5), rgba(226,232,240,0.5) 6px, rgba(248,250,252,0.7) 6px, rgba(248,250,252,0.7) 12px);
}

.history-batch-cell.cell-broken img {
    display: none;
}

.history-batch-cell.cell-broken .history-batch-cell-broken {
    display: flex;
}

.history-batch-count {
    margin-left: 5px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    background: var(--surface-soft);
    border: 1px solid rgba(203, 213, 225, 0.35);
    border-radius: 999px;
    padding: 1px 6px;
}

@keyframes historyPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.history-batch-cell-time {
    position: absolute;
    bottom: 3px;
    right: 3px;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.6);
    color: #fff;
    font-size: 9px;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    pointer-events: none;
    line-height: 1.4;
}

.history-desc {
    font-size: 12px;
    color: var(--text-soft);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

.history-model-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.history-model {
    font-size: 11px;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    box-sizing: border-box;
    font-weight: 550;
}

.history-temp-badge {
    color: #b45309;
    background: linear-gradient(145deg, #fef3c7, #fde68a);
    border: 1px solid rgba(251, 191, 36, 0.4);
    border-radius: 999px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.history-source {
    color: var(--text-muted);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    border-top: 1px solid rgba(203, 213, 225, 0.25);
    padding-top: 8px;
    margin-top: 4px;
}

.hist-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.hist-btn:hover {
    background: var(--surface-soft);
    border-color: rgba(203, 213, 225, 0.35);
    color: var(--text);
    box-shadow: var(--neu-inset);
}

.hist-btn.delete:hover {
    background: rgba(254, 242, 242, 0.8);
    border-color: rgba(239, 68, 68, 0.25);
    color: var(--danger);
}

/* === 非 Dock / 非右上状态栏：侧边栏取消底部阴影与发光 === */
#history-sidebar,
#operation-history-sidebar,
.sidebar-close:hover,
.history-tab,
.history-tab.active,
.history-scope-note,
.history-toolbar,
.history-clear-btn,
.history-clear-btn:hover:not(:disabled),
.history-empty,
.history-item,
.history-item:hover,
.history-thumb-wrap,
.hist-btn:hover {
    box-shadow: none !important;
}


/* === 操作历史记录侧边栏 === */
.operation-history-toolbar {
    align-items: flex-start;
    flex-direction: column;
}

.operation-history-toolbar-actions {
    display: flex;
    gap: 6px;
    width: 100%;
}

.operation-history-small-btn {
    flex: 1;
    height: 28px;
    border-radius: 999px;
    border: 1px solid rgba(203, 213, 225, 0.45);
    background: var(--surface-soft);
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
}

.operation-history-small-btn:hover:not(:disabled) {
    background: var(--surface);
    color: var(--text);
    border-color: var(--line-strong);
}

.operation-history-small-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.operation-history-small-btn.danger {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.25);
}

.operation-history-list {
    gap: 8px;
}

.operation-history-item {
    width: 100%;
    border: 1px solid rgba(203, 213, 225, 0.45);
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 10px 11px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    color: var(--text);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
}

.operation-history-item:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    background: var(--surface-soft);
}

.operation-history-item.active {
    border-color: color-mix(in srgb, var(--accent) 55%, transparent);
    background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.operation-history-index {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    background: var(--surface-soft);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 800;
    border: 1px solid rgba(203, 213, 225, 0.35);
}

.operation-history-item.active .operation-history-index {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.operation-history-main {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.operation-history-title {
    font-size: 13px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.operation-history-meta {
    color: var(--text-muted);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.operation-history-current {
    flex: 0 0 auto;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 10px;
    font-weight: 800;
}

#operation-history-sidebar,
.operation-history-small-btn:hover:not(:disabled),
.operation-history-item,
.operation-history-item:hover {
    box-shadow: none !important;
}
