* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* 禁用文本选择 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* 禁用拖拽 */
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 2.5em;
}

h2 {
    color: #34495e;
    margin-bottom: 15px;
    font-size: 1.5em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

/* 单选按钮组样式 */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.radio-label:hover {
    background-color: #f8f9fa;
    border-color: #3498db;
}

.radio-label input[type="radio"] {
    margin: 0;
    user-select: auto;
}

.radio-label input[type="radio"]:checked + span {
    color: #3498db;
    font-weight: 500;
}

.radio-label:has(input[type="radio"]:checked) {
    background-color: #e3f2fd;
    border-color: #3498db;
}

/* 批量保存按钮特殊样式 */
#batchSaveBtn {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    font-weight: bold;
    animation: pulse 2s infinite;
}

#batchSaveBtn:hover {
    background: linear-gradient(45deg, #218838, #1ea085);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

/* API Key 输入框样式 */
.api-key-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 5px 0;
}

#apiKey {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-family: monospace;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

#apiKey:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

#apiKey.valid {
    border-color: #28a745;
    background-color: #f8fff9;
}

#apiKey.invalid {
    border-color: #dc3545;
    background-color: #fff8f8;
}

.toggle-btn, .test-btn {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.toggle-btn:hover {
    background: #e9ecef;
}

.test-btn {
    background: #17a2b8;
    color: white;
    border-color: #17a2b8;
}

.test-btn:hover:not(:disabled) {
    background: #138496;
    border-color: #117a8b;
}

.test-btn:disabled {
    background: #6c757d;
    border-color: #6c757d;
    cursor: not-allowed;
}

.test-btn.testing {
    background: #ffc107;
    border-color: #ffc107;
    color: #212529;
}

.test-btn.success {
    background: #28a745;
    border-color: #28a745;
}

.test-btn.error {
    background: #dc3545;
    border-color: #dc3545;
}

.api-key-hint {
    display: block;
    color: #6c757d;
    font-size: 12px;
    margin-top: 5px;
    line-height: 1.4;
}

.config-section,
.preview-section,
.control-section,
.progress-section,
.log-section {
    background: white;
    margin-bottom: 20px;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
    font-style: italic;
}

input[type="text"],
textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
    /* 允许输入框中的文本选择 */
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: #3498db;
}

button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    margin-left: 10px;
}

button:hover {
    background-color: #2980b9;
}

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

#generateBtn {
    background-color: #27ae60;
    font-size: 16px;
    padding: 15px 30px;
    margin: 0;
}

#generateBtn:hover:not(:disabled) {
    background-color: #229954;
}

#stopBtn {
    background-color: #e74c3c;
    margin-left: 10px;
}

#stopBtn:hover:not(:disabled) {
    background-color: #c0392b;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.image-item {
    position: relative;
    border: 2px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    aspect-ratio: 1;
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-item .filename {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px;
    font-size: 12px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.count-info {
    font-weight: 600;
    color: #2c3e50;
    font-size: 16px;
}

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

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

.progress-text {
    text-align: center;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 15px;
}

.download-notice {
    background-color: #e8f4fd;
    border: 1px solid #bee5eb;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
    font-size: 14px;
}

.download-notice p {
    margin: 5px 0;
    color: #0c5460;
}

.download-notice code {
    background-color: #f8f9fa;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #e83e8c;
}

.task-list {
    max-height: 300px;
    overflow-y: auto;
}

.task-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 5px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 4px solid #3498db;
}

.task-item.completed {
    border-left-color: #27ae60;
    background-color: #d5f4e6;
}

.task-item.error {
    border-left-color: #e74c3c;
    background-color: #fadbd8;
}

