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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: #2c3e50;
}

.upload-area {
    position: relative;  /* 添加相对定位，作为按钮的定位参考 */
    width: 100%;
    height: 200px;
    border: 2px dashed #3498db;
    border-radius: 8px;
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #2980b9;
    background-color: #f7f9fc;
}

.upload-area.drag-over {
    border-color: #2ecc71;
    background-color: #f0f9f4;
}

.file-input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-text {
    text-align: center;
}

.upload-text p {
    margin: 0;
    color: #7f8c8d;
}

.sub-text {
    font-size: 0.9em;
    margin-top: 0.5rem;
}

/* 预览区域基础样式 */
.preview-area {
    display: flex;           /* 使用flexbox布局 */
    flex-wrap: wrap;         /* 允许元素换行 */
    gap: 10px;              /* 网格间距 */
    padding: 0px;          /* 内边距 */
    min-height: 200px;      /* 最小高度 */
    align-items: flex-start; /* 从顶部开始排列 */
}

/* 垂直布局模式样式 */
.preview-area.vertical-layout {
    flex-direction: column;  /* 垂直方向排列 */
    align-items: center;     /* 水平居中 */
    gap: 0;                 /* 移除间隙（为了无缝显示） */
    padding: 0;             /* 移除内边距（为了无缝显示）*/
}

/* 垂直布局下所有元素样式（用 * 号选择所有子元素） */
.preview-area.vertical-layout * {
    line-height: 0;         /* 移除元素间的行高间隙（为了无缝显示）*/
}

/* 预览项目基础样式（后代选择器：选择 preview-area 内的所有 preview-item。注意期间有一个空格，不能省略！） */
.preview-area .preview-item {
    position: relative;       /* 使用相对定位，方便内部元素（如删除按钮）进行绝对定位 */
    display: inline-block;    /* 让元素在同一行内显示，但可以设置宽高边距 */
    margin: 5px;            /* 设置外边距，使预览项之间有一定间隔 */
    border: 2px solid #ddd;  /* 添加边框，颜色为浅灰色 */
    border-radius: 4px;      /* 设置圆角，让外观更现代化 */
    overflow: hidden;        /* 隐藏超出容器的内容，防止图片溢出 */
    width: 150px;           /* 设置预览项的固定宽度 */
    cursor: move;           /* 鼠标悬停时显示移动光标，提示可拖动 */
    user-select: none;      /* 禁止文本选中，避免拖拽时选中内容 */
    transition: transform 0.2s;  /* 添加变换动画效果，持续0.2秒，使交互更流畅 */
}

/* 垂直布局下的预览项目样式（选择 “具有 preview-area 和 vertical-layout” 的元素之中 “具有 preview-item” 的元素  。注意期间有一个空格，不能省略！） */
.preview-area.vertical-layout .preview-item {
    width: 100%;            /* 占满容器宽度 */
    touch-action: pan-y;    /* 垂直布局时允许垂直方向的滚动 */
}

/* 垂直布局下的预览项目样式（...针对没有 drag-over 状态的 preview-item 元素...） */
.preview-area.vertical-layout .preview-item:not(.drag-over) { /* */
    margin: 0;              /* 移除外边距 */
    border: none;           /* 移除边框 */
    border-radius: 0;       /* 移除圆角 */
}

/* 预览项目悬停效果 */
.preview-area .preview-item:hover {
    /* transform: scale(1.02); 悬停时轻微放大，提供交互反馈 */
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* 禁用移动端长按菜单（为了保证自己的 “长按拖动图片” 的功能正常） */
    -webkit-touch-callout: none; /* iOS Safari ，禁用 iOS 的触摸长按菜单*/
    -webkit-user-select: none; /* Safari */
    -khtml-user-select: none; /* Konqueror HTML */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
    user-select: none; /* Non-prefixed version ，禁止选择文本（包含各浏览器前缀） */
    -webkit-tap-highlight-color: transparent; /* 移除点击时的高亮效果 */
    pointer-events: auto !important; /* 确保事件处理正常 */
}

/* 按钮容器样式 */
.button-container {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    gap: 5px; /* 按钮之间的间距 */
}

.preview-item:hover .button-container {
    display: flex; /* 鼠标悬停时显示 */
}

/* 移动按钮和删除按钮的基础样式 */
.move-btn,
.remove-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    color: white;
}

