/* 定义基础全局变量，使用极具现代感和高级感的暗色主题配色 */
:root {
    --bg-color: #0d0f14;
    --panel-bg: #16181f;
    --canvas-bg: #1e212b;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-color: #4f46e5;
    --accent-hover: #4338ca;
    --border-color: #2b2f3a;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* 左侧栏样式 */
.sidebar {
    width: 340px;
    background-color: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    background-color: rgba(22, 24, 31, 0.95);
    backdrop-filter: blur(10px);
}

.sidebar-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.sidebar-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.icon-btn {
    position: absolute;
    right: 24px;
    top: 28px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
}

.icon-btn:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

/* 缩略图库样式 */
.gallery {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.gallery-item {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    cursor: grab;
    border: 2px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: var(--canvas-bg);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    position: relative;
}

.gallery-item:hover {
    border-color: var(--accent-color);
    transform: translateY(-4px);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.2);
}

.gallery-item img {
    width: 100%;
    height: 180px;
    display: block;
    object-fit: cover;
    pointer-events: none;
}

.gallery-item-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    padding: 30px 10px 10px;
    font-size: 0.85rem;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* 主工作区样式 */
.workspace {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(79, 70, 229, 0.05) 0%, transparent 70%),
        radial-gradient(circle at 0% 100%, rgba(239, 68, 68, 0.03) 0%, transparent 50%);
}

.workspace-header {
    height: 80px;
    padding: 0 40px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(13, 15, 20, 0.8);
    backdrop-filter: blur(12px);
    z-index: 5;
}

.workspace-header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.actions {
    display: flex;
    gap: 16px;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn.primary {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn.primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.btn.primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn.secondary {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn.secondary:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background-color: rgba(255, 255, 255, 0.05);
}

/* 画布相关样式 */
.canvas-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* 拼合主视觉面板 */
.stitch-canvas {
    width: 100%;
    max-width: 700px; /* 默认拼合预览宽度 */
    min-height: 500px;
    padding-bottom: 300px; /* 提供充足的底部拖拽放置空间 */
    background-color: transparent;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    transition: background-color 0.3s;
}

/* 空状态占位提示 */
.empty-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
    border: 2px dashed var(--border-color);
    background-color: rgba(22, 24, 31, 0.4);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.empty-state.hidden {
    opacity: 0;
    pointer-events: none;
}

.empty-icon {
    margin-bottom: 20px;
    opacity: 0.6;
    color: var(--accent-color);
}

.empty-state p {
    font-size: 1.1rem;
    font-weight: 500;
}

/* 拼合的单张图片控制状态 */
.stitching-item {
    position: relative;
    width: 100%;
    /* 处理相邻图片间隙的常规hack */
    line-height: 0;
    font-size: 0;
}

/* 给第一张和最后一张加圆角过渡，提升高级感，但在导出时是不带圆角的 */
.stitching-item:first-child img {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
.stitching-item:last-child img {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.stitching-item img {
    width: 100%;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

/* 移除按钮 */
.stitching-item .remove-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background-color: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    font-size: 14px;
}

.stitching-item:hover .remove-btn {
    opacity: 1;
    transform: scale(1);
}

.stitching-item .remove-btn:hover {
    background-color: var(--danger);
    transform: scale(1.1);
}

/* SortableJS 拖拽占位符幽灵状态 */
.sortable-ghost {
    opacity: 0.3;
    background-color: var(--accent-color);
}
.sortable-drag {
    cursor: grabbing !important;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    border-radius: 8px;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
