/* 头部区域样式 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

/* 修复：覆盖全局 header-actions 的 absolute 定位 */
.header .header-actions {
    position: static;
    transform: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 返回按钮样式 */
.back-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 18px;
    background-color: #f5f5f5;
    color: #666;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    height: 36px;
    box-sizing: border-box;
}

.back-btn:hover {
    background-color: #e8e8e8;
    color: #333;
    transform: translateY(-1px);
}

/* 收藏按钮样式 - 以返回按钮为模板 */
.favorite-button {
    display: inline-flex;
    align-items: center;
    padding: 6px 18px;
    background-color: #f5f5f5;
    color: #666;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    height: 36px;
    box-sizing: border-box;
    cursor: pointer;
    font-family: inherit;
}

.favorite-button:hover {
    background-color: #e8e8e8;
    color: #333;
    transform: translateY(-1px);
}

.favorite-button.favorited {
    background-color: #fff8e1;
    color: #f9a825;
}

.favorite-button.favorited:hover {
    background-color: #ffecb3;
    color: #f57f17;
}

/* 工具标题样式 */
.tool-title {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
    color: #1d1d1f;
}

.tool-subtitle {
    text-align: center;
    color: #6b7280;
    margin-bottom: 40px;
}

/* 工具主容器 */
.tool-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
    background-color: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* 安全提示 */
.security-tip {
    background-color: #f3f4f6;
    color: #6b7280;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 0;
    font-size: 14px;
    text-align: center;
}

/* 上传区域样式 */
.upload-section {
    text-align: center;
}

.upload-btn {
    display: inline-block;
    padding: 12px 24px;
    background-color: #10b981;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.upload-btn:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

#fileInput {
    display: none;
}

/* 预览区域样式 */
.preview-section {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
}

.image-container {
    position: relative;
    width: 400px;
    height: 400px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f9fafb;
}

.image-container img {
    position: relative;
    z-index: 1;
    max-width: 100%;
    max-height: 100%;
    display: none;
}

/* 选择框样式 */
.selection-box {
    position: absolute;
    border: 2px solid #2563eb;
    border-radius: 4px;
    cursor: move;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 10;
}

.resize-handle {
    position: absolute;
    width: 24px;
    height: 24px;
    background-color: #2563eb;
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.resize-handle.top-left {
    top: -12px;
    left: -12px;
    cursor: nwse-resize;
}

.resize-handle.top-right {
    top: -12px;
    right: -12px;
    cursor: nesw-resize;
}

.resize-handle.bottom-left {
    bottom: -12px;
    left: -12px;
    cursor: nesw-resize;
}

.resize-handle.bottom-right {
    bottom: -12px;
    right: -12px;
    cursor: nwse-resize;
}

/* 圆角框线 */
.corner-outline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid #9ca3af;
    border-radius: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    box-sizing: border-box;
    z-index: 5;
}
.corner-outline.active {
    opacity: 1;
}

/* 圆角效果预览 */
.round-preview {
    width: 400px;
    height: 400px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background-color: #f9fafb;
}

.round-preview canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
}

/* 控制区域样式 */
.controls-section {
    text-align: center;
}

.radius-control {
    margin-bottom: 20px;
}

.radius-control label {
    display: block;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: 500;
}

#radiusSlider {
    width: 300px;
    height: 6px;
    border-radius: 3px;
    background: #d1d5db;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#radiusSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2563eb;
    cursor: pointer;
}

#radiusSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2563eb;
    cursor: pointer;
    border: none;
}

#radiusValue {
    display: inline-block;
    margin-top: 10px;
    font-size: 14px;
    color: #6b7280;
}

/* 控制行 */
.controls-row {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* 横纵比控制 */
.aspect-ratio-control {
    text-align: center;
}

/* 圆角框线控制 */
.corner-outline-control {
    text-align: center;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #2563eb;
}

/* 操作按钮样式 */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none !important;
    border-radius: 8px !important;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-sizing: border-box !important;
}

.btn-primary {
    background-color: #2563eb;
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

/* 提示信息样式 */
.message {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    display: none;
}

.message.success {
    background-color: #d1fae5;
    color: #065f46;
    display: block;
}

.message.error {
    background-color: #fee2e2;
    color: #991b1b;
    display: block;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
        margin-top: 15px;
        margin-bottom: 15px;
    }

    .back-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .favorite-button {
        padding: 8px 12px;
        font-size: 13px;
    }

    .tool-title {
        font-size: 24px;
        margin-bottom: 15px;
    }

    .tool-container {
        padding: 20px;
        gap: 20px;
    }

    .image-container,
    .round-preview {
        width: 100%;
        height: 300px;
    }

    .preview-section {
        flex-direction: column;
        gap: 20px;
    }

    #radiusSlider {
        width: 100%;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}