/* 移动按钮特有样式 */
.move-btn {
    background-color: rgba(0, 0, 0, 0.5);
}

/* 删除按钮特有样式 */
.remove-btn {
    background-color: rgba(255, 0, 0, 0.7);
}

/* 按钮悬停效果 */
.move-btn:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.remove-btn:hover {
    background-color: rgba(255, 0, 0, 0.9);
}

.preview-item .simple-line-top {
    position: absolute;
    top: 0px;
    left: 0px;
    background: rgba(82, 82, 82, 0.411);
    color: white;
    border: none;
    width: auto;
    height: 15px;
    text-align: left;
    pointer-events: none; /*避免 "裁剪线" 阻挡图片被点击 */
    touch-action: none; /*避免 "裁剪线" 阻挡图片被点击 */
}

.preview-item .simple-line-bottom {
    position: absolute;
    bottom: 0px;
    left: 0px;
    background: rgba(82, 82, 82, 0.411);
    color: white;
    border: none;
    width: auto;
    height: 15px;
    text-align: left;
    pointer-events: none; /*避免 "裁剪线" 阻挡图片被点击 */
    touch-action: none; /*避免 "裁剪线" 阻挡图片被点击 */
}

.preview-item.dragging {
    opacity: 0.5;
    transform: scale(0.9);
}

.preview-item.drag-over {
    border: 2px dashed #4CAF50;
    transform: translateX(0);
    padding: 5px;
}

.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.btn {
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 4px;
    background-color: #3498db;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.btn:not(:disabled):hover {
    background-color: #2980b9;
}

/* 图片查看弹窗相关样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(2px);
}

.modal .modal-content {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    max-width: 1600px;
    padding: 20px;
    box-sizing: border-box;
}

#modalCanvas {
    display: block;
    margin: 0 auto;
    background-color: #1a1a1a;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.crop-info {
    margin-top: 15px;
    color: #f1f1f1;
    text-align: center;
    padding: 8px 16px;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 20px;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.close {
    position: fixed;
    right: 25px;
    top: 15px;
    color: #f1f1f1;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
}

.close:hover {
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
}

/* 进度弹窗样式 */
.progress-modal {
    background-color: rgba(0, 0, 0, 0.7);
}

.progress-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 400px;
}

.progress-container h3 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background-color: #3498db;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 1.1em;
    color: #666;
}

/* 参数调整弹窗样式 */
.parameter-modal .modal-content {
    max-width: 500px;
    width: 90%;
    max-height: 90vh; /* 最大高度为视口高度的90% */
    height: auto;
    padding: 0; /* 移除内边距，由内部元素控制 */
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column; /* 使用flex布局，便于固定底部按钮 */
    overflow: hidden; /* 防止内容溢出 */
}

.parameter-modal h3 {
    margin: 0;
    padding: 1rem;
    text-align: center;
    color: #2c3e50;
    font-size: 1.3rem;
    font-weight: 600;
    background-color: #fff;
    border-bottom: 1px solid #e9ecef;
}

.parameter-content {
    flex: 1;
    overflow-y: scroll; /* 改为scroll，始终显示滚动条 */
    padding: 1rem;
}

.parameter-content::-webkit-scrollbar {
    width: 12px; /* 滚动条宽度 */
    background-color: #f1f1f1;
}

.parameter-content::-webkit-scrollbar-thumb {
    background-color: #c1c1c1;
    border-radius: 6px;
    border: 2px solid #f1f1f1;
}

.parameter-content::-webkit-scrollbar-thumb:hover {
    background-color: #a8a8a8;
}

.parameter-content::-webkit-scrollbar-track {
    background-color: #f1f1f1;
    border-radius: 6px;
}

.parameter-item {
    margin-bottom: 1rem;
    background-color: #f8f9fa;
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.parameter-item label {
    display: block;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-weight: 600;
}

.parameter-item input[type="range"] {
    width: 100%;
    margin: 0.8rem 0;
    height: 6px;
    background-color: #e9ecef;
    border-radius: 3px;
    cursor: pointer;
}

.parameter-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.parameter-item input[type="range"]::-webkit-slider-thumb:hover {
    background: #2980b9;
}

.parameter-desc {
    font-size: 0.9rem;
    color: #495057;
    margin-top: 0.5rem;
    line-height: 1.25;
}

.parameter-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    position: sticky;
    bottom: 0;
    width: 100%;
}

