/* 基础布局与全局样式 */
body { margin: 0; padding: 0; }
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 52px;
    background: #1976d2;
    color: #fff;
    font-size: 22px;
    font-weight: bold;
    display: flex;
    align-items: center;
    padding-left: 32px;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,0.07);
}
.header__nav-btn {
    position: absolute;
    right: 32px;
    top: 10px;
    background: #fff;
    color: #1976d2;
    border: 1.5px solid #1976d2;
    border-radius: 5px;
    font-size: 15px;
    font-weight: bold;
    padding: 6px 18px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
}
.header__nav-btn:hover {
    background: #1976d2;
    color: #fff;
}
.main-flex {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    width: 100%;
}
.sidebar {
    min-width: 260px;
    max-width: 320px;
    width: 280px;
    padding: 0;
    border-right: 1px solid #eee;
    background: #fafbfc;
    position: fixed;
    left: 0;
    top: 52px;
    height: calc(100vh - 52px);
    overflow-y: hidden;
    z-index: 10;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    flex-shrink: 0;
    padding: 18px 10px 0 10px;
    background: #fafbfc;
    position: sticky;
    top: 0;
    z-index: 30;
}

.sidebar-content {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0 10px;
}

.sidebar-info-section {
    flex-shrink: 0;
    padding: 10px 10px 0 10px;
    background: #fafbfc;
    border-top: 1px solid #e0e0e0;
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* 分隔条样式 */
.sidebar-resizer {
    flex-shrink: 0;
    height: 8px;
    background: #e0e0e0;
    cursor: ns-resize;
    position: relative;
    border-top: 1px solid #d0d0d0;
    border-bottom: 1px solid #d0d0d0;
    transition: background 0.2s;
}

.sidebar-resizer:hover {
    background: #1976d2;
}

.sidebar-resizer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 3px;
    background: #999;
    border-radius: 2px;
}

.sidebar-resizer:hover::before {
    background: #fff;
}

.sidebar-info-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.sidebar-info-section-header .sidebar-title {
    margin-bottom: 0;
    flex: 1;
}

.info-text-selector {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
    color: #333;
    cursor: pointer;
    outline: none;
    transition: border 0.2s;
    min-width: 80px;
}

.info-text-selector:focus {
    border: 1px solid #1976d2;
}

.sidebar-info-section-content {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 60px;
}

.sidebar-controls {
    flex-shrink: 0;
    padding-top: 16px;
    padding-bottom: 10px;
    padding-left: 10px;        /* 添加：左内边距 */
    padding-right: 10px;       /* 添加：右内边距 */
    background: #fafbfc;
    border-top: 1px solid #e0e0e0;
    position: sticky;
    bottom: 0;
    z-index: 20;
}
.sidebar-controls-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 8px;
}
.sidebar-controls-row > * {
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
}
.sidebar-controls-row button,
.sidebar-controls-row select {
    min-width: auto;
    width: 100%;
    padding: 6px 8px;          /* 修改：减小左右内边距 */
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-controls .btn,
.sidebar-controls select {
    margin: 0;
    width: 100%;
    padding-left: 10px;        /* 添加：左右内边距 */
    padding-right: 10px;       /* 添加：左右内边距 */
}

/* 信息显示框样式 */
.sidebar-info-box {
    margin-top: 0;
    margin-bottom: 12px;
    padding: 12px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    font-size: 13px;
    line-height: 1.6;
    color: #333;
    word-wrap: break-word;
}

.sidebar-info-box h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: bold;
    color: #1976d2;
}

.sidebar-info-box p {
    margin: 0;
    white-space: pre-wrap;
}

.sidebar-info-box:empty {
    display: none;
}

