* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* 容器布局 */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
    border-bottom: 2px solid var(--border-color);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* 主内容布局 */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    flex: 1;
    margin-bottom: 30px;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* 侧边栏 */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 部分容器 */
.upload-section,
.options-section,
.actions-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.upload-section h3,
.options-section h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 上传提示 */
.upload-tips {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.upload-tips h3 {
    margin-bottom: 10px;
    font-size: 1rem;
}

.upload-tips p {
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.upload-tips ul {
    list-style: none;
    padding-left: 0;
}

.upload-tips li {
    padding: 4px 0;
    font-size: 0.9rem;
}

kbd {
    background: var(--text-primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: bold;
}

/* 拖拽区域 */
.drop-zone {
    border: 2px dashed var(--primary-color);
    border-radius: 8px;
    padding: 30px 20px;
    text-align: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(139, 92, 246, 0.05));
    cursor: pointer;
    transition: all 0.3s ease;
}

.drop-zone:hover {
    border-color: var(--secondary-color);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
}

.drop-zone.drag-over {
    border-color: var(--success-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(139, 92, 246, 0.1));
}

.drop-zone p {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
}

.drop-zone .small-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
    font-weight: normal;
}

/* 选项组 */
.option-group {
    margin-bottom: 15px;
}

.option-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.95rem;
}

.option-group input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-group label {
    display: flex;
    align-items: center;
    margin-bottom: 0;
}

.radio-group input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

/* 输入框和滑块 */
.slider,
.input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.3s ease;
}

.slider {
    padding: 5px 12px;
}

.slider:focus,
.input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#gapValue {
    display: inline-block;
    margin-left: 8px;
    background: var(--bg-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    color: var(--primary-color);
}

/* 按钮 */
.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-danger {
    background: var(--bg-color);
    color: var(--danger-color);
    border: 2px solid var(--danger-color);
}

.btn-danger:hover {
    background: var(--danger-color);
    color: white;
}

.actions-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* 预览部分 */
.preview-section {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 20px;
}

.image-list-container,
.result-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.image-list-container h3,
.result-container h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 图片列表 */
.image-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 150px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.image-list::-webkit-scrollbar {
    width: 6px;
}

.image-list::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 10px;
}

.image-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.image-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.image-item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: grab;
    transition: all 0.2s ease;
}

.image-item:active {
    cursor: grabbing;
    opacity: 0.7;
}

.image-item:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.image-item.sortable-ghost {
    opacity: 0.5;
    background: var(--primary-color);
}

.image-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.image-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.image-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    word-break: break-all;
}

.image-size {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.image-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-small:hover {
    opacity: 0.8;
}

.empty-state {
    color: var(--text-secondary);
    text-align: center;
    padding: 40px 20px;
    font-style: italic;
}

/* 结果区域 */
.result-area {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 20px;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: auto;
    max-height: 600px;
}

.result-area img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

/* 进度条 */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.3s ease;
}

.progress-bar.hidden {
    display: none;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* 加载动画 */
.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ============================================
   灯箱效果（Lightbox）
   ============================================ */

/* 灯箱背景 */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.lightbox-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 灯箱容器 */
.lightbox-container {
    position: relative;
    width: 90vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 灯箱图片 */
.lightbox-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    cursor: grab;
    transition: transform 0.2s ease;
    user-select: none;
}

.lightbox-image:active {
    cursor: grabbing;
}

/* 关闭按钮 */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.lightbox-close:active {
    transform: scale(0.95);
}

/* 导航按钮 */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

/* 工具栏 */
.lightbox-toolbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    max-width: 90vw;
    z-index: 10001;
    backdrop-filter: blur(10px);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 工具栏按钮 */
.lightbox-btn {
    background: rgba(59, 130, 246, 0.8);
    border: 1px solid rgba(59, 130, 246, 1);
    color: white;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.lightbox-btn:hover {
    background: rgba(59, 130, 246, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.lightbox-btn:active {
    transform: translateY(0);
}

/* 信息显示 */
.lightbox-info {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

/* 提示文本 */
.lightbox-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 5px;
    font-weight: normal;
    opacity: 0.7;
}

/* ============================================
   响应式设计
   ============================================ */

@media (max-width: 768px) {
    .lightbox-container {
        width: 95vw;
        height: 95vh;
    }

    .lightbox-image {
        max-height: 60vh;
    }

    .lightbox-close {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
        top: 10px;
        right: 10px;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-toolbar {
        bottom: 10px;
        padding: 10px 15px;
        gap: 5px;
    }

    .lightbox-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .lightbox-info {
        display: none;  /* 手机上隐藏信息 */
    }
}

/* 响应式设计 */

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .image-list {
        max-height: 250px;
    }

    .result-area {
        min-height: 250px;
        max-height: 400px;
    }
}