.task-status {
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.status-pending {
    background-color: #f39c12;
    color: white;
}

.status-processing {
    background-color: #3498db;
    color: white;
}

.status-downloading {
    background-color: #9b59b6;
    color: white;
}

.status-processing_image {
    background-color: #9b59b6;
    color: white;
}

.status-saving {
    background-color: #e67e22;
    color: white;
}

.status-manual_download {
    background-color: #f39c12;
    color: white;
}

.status-completed {
    background-color: #27ae60;
    color: white;
}

.status-error {
    background-color: #e74c3c;
    color: white;
}

.log-container {
    height: 200px;
    overflow-y: auto;
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    margin-bottom: 10px;
}

.log-entry {
    margin-bottom: 5px;
    padding: 2px 0;
}

.log-entry.info {
    color: #3498db;
}

.log-entry.success {
    color: #27ae60;
}

.log-entry.error {
    color: #e74c3c;
}

.log-entry.warning {
    color: #f39c12;
}

#clearLogBtn {
    background-color: #95a5a6;
    margin: 0;
}

#clearLogBtn:hover {
    background-color: #7f8c8d;
}

/* 结果展示样式 */
.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.result-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.result-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.result-image-container {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.result-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.result-image:hover {
    transform: scale(1.05);
}

.image-error {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #6c757d;
    font-size: 14px;
}

.result-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

.result-image-container:hover .result-overlay {
    opacity: 1;
}

.result-btn {
    background: white;
    color: #333;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.result-btn:hover {
    background: #f8f9fa;
}

.view-btn {
    background: #007bff;
    color: white;
}

.download-btn {
    background: #28a745;
    color: white;
}

.result-info {
    padding: 15px;
}

.result-filename {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 14px;
}

.result-original {
    color: #6c757d;
    font-size: 12px;
    margin-bottom: 8px;
}

.result-status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.result-status.success {
    background: #d4edda;
    color: #155724;
}

.result-status.manual {
    background: #fff3cd;
    color: #856404;
}

.result-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.result-control-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin: 0;
}

.result-control-btn:hover {
    background: #5a6268;
}

.result-count {
    color: #6c757d;
    font-size: 14px;
    font-weight: 600;
}

/* 裁剪图片特殊样式 */
.cropped-item {
    border: 2px solid #007bff;
}

.cropped-item .result-filename {
    color: #007bff;
}

.cropped-item::before {
    content: "✂️";
    position: absolute;
    top: 5px;
    right: 5px;
    background: #007bff;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    z-index: 1;
}

/* 高清处理标识 */
.result-enhanced {
    font-size: 11px;
    color: #28a745;
    font-weight: 600;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.result-enhanced::before {
    content: "✨";
}

/* 图片尺寸信息 */
.result-dimensions {
    font-size: 10px;
    color: #6c757d;
    margin-top: 2px;
}

/* 裁剪类型信息 */
.result-crop-type {
    font-size: 11px;
    color: #007bff;
    font-weight: 600;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.result-crop-type::before {
    content: "✂️";
}

/* 智能裁剪项目样式 */
.cropped-item.enhanced {
    border-color: #28a745;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.cropped-item.enhanced::before {
    background: #28a745;
    content: "✨";
}

/* 本地图片裁剪区域样式 */
.local-crop-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    color: white;
}

.local-crop-section h2 {
    color: white;
    margin-bottom: 15px;
    text-align: center;
}

.local-crop-section .form-group label {
    color: white;
    font-weight: 600;
}

.local-crop-section .count-info {
    color: #e8f4fd;
    font-weight: 600;
    text-align: center;
    margin-top: 10px;
}

.local-crop-section .image-grid {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 10px;
    margin: 15px 0;
}

.local-crop-section .image-item {
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.local-crop-section .image-item:hover {
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.02);
    transition: all 0.2s ease;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .result-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    button {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
    }

    .task-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .result-control-btn {
        width: 100%;
        margin-bottom: 5px;
    }
}

/* 安全保护样式 */
img {
    pointer-events: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

/* 禁用图片的右键和选择，但允许工具功能正常工作 */
.image-grid img,
.result-image {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 确保按钮仍然可以点击 */
button, .result-btn {
    pointer-events: auto !important;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 禁用页面打印 */
@media print {
    body {
        display: none !important;
    }
}