/* 隐藏侧边栏控制区域中的颜色选择器 */
.sidebar-controls select[id*="color"],
.sidebar-controls .rect-color-select {
    display: none;
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-left: 280px;
    margin-top: 52px;
    height: calc(100vh - 52px);
    overflow: auto;
    box-sizing: border-box;
}
.content-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 18px;
}
.draw-area {
    position: relative;
    display: block;
    margin-top: 40px;
    flex: 1 1 auto;
}
.compare-pane {
    position: relative;
    margin-top: 40px;
    flex: 0 0 36%;
    max-width: 36%;
    border-left: 1px solid #e0e0e0;
    padding-left: 12px;
}
.compare-pane-title {
    font-size: 15px;
    font-weight: bold;
    color: #1976d2;
    margin-bottom: 8px;
}
.compare-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e0e0e0;
}
.form-group {
    margin-bottom: 18px;
    padding: 10px;
    border-radius: 5px;
    border: 2px solid transparent;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.form-group.active {
    border-color: #ffd700;
    background: #fffbea;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}
label {
    display: block;
    margin-bottom: 5px;
    font-size: 15px;
    font-weight: bold;
}
input[type="text"] {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 13px;
    box-sizing: border-box;
    margin-top: 4px;
    margin-bottom: 2px;
}
input[type="file"] {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 12px;
    font-size: 15px;
    border-radius: 5px;
    border: 1px solid #1976d2;
    background: #fff;
    color: #222;
    margin-bottom: 8px;
    outline: none;
}
input[type="file"]:focus {
    border: 2px solid #1251a3;
}
.btn, button {
    display: inline-block;
    padding: 8px 20px;
    font-size: 16px;
    border-radius: 5px;
    border: none;
    background: #1976d2;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
}
.btn.btn-primary, button.btn-primary {
    background: #1976d2;
}
.btn:hover, button:hover {
    background: #1251a3;
}
.btn--cancel {
    min-width: 140px;
    font-size: 16px;
    padding: 12px 24px;
    border-radius: 8px;
    background: #e53935;
    color: #fff;
    margin-right: 8px;
    border: none;
    box-shadow: 0 2px 8px rgba(229,57,53,0.07);
    transition: background 0.2s;
}
.btn--cancel:hover {
    background: #b71c1c;
}
select, .rect-color-select {
    padding: 7px 12px;
    font-size: 15px;
    border-radius: 5px;
    border: 1px solid #1976d2;
    background: #fff;
    color: #222;
    margin-bottom: 4px;
    margin-right: 8px;
    outline: none;
    transition: border 0.2s;
}
select:focus, .rect-color-select:focus {
    border: 2px solid #1251a3;
}
.rect-box {
    position: absolute;
    border: 2px solid;
    box-sizing: border-box;
    background: rgba(255,0,0,0.2);
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}
.rect-label-outer {
    position: absolute;
    left: 0;
    top: -22px;
    font-size: 13px;
    color: #222;
    background: #7fffd4;
    border-radius: 2px;
    padding: 0 5px;
    z-index: 3;
    opacity: 0.92;
    font-weight: bold;
    pointer-events: none;
}
.rect-box.selected {
    box-shadow: 0 0 0 4px #ffd700, 0 0 20px rgba(255, 215, 0, 0.6);
    border-color: #ffd700 !important;
    border-width: 3px !important;
    z-index: 10;
    transform: scale(1.02);
}
.form-group button {
    padding: 6px 14px;
    font-size: 14px;
    border-radius: 4px;
    border: none;
    background: #e53935;
    color: #fff;
    cursor: pointer;
    margin-left: 8px;
    transition: background 0.2s;
}
.form-group button:hover {
    background: #b71c1c;
}
.form-group input[type="text"] {
    width: auto;
    margin-top: 0;
    margin-bottom: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.form-group .rect-color-select {
    background: transparent;  /* 改为透明 */
    border: 1px solid #ccc;
    color: #333;
    font-size: 11px;
    margin-bottom: 0;
    margin-right: 0;
    padding: 2px 4px;
    min-width: 100px;
}

/* 修改：为不同类型的选项添加背景色 */
.form-group .rect-color-select option[value="#7fffd4"] {
    background-color: rgba(127, 255, 212, 0.3);
    color: #222;
}

.form-group .rect-color-select option[value="#060ac9"] {
    background-color: rgba(6, 10, 201, 0.2);
    color: #fff;
}

.form-group .rect-color-select option[value="#ff0000"] {
    background-color: rgba(255, 0, 0, 0.2);
    color: #222;
}

.form-group .rect-color-select option[value="#2196f3"] {
    background-color: rgba(33, 150, 243, 0.25);
    color: #222;
}

.form-group .rect-color-select option[value="#ff6b35"] {
    background-color: rgba(255, 107, 53, 0.25);
    color: #222;
}

.form-group .rect-color-select option[value="#ffffff"] {
    background-color: rgba(200, 200, 200, 0.4);
    color: #222;
}

/* upload.html 样式 */
.examples__title {
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 6px;
    color: #1976d2;
}
.examples__list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.example-item {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 60px;
    padding: 4px 0;
    cursor: pointer;
    user-select: none;
    border-radius: 5px;
    transition: background 0.15s;
}
.example-item:hover {
    background: #e3f2fd;
}
.example-item__thumb {
    width: 60px;
    height: 100%;
    object-fit: contain;
    border-radius: 5px;
    border: 2px solid #eee;
    background: #fafbfc;
    transition: border 0.2s;
    flex-shrink: 0;
    pointer-events: none;
}
.example-item__name {
    font-size: 15px;
    color: #1976d2;
    font-weight: bold;
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-selected-file {
    font-size: 16px;
    color: #1976d2;
    margin-bottom: 0;
    padding: 10px 0 8px 10px;
    font-weight: bold;
    word-break: break-all;
    border-radius: 5px;
    background: #e3f2fd;
    text-align: left;
    border: 1.5px solid #1976d2;
    letter-spacing: 0.5px;
    box-shadow: none;
    transition: background 0.2s, border 0.2s;
}
.sidebar-selected-file.empty {
    color: #888;
    background: #f5fafd;
    border: 1.5px solid #e0e0e0;
    font-weight: normal;
    opacity: 1;
}
.upload {
    position: relative;
    width: 100%;
    height: 100%;
}
.upload__drop-area {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 70vw;
    max-width: 800px;
    min-width: 320px;
    min-height: 260px;
    border: 2px dashed #1976d2;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5fafd;
    transition: background 0.2s, border 0.2s;
    z-index: 1;
    flex-direction: column;
    box-shadow: 0 2px 12px rgba(25,118,210,0.06);
    padding: 40px 24px 32px 24px;
    cursor: pointer;
}
.upload__drop-area--dragover {
    background: #e3f2fd;
    border-color: #1251a3;
}
.upload__preview {
    display: block;
    max-width: 90%;
    max-height: 60vh;
    margin: 20px auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    object-fit: contain;
    background: #fff;
}
.upload__actions {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
    padding: 20px 0;
    background: linear-gradient(to top, #fafbfc 90%, rgba(250,251,252,0.01));
    z-index: 2;
}
.content.upload-page {
    position: relative;
    padding-bottom: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 480px;
}
.sidebar-section {
    margin-bottom: 22px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}
.sidebar-title {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 12px;
    gap: 8px;
    color: #1976d2;
    border-bottom: 1.5px solid #e3e3e3;
    padding-bottom: 4px;
}
.btn--primary {
    min-width: 160px;
    font-size: 18px;
    padding: 14px 32px;
    border-radius: 8px;
    background: #1976d2;
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(25,118,210,0.15);
    transition: background 0.2s;
}
.btn--primary:hover {
    background: #1251a3;
}
.btn--next-step {
    width: 100%;
    min-width: 200px;
    font-size: 14px;           /* 修改：减小字体 */
    font-weight: bold;
    padding: 10px 20px;        /* 修改：减小内边距 */
    border-radius: 8px;
    background: #4caf50;
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(76,175,80,0.15);
    transition: background 0.2s;
    margin-top: 8px;
}
.btn--next-step:hover {
    background: #45a049;
}
.btn--next-step:disabled {
    background: #cccccc;
    cursor: not-allowed;
    box-shadow: none;
}

/* 加载模态框样式 */
.loading-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.loading-modal.show {
    opacity: 1;
}
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}
.loading-content {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    min-width: 300px;
    max-width: 500px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}
.loading-modal.show .loading-content {
    transform: translateY(0);
}
.loading-title {
    color: #1976d2;
    font-size: 20px;
    font-weight: bold;
    margin: 0 0 20px 0;
}
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e3f2fd;
    border-top: 4px solid #1976d2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.loading-text {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
    margin-top: 15px;
    white-space: pre-line;
    max-height: 200px;
    overflow-y: auto;
    text-align: left;
    background: #f9f9f9;
    padding: 10px;
    border-radius: 4px;
    font-family: monospace;
}

/* Restore页面样式 */
.restore-main {
    margin-left: 0;
    margin-top: 52px;
    height: calc(100vh - 52px - 120px);
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f9f9f9;
    overflow: auto;
}
.restore-image-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
}
.restore-main-image {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
    position: relative;
    cursor: grab;
}
.restore-main-image:active {
    cursor: grabbing;
}
.restore-comparison-view {
    display: flex;
    gap: 40px;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
}
.restore-comparison-item {
    flex: 1;
    max-width: 45%;
    text-align: center;
}
.restore-comparison-item h3 {
    color: #1976d2;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
}
.restore-comparison-image {
    max-width: 100%;
    max-height: calc(100vh - 52px - 200px);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
}
.restore-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 100;
    padding: 15px 30px;
    box-sizing: border-box;
}
.restore-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 15px;
}
.restore-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.restore-info-label {
    font-weight: bold;
    color: #666;
    font-size: 14px;
}
.restore-info-value {
    color: #333;
    font-size: 14px;
}
.restore-info-value.status-success {
    color: #4caf50;
    font-weight: bold;
}
.restore-action-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}
.btn-secondary {
    background: #1976d2;
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-secondary:hover {
    background: #1251a3;
}
.restore-image-title {
    color: #1976d2;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    text-align: center;
}

/* 备选项菜单样式 */
.alternatives-menu {
    position: fixed;
    background: #fff;
    border: 2px solid #1976d2;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    min-width: 120px;
    max-width: 250px;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px 0;
}

.alternatives-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alternatives-option:hover {
    background: #e3f2fd;
    color: #1976d2;
}

.alternatives-option:active {
    background: #bbdefb;
}

.alternatives-btn {
    flex-shrink: 0;
}