.parameter-buttons .btn {
    min-width: 80px;
    padding: 0.6rem 1.2rem;
}

/* 帮助按钮样式 */
#loadImageHelpBtn {
    position: absolute;  /* 绝对定位 */
    top: 10px;          /* 距离顶部10px */
    right: 10px;        /* 距离右侧10px */
    font-size: 0.9rem;
    padding: 0.4rem 0.8rem;
    background-color: #ff4d4f;
    border-color: #ff4d4f;
    color: white;
    z-index: 1;         /* 确保按钮在其他元素上方 */
    display: none;      /*默认隐藏*/
}

#loadImageHelpBtn:hover {
    background-color: #ff7875;
    border-color: #ff7875;
}

/* 帮助弹窗样式 */
.help-modal .modal-content {
    max-width: 500px;
    padding: 30px;
    border-radius: 8px;
    background: #fff;
    position: relative;
}

.help-content {
    margin-top: 10px;
    line-height: 1.6;
    color: #333;
}

.help-content p {
    margin: 0;
    padding: 0;
    font-size: 16px;
    white-space: pre-line; /* 保留换行符 */
}

/* 对话框样式 */
.dialog-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.dialog-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    max-width: 90%;
    width: 70%;
    z-index: 1001;
}

.dialog-title {
    margin: 0 0 15px 0;
    font-size: 16px;
    text-align: center;
}

.dialog-body {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.dialog-close-btn {
    background: #2196F3;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 15px;
    width: 100%;
}

.dialog-close-btn:hover {
    background: #1976D2;
}

/* 对话框按钮容器样式 */
.dialog-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

/* 多按钮模式下的按钮样式 */
.dialog-buttons.multiple-buttons .dialog-close-btn {
    width: auto;
    min-width: 80px;
    flex: 1;
}

/* 单按钮模式保持原样 */
.dialog-buttons.single-button .dialog-close-btn {
    width: 100%;
}

/* 适配移动端 */
@media (max-width: 768px) {
    .parameter-modal .modal-content {
        padding: 1.5rem;
        width: 95%;
    }

    .parameter-item {
        margin-bottom: 1rem;
        padding: 1rem;
    }

    .parameter-desc {
        font-size: 0.85rem;
    }

    .parameter-buttons .btn {
        min-width: 80px;
    }
}

/* 标题栏样式 */
.header {
    margin: 15px 0 25px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.3;
    color: #2c3e50;
    font-weight: 600;
    word-wrap: break-word;
    hyphens: auto;
    flex: 1;
}

/* 按钮区域容器 */
.header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 130px;
    position: relative;
}

.header-btn {
    font-size: 13px;
    padding: 6px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    border-radius: 4px;
    transition: all 0.2s ease;
    min-width: 70px;
}

.header-btn:hover {
    background: #e9ecef;
    border-color: #ced4da;
}

/* 最近更新按钮特殊样式 */
.update-btn {
    background: transparent !important;
    border: none !important;
    color: #3498db !important;
    text-decoration: underline;
    font-size: 11px !important;
    padding: 4px 8px !important;
    min-width: 50px !important;
    position: absolute;
    top: -21px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.update-btn:hover {
    background: transparent !important;
    color: #2980b9 !important;
    border: none !important;
}

/* 响应式调整 */
@media (max-width: 480px) {
    .header {
        padding: 0 10px;
        gap: 8px;
    }

    .header h1 {
        font-size: 20px;
    }

    .header-btn {
        font-size: 12px;
        padding: 5px 10px;
        min-width: 60px;
    }
}

/* 图片加载错误容器样式 */
.error-container {
    padding: 15px;
    text-align: center;
    background: #fff1f0;
    border: 1px solid #ffa39e;
    border-radius: 4px;
    margin: 10px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.error-container .error-text {
    margin-bottom: 12px;
    color: #cf1322;
    font-size: 14px;
}

.error-container .retry-button {
    padding: 6px 16px;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    cursor: pointer;
    color: #000000d9;
    transition: all 0.3s;
}

.error-container .retry-button:hover {
    color: #40a9ff;
    border-color: #40a9ff;
}

.error-container .retry-button:active {
    color: #096dd9;
    border-color: #096dd9;
}

.clip-tips {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    margin: 0.5rem 0;
    font-style: italic;
}
